exchange-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_EXCHANGE_TRAITS_H_INCLUDED
9 #define SOCI_EXCHANGE_TRAITS_H_INCLUDED
10 
11 #include "type-conversion-traits.h"
12 #include "soci-backend.h"
13 // std
14 #include <ctime>
15 #include <string>
16 #include <vector>
17 
18 namespace soci
19 {
20 
21 namespace details
22 {
23 
24 struct basic_type_tag {};
25 struct user_type_tag {};
26 
27 template <typename T>
29 {
30  // this is used for tag-dispatch between implementations for basic types
31  // and user-defined types
33 
34  enum // anonymous
35  {
36  x_type =
38  <
40  >::x_type
41  };
42 };
43 
44 template <>
45 struct exchange_traits<short>
46 {
48  enum { x_type = x_short };
49 };
50 
51 template <>
52 struct exchange_traits<unsigned short> : exchange_traits<short>
53 {
54 };
55 
56 template <>
57 struct exchange_traits<int>
58 {
60  enum { x_type = x_integer };
61 };
62 
63 template <>
64 struct exchange_traits<unsigned int> : exchange_traits<int>
65 {
66 };
67 
68 template <>
69 struct exchange_traits<char>
70 {
72  enum { x_type = x_char };
73 };
74 
75 template <>
76 struct exchange_traits<long long>
77 {
79  enum { x_type = x_long_long };
80 };
81 
82 template <>
83 struct exchange_traits<unsigned long long>
84 {
86  enum { x_type = x_unsigned_long_long };
87 };
88 
89 // long must be mapped either to x_integer or x_long_long:
90 template<int long_size> struct long_traits_helper;
91 template<> struct long_traits_helper<4> { enum { x_type = x_integer }; };
92 template<> struct long_traits_helper<8> { enum { x_type = x_long_long }; };
93 
94 template <>
95 struct exchange_traits<long int>
96 {
99 };
100 
101 template <>
102 struct exchange_traits<unsigned long> : exchange_traits<long>
103 {
104 };
105 
106 template <>
107 struct exchange_traits<double>
108 {
110  enum { x_type = x_double };
111 };
112 
113 template <>
114 struct exchange_traits<std::string>
115 {
117  enum { x_type = x_stdstring };
118 };
119 
120 template <>
121 struct exchange_traits<std::tm>
122 {
124  enum { x_type = x_stdtm };
125 };
126 
127 template <typename T>
128 struct exchange_traits<std::vector<T> >
129 {
131  enum { x_type = exchange_traits<T>::x_type };
132 };
133 
134 } // namespace details
135 
136 } // namespace soci
137 
138 #endif // SOCI_EXCHANGE_TRAITS_H_INCLUDED
exchange_traits< T >::type_family type_family


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