type-conversion-traits.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_TYPE_CONVERSION_TRAITS_H_INCLUDED
9 #define SOCI_TYPE_CONVERSION_TRAITS_H_INCLUDED
10 
11 #include "soci-backend.h"
12 
13 namespace soci
14 {
15 
16 // default traits class type_conversion, acts as pass through for row::get()
17 // when no actual conversion is needed.
18 template <typename T, typename Enable = void>
20 {
21  typedef T base_type;
22 
23  static void from_base(base_type const & in, indicator ind, T & out)
24  {
25  if (ind == i_null)
26  {
27  throw soci_error("Null value not allowed for this type");
28  }
29  out = in;
30  }
31 
32  static void to_base(T const & in, base_type & out, indicator & ind)
33  {
34  out = in;
35  ind = i_ok;
36  }
37 };
38 
39 } // namespace soci
40 
41 #endif // SOCI_TYPE_CONVERSION_TRAITS_H_INCLUDED
static void to_base(T const &in, base_type &out, indicator &ind)
static void from_base(base_type const &in, indicator ind, T &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:41