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(
73 io::
traits::kTypeBufferCategory<T>,
74 std::string{
compiler::GetTypeName<T>()}
77 static constexpr Oid GetOid(
const UserTypes&) {
79 return static_cast<Oid>(type_oid);
81 static constexpr Oid GetArrayOid(
const UserTypes&) {
83 return static_cast<Oid>(array_oid);
88struct CppToUserPgImpl;
93struct PgToCppPredefined {
94 static constexpr auto type_oid = TypeOid;
95 static_assert(type_oid !=
PredefinedOids::kInvalid,
"Type oid is invalid");
98 static constexpr auto array_oid = ArrayMapping::value;
99 static_assert(array_oid !=
PredefinedOids::kInvalid,
"Array type oid is invalid");
103 static const inline RegisterPredefinedOidParser init = RegisterPredefinedOidParser::Register(
106 io::
traits::kTypeBufferCategory<T>,
107 std::string{
compiler::GetTypeName<T>()}
116 std::enable_if_t<!
traits::kIsSpecialMapping<T> &&
traits::kIsMappedToPg<T> && !
traits::kIsMappedToArray<T>>>
117 : std::conditional_t<
traits::kIsMappedToSystemType<T>, detail::CppToSystemPgImpl<T>, detail::CppToUserPgImpl<T>> {};
120constexpr bool IsTypeMappedToSystem() {
121 return traits::kIsMappedToPg<T> &&
122 std::is_same<
typename CppToPg<T>::Mapping, CppToSystemPg<
typename CppToPg<T>::Type>>::value;
125void LogRegisteredTypes();