hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
soci_std_optional.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SOCI_STD_OPTIONAL_HPP
7 #define IROHA_SOCI_STD_OPTIONAL_HPP
8 
9 #include <soci/type-conversion-traits.h>
10 
11 #include <optional>
12 
13 namespace soci {
14 
15  // simple fall-back for std::optional
16  template <typename T>
17  struct type_conversion<std::optional<T>> {
18  typedef typename type_conversion<T>::base_type base_type;
19 
20  static void from_base(base_type const &in,
21  indicator ind,
22  std::optional<T> &out) {
23  if (ind == i_null) {
24  out.reset();
25  } else {
26  T tmp = T();
27  type_conversion<T>::from_base(in, ind, tmp);
28  out = tmp;
29  }
30  }
31 
32  static void to_base(std::optional<T> const &in,
33  base_type &out,
34  indicator &ind) {
35  if (in) {
36  type_conversion<T>::to_base(in.value(), out, ind);
37  } else {
38  ind = i_null;
39  }
40  }
41  };
42 
43 } // namespace soci
44 
45 #endif // IROHA_SOCI_STD_OPTIONAL_HPP
type_conversion< T >::base_type base_type
Definition: soci_std_optional.hpp:18
Definition: peer.hpp:48
static void to_base(std::optional< T > const &in, base_type &out, indicator &ind)
Definition: soci_std_optional.hpp:32
static void from_base(base_type const &in, indicator ind, std::optional< T > &out)
Definition: soci_std_optional.hpp:20
Definition: pool_wrapper.hpp:11