11 #ifndef PQXX_H_STRINGCONV 12 #define PQXX_H_STRINGCONV 14 #include "pqxx/compiler-public.hxx" 23 #if __has_include(<charconv>) 27 #include "pqxx/except.hxx" 28 #include "pqxx/util.hxx" 29 #include "pqxx/zview.hxx" 75 template<
typename TYPE>
86 template<
typename TYPE,
typename ENABLE =
void>
struct nullness 92 static bool is_null(TYPE
const &value);
100 [[nodiscard]]
static TYPE
null();
107 static constexpr
bool has_null =
false;
108 [[nodiscard]]
static constexpr
bool is_null(TYPE
const &) noexcept
139 [[nodiscard]]
static inline zview 140 to_buf(
char *begin,
char *end, TYPE
const &value);
150 static inline char *into_buf(
char *begin,
char *end, TYPE
const &value);
156 [[nodiscard]]
static inline TYPE
from_string(std::string_view text);
163 [[nodiscard]]
static inline size_t size_buffer(TYPE
const &value);
168 template<
typename ENUM>
191 [[nodiscard]]
static constexpr
zview 192 to_buf(
char *begin,
char *end, ENUM
const &value)
194 return impl_traits::to_buf(begin, end, static_cast<impl_type>(value));
197 static constexpr
char *
into_buf(
char *begin,
char *end, ENUM
const &value)
199 return impl_traits::into_buf(begin, end, static_cast<impl_type>(value));
209 return impl_traits::size_buffer(static_cast<impl_type>(value));
227 #define PQXX_DECLARE_ENUM_CONVERSION(ENUM) \ 228 template<> struct string_traits<ENUM> : pqxx::internal::enum_traits<ENUM> \ 230 template<> std::string const type_name<ENUM> { #ENUM } 248 template<
typename T>[[nodiscard]]
inline T
from_string(std::string_view text)
262 template<
typename T>
inline void from_string(std::string_view text, T &value)
264 value = from_string<T>(text);
274 template<
typename TYPE>
inline std::string
to_string(TYPE
const &value);
281 template<
typename TYPE>
282 inline void into_string(TYPE
const &value, std::string &out);
286 template<
typename TYPE>[[nodiscard]]
inline bool is_null(TYPE
const &value)
316 #include "pqxx/internal/conversions.hxx" bool is_null(TYPE const &value)
Is value null?
Definition: strconv.hxx:286
std::string const type_name
A human-readable name for a type, used in error messages and such.
Definition: strconv.hxx:76
static size_t size_buffer(ENUM const &value)
Definition: strconv.hxx:207
constexpr char array_separator
Element separator between SQL array elements of this type.
Definition: strconv.hxx:311
static ENUM from_string(std::string_view text)
Definition: strconv.hxx:202
static constexpr bool is_null(TYPE const &) noexcept
Definition: strconv.hxx:108
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:32
std::string to_string(field const &value)
Convert a field to a string.
Definition: result.cxx:478
T from_string(field const &value)
Convert a field's string contents to another type.
Definition: field.hxx:355
static bool has_null
Does this type have a null value?
Definition: strconv.hxx:89
Definition: connection.hxx:59
Helper class for defining enum conversions.
Definition: strconv.hxx:186
void from_string(std::string_view text, T &value)
Attempt to convert postgres-generated string to given built-in object.
Definition: strconv.hxx:262
Nullness traits describing a type which does not have a null value.
Definition: strconv.hxx:105
constexpr bool is_sql_array
Does this type translate to an SQL array?
Definition: strconv.hxx:307
void into_string(TYPE const &value, std::string &out)
Convert a value to a readable string that PostgreSQL will understand.
void ignore_unused(T &&)
Suppress compiler warning about an unused item.
Definition: util.hxx:43
Traits describing a type's "null value," if any.
Definition: strconv.hxx:86
Dedicated namespace for helper types related to prepared statements.
Definition: array.hxx:25
static constexpr char * into_buf(char *begin, char *end, ENUM const &value)
Definition: strconv.hxx:197
std::string demangle_type_name(char const [])
Attempt to demangle std::type_info::name() to something human-readable.
Definition: strconv.cxx:223
Traits class for use in string conversions.
Definition: strconv.hxx:119
static constexpr zview to_buf(char *begin, char *end, ENUM const &value)
Definition: strconv.hxx:192
std::underlying_type_t< ENUM > impl_type
Definition: strconv.hxx:188