once-temp-type.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_ONCE_TEMP_TYPE_H_INCLUDED
9 #define SOCI_ONCE_TEMP_TYPE_H_INCLUDED
10 
11 #include "ref-counted-statement.h"
12 #include "prepare-temp-type.h"
13 
14 #if __cplusplus >= 201103L
15 #define SOCI_ONCE_TEMP_TYPE_NOEXCEPT noexcept(false)
16 #else
17 #define SOCI_ONCE_TEMP_TYPE_NOEXCEPT
18 #endif
19 
20 namespace soci
21 {
22 
23 class session;
24 
25 namespace details
26 {
27 
28 class ref_counted_statement;
29 
30 // this needs to be lightweight and copyable
32 {
33 public:
34 
36  once_temp_type(once_temp_type const & o);
37  once_temp_type & operator=(once_temp_type const & o);
38 
40 
41  template <typename T>
42  once_temp_type & operator<<(T const & t)
43  {
44  rcst_->accumulate(t);
45  return *this;
46  }
47 
48  once_temp_type & operator,(into_type_ptr const &);
49  template <typename T, typename Indicator>
51  {
52  rcst_->exchange(ic);
53  return *this;
54  }
55  template <typename T, typename Indicator>
57  {
58  rcst_->exchange(uc);
59  return *this;
60  }
61 
62 private:
64 };
65 
66 // this needs to be lightweight and copyable
67 class once_type
68 {
69 public:
70  once_type() : session_(NULL) {}
71  once_type(session * s) : session_(s) {}
72 
73  void set_session(session * s)
74  {
75  session_ = s;
76  }
77 
78  template <typename T>
80  {
81  once_temp_type o(*session_);
82  o << t;
83  return o;
84  }
85 
86 private:
88 };
89 
90 
91 // this needs to be lightweight and copyable
93 {
94 public:
95  prepare_type() : session_(NULL) {}
96  prepare_type(session * s) : session_(s) {}
97 
98  void set_session(session * s)
99  {
100  session_ = s;
101  }
102 
103  template <typename T>
105  {
106  prepare_temp_type p(*session_);
107  p << t;
108  return p;
109  }
110 
111 private:
113 };
114 
115 } // namespace details
116 
117 } // namespace soci
118 
119 #endif
once_temp_type operator<<(T const &t)
prepare_temp_type operator<<(T const &t)
#define SOCI_DECL
Definition: soci-config.h:31
void set_session(session *s)
ref_counted_statement * rcst_
once_temp_type & operator<<(T const &t)
once_temp_type & operator,(into_container< T, Indicator > const &ic)
#define SOCI_ONCE_TEMP_TYPE_NOEXCEPT
void set_session(session *s)
once_temp_type & operator,(use_container< T, Indicator > const &uc)


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