6#include <userver/compiler/demangle.hpp>
7#include <userver/storages/postgres/detail/is_decl_complete.hpp>
8#include <userver/storages/postgres/io/pg_types.hpp>
9#include <userver/storages/postgres/io/traits.hpp>
10#include <userver/storages/postgres/io/type_traits.hpp>
12USERVER_NAMESPACE_BEGIN
17template <
typename T,
typename Enable = USERVER_NAMESPACE::utils::void_t<>>
37template <
typename... T>
38inline bool ForceReference(
const T&...) {
42struct RegisterPredefinedOidParser {
43 static RegisterPredefinedOidParser Register(
PredefinedOids type_oid,
46 std::string cpp_name);
50struct RegisterUserTypeParser {
51 static RegisterUserTypeParser Register(
const DBTypeName&,
52 std::string cpp_name);
59struct CppToSystemPgImpl {
61 using Mapping = CppToSystemPg<T>;
62 static constexpr auto type_oid = Mapping::value;
63 static_assert(type_oid !=
PredefinedOids::kInvalid,
"Type oid is invalid");
66 static constexpr auto array_oid = ArrayMapping::value;
68 "Array type oid is invalid");
74 static const inline RegisterPredefinedOidParser init_ =
75 RegisterPredefinedOidParser::Register(type_oid, array_oid,
79 static constexpr Oid GetOid(
const UserTypes&) {
80 ForceReference(init_);
81 return static_cast<Oid>(type_oid);
83 static constexpr Oid GetArrayOid(
const UserTypes&) {
84 ForceReference(init_);
85 return static_cast<Oid>(array_oid);
90struct CppToUserPgImpl;
96struct PgToCppPredefined {
97 static constexpr auto type_oid = TypeOid;
98 static_assert(type_oid !=
PredefinedOids::kInvalid,
"Type oid is invalid");
100 using ArrayMapping =
ArrayType<type_oid>;
101 static constexpr auto array_oid = ArrayMapping::value;
103 "Array type oid is invalid");
107 static const inline RegisterPredefinedOidParser init_ =
108 RegisterPredefinedOidParser::Register(type_oid, array_oid,
124constexpr bool IsTypeMappedToSystem() {
125 return traits::kIsMappedToPg<T> &&
126 std::is_same<
typename CppToPg<T>::Mapping,
127 CppToSystemPg<
typename CppToPg<T>::Type>>::value;
130void LogRegisteredTypes();