libpqxx 7.8.1
time.hxx
1
5#ifndef PQXX_H_TIME
6#define PQXX_H_TIME
7
8#if !defined(PQXX_HEADER_PRE)
9# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
10#endif
11
12#include <chrono>
13#include <cstdlib>
14
15#include "pqxx/internal/concat.hxx"
16#include "pqxx/strconv.hxx"
17
18
19#if defined(PQXX_HAVE_YEAR_MONTH_DAY)
20
21namespace pqxx
22{
23using namespace std::literals;
24
25template<>
26struct nullness<std::chrono::year_month_day>
27 : no_null<std::chrono::year_month_day>
28{};
29
30
32
60template<> struct PQXX_LIBEXPORT string_traits<std::chrono::year_month_day>
61{
62 [[nodiscard]] static zview
63 to_buf(char *begin, char *end, std::chrono::year_month_day const &value)
64 {
65 return generic_to_buf(begin, end, value);
66 }
67
68 static char *
69 into_buf(char *begin, char *end, std::chrono::year_month_day const &value);
70
71 [[nodiscard]] static std::chrono::year_month_day
72 from_string(std::string_view text);
73
74 [[nodiscard]] static std::size_t
75 size_buffer(std::chrono::year_month_day const &) noexcept
76 {
77 static_assert(int{(std::chrono::year::min)()} >= -99999);
78 static_assert(int{(std::chrono::year::max)()} <= 99999);
79 return 5 + 1 + 2 + 1 + 2 + std::size(s_bc) + 1;
80 }
81
82private:
84 static constexpr std::string_view s_bc{" BC"sv};
85};
86} // namespace pqxx
87#endif // PQXX_HAVE_YEAR_MONTH_DAY
88#endif
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:33
T from_string(field const &value)
Convert a field's value to type T.
Definition field.hxx:520