libpqxx  7.7.0
time.hxx
1 
5 #ifndef PQXX_H_TIME
6 #define PQXX_H_TIME
7 
8 #include <chrono>
9 #include <cstdlib>
10 
11 #include "pqxx/internal/concat.hxx"
12 #include "pqxx/strconv"
13 
14 
15 #if defined(PQXX_HAVE_YEAR_MONTH_DAY)
16 
17 namespace pqxx
18 {
19 using namespace std::literals;
20 
21 template<>
22 struct nullness<std::chrono::year_month_day>
23  : no_null<std::chrono::year_month_day>
24 {};
25 
26 
28 
56 template<> struct PQXX_LIBEXPORT string_traits<std::chrono::year_month_day>
57 {
58  [[nodiscard]] static zview
59  to_buf(char *begin, char *end, std::chrono::year_month_day const &value)
60  {
61  return generic_to_buf(begin, end, value);
62  }
63 
64  static char *
65  into_buf(char *begin, char *end, std::chrono::year_month_day const &value);
66 
67  [[nodiscard]] static std::chrono::year_month_day
68  from_string(std::string_view text);
69 
70  [[nodiscard]] static std::size_t
71  size_buffer(std::chrono::year_month_day const &) noexcept
72  {
73  static_assert(int{(std::chrono::year::min)()} >= -99999);
74  static_assert(int{(std::chrono::year::max)()} <= 99999);
75  return 5 + 1 + 2 + 1 + 2 + std::size(s_bc) + 1;
76  }
77 
78 private:
80  static constexpr std::string_view s_bc{" BC"sv};
81 };
82 } // namespace pqxx
83 #endif // PQXX_HAVE_YEAR_MONTH_DAY
84 #endif
zview generic_to_buf(char *begin, char *end, TYPE const &value)
Implement string_traits<TYPE>::to_buf by calling into_buf.
Definition: strconv.hxx:439
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:375
STL namespace.
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:343
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
T from_string(field const &value)
Convert a field&#39;s value to type T.
Definition: field.hxx:494