aboutsummaryrefslogtreecommitdiff
path: root/odb/connection.ixx
blob: fd1a62481e421eadbe26ed4329380f15558cca27 (plain)
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
// 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

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));
  }

  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_;
  }
}