aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/container-statements.txx
blob: a993d31b59feb734055904d0206e86e22e4e8739 (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
// file      : odb/mysql/container-statements.txx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#include <cstddef> // std::size_t
#include <cstring> // std::memset

namespace odb
{
  namespace mysql
  {
    // container_statements
    //

    template <typename T>
    container_statements<T>::
    container_statements (connection_type& conn)
        : conn_ (conn),
          functions_ (this,
                      &traits::insert_one,
                      &traits::load_all,
                      &traits::delete_all),
          id_binding_ (0),
          cond_image_binding_ (0, 0), // Initialized by impl.
          data_image_binding_ (0, 0)  // Initialized by impl.
    {
      cond_image_.version = 0;
      cond_image_version_ = 0;
      cond_id_binding_version_ = 0;

      data_image_.version = 0;
      data_image_version_ = 0;
      data_id_binding_version_ = 0;
    }

    template <typename T>
    container_statements_impl<T>::
    container_statements_impl (connection_type& conn)
        : base (conn)
    {
      this->cond_image_bind_ = cond_image_bind_array_;
      this->data_image_bind_ = data_image_bind_array_;
      this->data_image_truncated_ = data_image_truncated_array_;

      this->cond_image_binding_.bind = this->cond_image_bind_;
      this->cond_image_binding_.count = traits::cond_column_count;

      this->data_image_binding_.bind = this->data_image_bind_;
      this->data_image_binding_.count = traits::data_column_count;

      std::memset (cond_image_bind_array_, 0, sizeof (cond_image_bind_array_));
      std::memset (data_image_bind_array_, 0, sizeof (data_image_bind_array_));
      std::memset (data_image_truncated_array_,
                   0,
                   sizeof (data_image_truncated_array_));

      for (std::size_t i (0); i < traits::data_column_count; ++i)
        data_image_bind_array_[i].error = data_image_truncated_array_ + i;

      this->insert_one_text_ = traits::insert_one_statement;
      this->select_all_text_ = traits::select_all_statement;
      this->delete_all_text_ = traits::delete_all_statement;
    }
  }
}