boost-optional.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
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_OPTIONAL_H_INCLUDED
9 #define SOCI_BOOST_OPTIONAL_H_INCLUDED
10 
11 #include "type-conversion-traits.h"
12 // boost
13 #include <boost/optional.hpp>
14 
15 namespace soci
16 {
17 
18 // simple fall-back for boost::optional
19 template <typename T>
20 struct type_conversion<boost::optional<T> >
21 {
23 
24  static void from_base(base_type const & in, indicator ind,
25  boost::optional<T> & out)
26  {
27  if (ind == i_null)
28  {
29  out.reset();
30  }
31  else
32  {
33  T tmp;
34  type_conversion<T>::from_base(in, ind, tmp);
35  out = tmp;
36  }
37  }
38 
39  static void to_base(boost::optional<T> const & in,
40  base_type & out, indicator & ind)
41  {
42  if (in.is_initialized())
43  {
44  type_conversion<T>::to_base(in.get(), out, ind);
45  }
46  else
47  {
48  ind = i_null;
49  }
50  }
51 };
52 
53 } // namespace soci
54 
55 #endif // SOCI_BOOST_OPTIONAL_H_INCLUDED
type_conversion< T >::base_type base_type
static void to_base(T const &in, base_type &out, indicator &ind)
static void from_base(base_type const &in, indicator ind, boost::optional< T > &out)
static void from_base(base_type const &in, indicator ind, T &out)
static void to_base(boost::optional< T > const &in, base_type &out, indicator &ind)


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