7#include <unordered_map>
8#include <unordered_set>
10#include <userver/storages/postgres/exceptions.hpp>
11#include <userver/storages/postgres/io/pg_types.hpp>
12#include <userver/storages/postgres/io/type_mapping.hpp>
14USERVER_NAMESPACE_BEGIN
64 CompositeTypeDescription(CompositeFieldDefs::const_iterator begin,
65 CompositeFieldDefs::const_iterator end)
66 : attributes_{begin, end} {}
67 std::size_t Size()
const {
return attributes_.size(); }
68 bool Empty()
const {
return attributes_.empty(); }
70 if (index >= Size()) {
73 return attributes_[index];
77 CompositeFieldDefs attributes_;
85 UserTypes() =
default;
87 UserTypes(
UserTypes&&)
noexcept =
default;
111 bool HasParser(Oid)
const;
113 const io::TypeBufferCategory& GetTypeBufferCategories()
const;
116 void AddCompositeFields(CompositeFieldDefs&& defs);
132 DescriptionSet types_;
135 io::TypeBufferCategory buffer_categories_;
136 CompositeTypes composite_types_;
139namespace io::detail {
142inline constexpr DBTypeName kPgUserTypeName = CppToUserPg<T>::postgres_name;
145struct CppToUserPgImpl {
146 static_assert(
io::
traits::CheckParser<T>());
149 using Mapping = CppToUserPg<T>;
150 static constexpr DBTypeName postgres_name = kPgUserTypeName<T>;
151 static const detail::RegisterUserTypeParser init_;
152 static Oid GetOid(
const UserTypes& user_types) {
154 return user_types.FindOid(init_.postgres_name);
156 static Oid GetArrayOid(
const UserTypes& user_types) {
158 return user_types.FindArrayOid(init_.postgres_name);
163const RegisterUserTypeParser CppToUserPgImpl<T>::init_ =
164 RegisterUserTypeParser::Register(kPgUserTypeName<T>,
168void LogRegisteredTypesOnce();