/sqlite3cc

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

« back to all changes in this revision

Viewing changes to include/sqlite3cc/basic_statement.h

  • Committer: edam
  • Date: 2010-07-29 20:56:19 UTC
  • Revision ID: edam@waxworlds.org-20100729205619-a9yo4uzu647nvnsj
- renamed database to connection to better identify what it is (would database_connection be better though?)
- moved basic_statement and basic_transaction to sqlite::detail
- made sqlite::threadsafe() return the threading mode int, not a bool
- renamed row::index() to row_number() so it isn't confused with column index
- added typedef for deferred_transaction
- added early rollback method to transaction_guard
- allowed transaction_guard::~transaction_guard() to throw exceptions, since when it needs to, we're really screwed anyway
- bugfix: query::reset() didn't reset the internal row counter
- added query::num_results()
- added docs/design-notes
- reimplemented query::iterator so that increment() (which performs a step() on the query) now caches the returned row to be returned during dereference() (previously it stashed details and returned new row!?)
- bugfix: resetting active queries during rollbacks would hang!

Show diffs side-by-side

added added

removed removed

34
34
{
35
35
 
36
36
 
37
 
class database;
 
37
class connection;
38
38
class row;
39
39
namespace detail {
40
40
        struct null_t;
43
43
}
44
44
 
45
45
 
 
46
namespace detail
 
47
{
 
48
 
 
49
 
46
50
/**
47
51
 * The statement class represents an SQL statement. It is the base class for
48
52
 * both the command and the query classes, which should be used for those
57
61
protected:
58
62
 
59
63
        /**
60
 
         * Constructor that provides a database upon which to act and the SQL
 
64
         * Constructor that provides a connection upon which to act and the SQL
61
65
         * statement.
62
 
         * @param database a reference to a database
 
66
         * @param connection a reference to a connection
63
67
         * @param sql an SQL statement in UTF-8
64
68
         */
65
69
        explicit basic_statement(
66
 
                database &database,
 
70
                connection &connection,
67
71
                const std::string &sql );
68
72
 
69
73
        /**
70
 
         * Constructor that provides a database upon which to act.
71
 
         * @param database a reference to a database
72
 
         * @param sql an SQL statement in UTF-8
 
74
         * Constructor that provides a connection upon which to act.
 
75
         * @param connection a reference to a connection
73
76
         */
74
77
        explicit basic_statement(
75
 
                database &database );
 
78
                connection &connection );
76
79
 
77
80
        virtual ~basic_statement();
78
81
 
95
98
         * @returns an sqlite error code
96
99
         * @see sqlite3_reset()
97
100
         */
98
 
        int reset();
 
101
        virtual int reset();
99
102
 
100
103
        /**
101
104
         * Clears the values bound to a statement to NULL.
127
130
        /**
128
131
         * Bind a string value to the SQL statement via it's index where the value
129
132
         * of that string will not change for the duration of the statement. This is
130
 
         * more optimal because sqlite will not have to make it's own copy of the
 
133
         * more optimal because sqlite will not have to take it's own copy of the
131
134
         * data.
132
135
         * @param index the index of the parameter to bind to
133
136
         * @param value the invariant string value
 
137
         * @param value_length the length of the string including zero-terminator
134
138
         * @returns an sqlite error code
135
139
         * @see sqlite3_bind_text()
136
140
         */
142
146
        /**
143
147
         * Bind a string value to the SQL statement via it's index where the value
144
148
         * of that string will not change for the duration of the statement. This is
145
 
         * more optimal  because sqlite will not have to make it's own copy of the
 
149
         * more optimal  because sqlite will not have to take it's own copy of the
146
150
         * data.
147
151
         * @param index the index of the parameter to bind to
148
152
         * @param value the invariant string value
156
160
        /**
157
161
         * Bind a string value to the SQL statement via it's index where the value
158
162
         * of that string will not change for the duration of the statement. This is
159
 
         * more optimal because sqlite will not have to make it's own copy of the
 
163
         * more optimal because sqlite will not have to take it's own copy of the
160
164
         * data.
161
165
         * @param index the index of the parameter to bind to
162
166
         * @param value the invariant string value
197
201
        /**
198
202
         * Bind a string value to the SQL statement via a named parameter where the
199
203
         * string value will not change for the duration of the statement. This
200
 
         * prevents a copy of the string being taken.
 
204
         * prevents sqlite from taking its own copy of the string.
201
205
         * @param name the named parameter to bind to
202
206
         * @param value the invariant string value
 
207
         * @param value_length the length of the string including zero-terminator
203
208
         * @returns an sqlite error code
204
209
         * @see sqlite3_bind_text()
205
210
         */
254
259
                const T &value )
255
260
        {
256
261
                int code = bind( _bind_index, value );
257
 
                if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
262
                if( code != SQLITE_OK ) throw sqlite_error( _connection, code );
258
263
                _bind_index++;
259
264
                return *this;
260
265
        }
287
292
         */
288
293
        int step();
289
294
 
290
 
        /** the database upon which to act */
291
 
        database &_database;
 
295
        /** the connection upon which to act */
 
296
        connection &_connection;
292
297
 
293
298
        /** the statement handle */
294
299
        sqlite3_stmt *_handle;
308
313
        const detail::set_index_t &t );
309
314
 
310
315
 
 
316
} // namespace detail
 
317
 
 
318
 
311
319
} // namespace sqlite
312
320
 
313
321