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
22 CompositeTypeDescription(CompositeFieldDefs::const_iterator begin, CompositeFieldDefs::const_iterator end)
23 : attributes_{begin, end} {}
24 std::size_t Size()
const {
return attributes_.size(); }
25 bool Empty()
const {
return attributes_.empty(); }
27 if (index >= Size()) {
30 return attributes_[index];
34 CompositeFieldDefs attributes_;
42 UserTypes() =
default;
44 UserTypes(
UserTypes&&)
noexcept =
default;
68 bool HasParser(Oid)
const;
70 const io::TypeBufferCategory& GetTypeBufferCategories()
const;
73 void AddCompositeFields(CompositeFieldDefs&& defs);
91 DescriptionSet types_;
94 io::TypeBufferCategory buffer_categories_;
95 CompositeTypes composite_types_;
101inline constexpr DBTypeName kPgUserTypeName = CppToUserPg<T>::postgres_name;
104struct CppToUserPgImpl {
105 static_assert(io::
traits::CheckParser<T>());
108 using Mapping = CppToUserPg<T>;
109 static constexpr DBTypeName postgres_name = kPgUserTypeName<T>;
110 static const detail::RegisterUserTypeParser init_;
111 static Oid GetOid(
const UserTypes& user_types) {
113 return user_types.FindOid(init_.postgres_name);
115 static Oid GetArrayOid(
const UserTypes& user_types) {
117 return user_types.FindArrayOid(init_.postgres_name);
122const RegisterUserTypeParser CppToUserPgImpl<T>::init_ =
123 RegisterUserTypeParser::Register(kPgUserTypeName<T>,
compiler::GetTypeName<T>());
126void LogRegisteredTypesOnce();