1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// file : odb/connection.ixx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::string
#include <cassert>
namespace odb
{
inline connection::
connection (database_type& database)
: database_ (database), tracer_ (0), transaction_tracer_ (0)
{
}
inline connection::database_type& connection::
database ()
{
return database_;
}
inline unsigned long long connection::
execute (const char* st)
{
return execute (st, std::strlen (st));
}
inline unsigned long long connection::
execute (const std::string& st)
{
return execute (st.c_str (), st.size ());
}
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const char* q)
{
return prepare_query<T> (n, query<T> (q));
}
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const std::string& q)
{
return prepare_query<T> (n, query<T> (q));
}
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const query<T>& q)
{
return query_<T, id_default>::call (*this, n, q);
}
template <typename T>
inline void connection::
cache_query (const prepared_query<T>& pq)
{
assert (pq);
cache_query_ (pq.impl_, typeid (T), 0, 0, 0);
}
template <typename T, typename P>
inline void connection::
cache_query (const prepared_query<T>& pq, std::auto_ptr<P> params)
{
assert (pq);
assert (params.get () != 0);
cache_query_ (
pq.impl_, typeid (T), params.get (), &typeid (P), ¶ms_deleter<P>);
params.release ();
}
#ifdef ODB_CXX11
template <typename T, typename P>
inline void connection::
cache_query (const prepared_query<T>& pq, std::unique_ptr<P> params)
{
assert (pq);
assert (params);
cache_query_ (
pq.impl_, typeid (T), params.get (), &typeid (P), ¶ms_deleter<P>);
params.release ();
}
#endif
template <typename T>
inline prepared_query<T> connection::
lookup_query (const char* name) const
{
return prepared_query<T> (lookup_query_ (name, typeid (T), 0, 0));
}
template <typename T, typename P>
inline prepared_query<T> connection::
lookup_query (const char* name, P*& params) const
{
return prepared_query<T> (
lookup_query_ (name,
typeid (T),
reinterpret_cast<void**> (¶ms),
&typeid (P)));
}
inline void connection::
tracer (tracer_type& t)
{
tracer_ = &t;
}
inline void connection::
tracer (tracer_type* t)
{
tracer_ = t;
}
inline connection::tracer_type* connection::
tracer () const
{
return tracer_;
}
inline connection::tracer_type* connection::
transaction_tracer () const
{
return transaction_tracer_;
}
}
|