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
48struct RegisterUserTypeParser {
49 static RegisterUserTypeParser Register(
const DBTypeName&, std::string cpp_name);
56struct CppToSystemPgImpl {
58 using Mapping = CppToSystemPg<T>;
59 static constexpr auto type_oid = Mapping::value;
60 static_assert(type_oid !=
PredefinedOids::kInvalid,
"Type oid is invalid");
63 static constexpr auto array_oid = ArrayMapping::value;
64 static_assert(array_oid !=
PredefinedOids::kInvalid,
"Array type oid is invalid");
70 static const inline RegisterPredefinedOidParser init_ = RegisterPredefinedOidParser::Register(
77 static constexpr Oid GetOid(
const UserTypes&) {
78 ForceReference(init_);
79 return static_cast<Oid>(type_oid);
81 static constexpr Oid GetArrayOid(
const UserTypes&) {
82 ForceReference(init_);
83 return static_cast<Oid>(array_oid);
88struct CppToUserPgImpl;
94struct PgToCppPredefined {
95 static constexpr auto type_oid = TypeOid;
96 static_assert(type_oid !=
PredefinedOids::kInvalid,
"Type oid is invalid");
99 static constexpr auto array_oid = ArrayMapping::value;
100 static_assert(array_oid !=
PredefinedOids::kInvalid,
"Array type oid is invalid");
104 static const inline RegisterPredefinedOidParser init_ = RegisterPredefinedOidParser::Register(
121constexpr bool IsTypeMappedToSystem() {
122 return traits::kIsMappedToPg<T> &&
123 std::is_same<
typename CppToPg<T>::Mapping, CppToSystemPg<
typename CppToPg<T>::Type>>::value;
126void LogRegisteredTypes();