libpqxx 7.7.0
|
Traits class for use in string conversions. More...
#include <strconv.hxx>
Static Public Member Functions | |
static zview | to_buf (char *begin, char *end, TYPE const &value) |
Return a string_view representing value, plus terminating zero. More... | |
static char * | into_buf (char *begin, char *end, TYPE const &value) |
Write value's string representation into buffer at begin . More... | |
static TYPE | from_string (std::string_view text) |
Parse a string representation of a TYPE value. More... | |
static std::size_t | size_buffer (TYPE const &value) noexcept |
Estimate how much buffer space is needed to represent value. More... | |
Traits class for use in string conversions.
Specialize this template for a type for which you wish to add to_string and from_string support.
String conversions are not meant to work for nulls. Check for null before converting a value of TYPE
to a string, or vice versa.
|
static |
Parse a string representation of a TYPE
value.
Throws conversion_error
if value
does not meet the expected format for a value of this type.
References pqxx::text.
Referenced by pqxx::internal::enum_traits< ENUM >::from_string(), and pqxx::from_string().
|
static |
Write value's string representation into buffer at begin
.
Assumes that value is non-null.
Writes value's string representation into the buffer, starting exactly at begin
, and ensuring a trailing zero. Returns the address just beyond the trailing zero, so the caller could use it as the begin
for another call to into_buf
writing a next value.
Referenced by pqxx::internal::enum_traits< ENUM >::into_buf(), and pqxx::placeholders< COUNTER >::next().
|
staticnoexcept |
Estimate how much buffer space is needed to represent value.
The estimate may be a little pessimistic, if it saves time.
The estimate includes the terminating zero.
Referenced by pqxx::string_traits< binarystring >::into_buf(), and pqxx::internal::enum_traits< ENUM >::size_buffer().
|
static |
Return a string_view
representing value, plus terminating zero.
Produces a string_view
containing the PostgreSQL string representation for value
.
Uses the space from begin
to end
as a buffer, if needed. The returned string may lie somewhere in that buffer, or it may be a compile-time constant, or it may be null if value was a null value. Even if the string is stored in the buffer, its begin()
may or may not be the same as begin
.
The string_view
is guaranteed to be valid as long as the buffer from begin
to end
remains accessible and unmodified.
pqxx::conversion_overrun | if the provided buffer space may not be enough. For maximum performance, this is a conservative estimate. It may complain about a buffer which is actually large enough for your value, if an exact check gets too expensive. |
Referenced by pqxx::internal::enum_traits< ENUM >::to_buf().