aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/connection.ixx
blob: c1bf77a9950f35f1cf3f3f16fa31b07ca5c906f8 (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/sqlite/connection.ixx
// license   : GNU GPL v2; see accompanying LICENSE file

namespace odb
{
  namespace sqlite
  {
    // active_objects
    //
    inline void active_object::
    list_add ()
    {
      next_ = conn_.active_objects_;
      conn_.active_objects_ = this;

      if (next_ != 0)
        next_->prev_ = this;
    }

    inline void active_object::
    list_remove ()
    {
      (prev_ == 0 ? conn_.active_objects_ : prev_->next_) = next_;

      if (next_ != 0)
        next_->prev_ = prev_;

      prev_ = 0;
      next_ = this;
    }

    // connection
    //
    inline database& connection::
    database ()
    {
      return static_cast<connection_factory&> (factory_).database ();
    }

    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 sqlite::query_base& q)
    {
      return query_<T, id_sqlite>::call (*this, n, q);
    }

    template <typename T>
    inline prepared_query<T> connection::
    prepare_query (const char* n, const odb::query_base& q)
    {
      // Translate to native query.
      //
      return prepare_query<T> (n, sqlite::query_base (q));
    }
  }
}