Loading...
Searching...
No Matches
time.hxx
#ifndef PQXX_H_TIME
#define PQXX_H_TIME
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif
#include <chrono>
#include <cstdlib>
#include "pqxx/internal/concat.hxx"
#include "pqxx/strconv.hxx"
#if defined(PQXX_HAVE_YEAR_MONTH_DAY)
namespace pqxx
{
using namespace std::literals;
template<>
struct nullness<std::chrono::year_month_day>
: no_null<std::chrono::year_month_day>
{};
template<> struct PQXX_LIBEXPORT string_traits<std::chrono::year_month_day>
{
[[nodiscard]] static zview
to_buf(char *begin, char *end, std::chrono::year_month_day const &value)
{
return generic_to_buf(begin, end, value);
}
static char *
into_buf(char *begin, char *end, std::chrono::year_month_day const &value);
[[nodiscard]] static std::chrono::year_month_day
from_string(std::string_view text);
[[nodiscard]] static std::size_t
size_buffer(std::chrono::year_month_day const &) noexcept
{
static_assert(int{(std::chrono::year::min)()} >= -99999);
static_assert(int{(std::chrono::year::max)()} <= 99999);
return 5 + 1 + 2 + 1 + 2 + std::size(s_bc) + 1;
}
private:
static constexpr std::string_view s_bc{" BC"sv};
};
} // namespace pqxx
#endif // PQXX_HAVE_YEAR_MONTH_DAY
#endif
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
pqxx::to_buf
std::vector< std::string_view > to_buf(char *here, char const *end, TYPE... value)
Convert multiple values to strings inside a single buffer.
Definition strconv.hxx:493
pqxx::size_buffer
std::size_t size_buffer(TYPE const &...value) noexcept
Estimate how much buffer space is needed to represent values as a string.
Definition strconv.hxx:526
pqxx::generic_to_buf
zview generic_to_buf(char *begin, char *end, TYPE const &value)
Implement string_traits<TYPE>::to_buf by calling into_buf.
Definition strconv.hxx:587
pqxx::from_string
T from_string(field const &value)
Convert a field's value to type T.
Definition field.hxx:548
pqxx::no_null
Nullness traits describing a type which does not have a null value.
Definition strconv.hxx:113
pqxx::nullness
Traits describing a type's "null value," if any.
Definition strconv.hxx:91
pqxx::string_traits
Traits class for use in string conversions.
Definition strconv.hxx:154