boost-gregorian-date.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 Maciej Sobczak
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #ifndef SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED
9 #define SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED
10 
11 #include "type-conversion-traits.h"
12 // boost
13 #include <boost/date_time/gregorian/gregorian_types.hpp>
14 #include <boost/date_time/gregorian/conversion.hpp>
15 // std
16 #include <ctime>
17 
18 namespace soci
19 {
20 
21 template<>
22 struct type_conversion<boost::gregorian::date>
23 {
24  typedef std::tm base_type;
25 
26  static void from_base(
27  base_type const & in, indicator ind, boost::gregorian::date & out)
28  {
29  if (ind == i_null)
30  {
31  throw soci_error("Null value not allowed for this type");
32  }
33 
34  out = boost::gregorian::date_from_tm(in);
35  }
36 
37  static void to_base(
38  boost::gregorian::date const & in, base_type & out, indicator & ind)
39  {
40  out = boost::gregorian::to_tm(in);
41  ind = i_ok;
42  }
43 };
44 
45 } // namespace soci
46 
47 #endif // SOCI_BOOST_GREGORIAN_DATE_H_INCLUDED
static void to_base(boost::gregorian::date const &in, base_type &out, indicator &ind)
static void from_base(base_type const &in, indicator ind, boost::gregorian::date &out)


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40