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
17namespace pqxx
18{
19using namespace std::literals;
20
21template<>
22struct nullness<std::chrono::year_month_day>
23 : no_null<std::chrono::year_month_day>
24{};
25
26
28
56template<> 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
78private:
80 static constexpr std::string_view s_bc{" BC"sv};
81};
82} // namespace pqxx
83#endif // PQXX_HAVE_YEAR_MONTH_DAY
84#endif
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:23
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
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
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
T from_string(field const &value)
Convert a field's value to type T.
Definition: field.hxx:494