/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to src/basic_statement.cc

  • Committer: edam
  • Date: 2012-01-23 13:47:08 UTC
  • Revision ID: edam@waxworlds.org-20120123134708-ol4tilkotsm3han0
updated build system

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <sqlite3cc/basic_statement.h>
24
24
#include <sqlite3cc/exception.h>
25
 
#include <sqlite3cc/database.h>
 
25
#include <sqlite3cc/connection.h>
26
26
#include <sqlite3cc/manipulator.h>
27
27
#include <string.h>
28
28
 
29
29
 
30
 
sqlite::basic_statement::basic_statement(
31
 
        database &database,
 
30
sqlite::detail::basic_statement::basic_statement(
 
31
        connection &connection,
32
32
        const std::string &sql )
33
33
        :
34
 
        _database( database ),
 
34
        _connection( connection ),
35
35
        _handle( NULL ),
36
36
        _bind_index( 1 )
37
37
{
38
38
        int code = prepare( sql );
39
 
        if( code != SQLITE_OK ) throw sqlite_error( database, code );
 
39
        if( code != SQLITE_OK ) throw sqlite_error( connection, code );
40
40
}
41
41
 
42
42
 
43
 
sqlite::basic_statement::basic_statement(
44
 
        database &database )
 
43
sqlite::detail::basic_statement::basic_statement(
 
44
        connection &connection )
45
45
        :
46
 
        _database( database ),
 
46
        _connection( connection ),
47
47
        _handle( NULL ),
48
48
        _bind_index( 1 )
49
49
{
50
50
}
51
51
 
52
52
 
53
 
sqlite::basic_statement::~basic_statement()
 
53
sqlite::detail::basic_statement::~basic_statement()
54
54
{
55
55
        finalize();
56
56
}
57
57
 
58
58
 
59
 
int sqlite::basic_statement::prepare(
 
59
int sqlite::detail::basic_statement::prepare(
60
60
        const std::string &sql )
61
61
{
62
62
        finalize();
63
 
        return sqlite3_prepare_v2( _database._handle, sql.c_str(),
 
63
        return sqlite3_prepare_v2( _connection._handle, sql.c_str(),
64
64
                sql.length() + 1, &_handle, NULL );
65
65
}
66
66
 
67
67
 
68
 
int sqlite::basic_statement::reset()
 
68
int sqlite::detail::basic_statement::reset()
69
69
{
70
70
        return sqlite3_reset( _handle );
71
71
}
72
72
 
73
73
 
74
 
int sqlite::basic_statement::clear_bindings()
 
74
int sqlite::detail::basic_statement::clear_bindings()
75
75
{
76
76
        _bind_index = 1;
77
77
        return sqlite3_clear_bindings( _handle );
78
78
}
79
79
 
80
80
 
81
 
int sqlite::basic_statement::bind_static(
 
81
int sqlite::detail::basic_statement::bind_static(
82
82
        unsigned int index,
83
83
        const char *value,
84
84
        unsigned int value_length )
88
88
}
89
89
 
90
90
 
91
 
int sqlite::basic_statement::bind_static(
 
91
int sqlite::detail::basic_statement::bind_static(
92
92
        unsigned int index,
93
93
        const char *value )
94
94
{
96
96
}
97
97
 
98
98
 
99
 
int sqlite::basic_statement::bind_static(
 
99
int sqlite::detail::basic_statement::bind_static(
100
100
        unsigned int index,
101
101
        const std::string &value )
102
102
{
104
104
}
105
105
 
106
106
 
107
 
int sqlite::basic_statement::bind_null(
 
107
int sqlite::detail::basic_statement::bind_null(
108
108
        unsigned int index )
109
109
{
110
110
        return sqlite3_bind_null( _handle, index );
111
111
}
112
112
 
113
113
 
114
 
int sqlite::basic_statement::bind_static(
 
114
int sqlite::detail::basic_statement::bind_static(
115
115
        const std::string &name,
116
116
        const char *value,
117
117
        unsigned int value_length )
120
120
}
121
121
 
122
122
 
123
 
int sqlite::basic_statement::bind_static(
 
123
int sqlite::detail::basic_statement::bind_static(
124
124
        const std::string &name,
125
125
        const char *value )
126
126
{
128
128
}
129
129
 
130
130
 
131
 
int sqlite::basic_statement::bind_static(
 
131
int sqlite::detail::basic_statement::bind_static(
132
132
        const std::string &name,
133
133
        const std::string &value )
134
134
{
136
136
}
137
137
 
138
138
 
139
 
int sqlite::basic_statement::bind_null(
 
139
int sqlite::detail::basic_statement::bind_null(
140
140
        const std::string &name )
141
141
{
142
142
        return bind_null( bind_parameter_index( name ) );
143
143
}
144
144
 
145
145
 
146
 
int sqlite::basic_statement::finalize()
 
146
int sqlite::detail::basic_statement::finalize()
147
147
{
148
148
        int code = SQLITE_OK;
149
149
 
156
156
}
157
157
 
158
158
 
159
 
int sqlite::basic_statement::bind_parameter_index(
 
159
int sqlite::detail::basic_statement::bind_parameter_index(
160
160
        const std::string &name )
161
161
{
162
162
        unsigned int index = sqlite3_bind_parameter_index( _handle, name.c_str() );
165
165
}
166
166
 
167
167
 
168
 
int sqlite::basic_statement::step()
 
168
int sqlite::detail::basic_statement::step()
169
169
{
170
170
        return sqlite3_step( _handle );
171
171
}
173
173
 
174
174
 
175
175
template< >
176
 
sqlite::basic_statement &sqlite::basic_statement::operator <<
 
176
sqlite::detail::basic_statement &sqlite::detail::basic_statement::operator <<
177
177
        < sqlite::detail::null_t >(
178
178
        const sqlite::detail::null_t & )
179
179
{
180
180
        int code = bind_null( _bind_index );
181
 
        if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
181
        if( code != SQLITE_OK ) throw sqlite_error( _connection, code );
182
182
        _bind_index++;
183
183
        return *this;
184
184
}
185
185
 
186
186
 
187
187
template< >
188
 
sqlite::basic_statement &sqlite::basic_statement::operator <<
 
188
sqlite::detail::basic_statement &sqlite::detail::basic_statement::operator <<
189
189
        < sqlite::detail::set_index_t >(
190
190
        const sqlite::detail::set_index_t &t )
191
191
{