/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-23 09:17:03 UTC
  • Revision ID: edam@waxworlds.org-20100723091703-3siqjj6eeux9hupz
- added NEWS
- added library checks to configure.ac
- added query::iterators
- remove dependency that rows have on querys (since querys have to be dependent on rows for boost::iterator_facade to work)
- rows now have the handle to the sqlite3 statement and know a count of their row number
- added convenience function tht can be used to detect presence of sqlite3cc in other packages
- updated test-main
- renamed all subdir.mk files to emake.mk

Show diffs side-by-side

added added

removed removed

36
36
 
37
37
class database;
38
38
class row;
39
 
namespace detail {
40
 
        struct null_t;
41
 
        struct exec_t;
42
 
        struct set_index_t;
43
 
}
 
39
struct _null_t;
 
40
struct _exec_t;
 
41
struct _set_index_t;
44
42
 
45
43
 
46
44
/**
243
241
        int bind_null(
244
242
                const std::string &name );
245
243
 
 
244
        /**
 
245
         * Stream operator is used to bind values to parameters automatically, in
 
246
         * ascending order. In addition, the null, set_index() and execute auto-
 
247
         * binding manipulators can be used.
 
248
         * @param value a value to bind
 
249
         */
 
250
        template< class T >
 
251
        basic_statement &operator <<(
 
252
                const T &value )
 
253
        {
 
254
                int error_code = bind( _bind_index, value );
 
255
                if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
 
256
                _bind_index++;
 
257
                return *this;
 
258
        }
 
259
 
246
260
//______________________________________________________________________________
247
261
//                                                                implementation
248
262
protected:
257
271
        int finalize();
258
272
 
259
273
        /**
 
274
         * Step through one execution cycle of the SQL statement. If this is an SQL
 
275
         * statement that doesn't return any rows, only one cycle is required,
 
276
         * otherwise, each cycle will return another row
 
277
         * @return an sqlite error code
 
278
         * @see sqlite3_step()
 
279
         */
 
280
        int step();
 
281
 
 
282
        /**
260
283
         * Get the index number of a named parameter
261
284
         * @param parameter name
262
285
         * @return index of named parameter
264
287
        int bind_parameter_index(
265
288
                const std::string &name );
266
289
 
267
 
        /**
268
 
         * Perform a step
269
 
         * @return sqlite error code
270
 
         * @see sqlite3_step()
271
 
         */
272
 
        int step();
273
 
 
274
290
        /** the database upon which to act */
275
291
        database &_database;
276
292
 
277
293
        /** the statement handle */
278
294
        sqlite3_stmt *_handle;
279
295
 
 
296
private:
 
297
 
280
298
        /** index used when auto-binding */
281
299
        unsigned int _bind_index;
282
300
 
283
301
};
284
302
 
285
303
 
 
304
// template specialisations for statement::operator <<()
 
305
template< >
 
306
basic_statement &basic_statement::operator << < _null_t >(
 
307
        const _null_t & );
 
308
template< >
 
309
basic_statement &basic_statement::operator << < _exec_t >(
 
310
        const _exec_t & );
 
311
template< >
 
312
basic_statement &basic_statement::operator << < _set_index_t >(
 
313
        const _set_index_t &t );
 
314
 
 
315
 
286
316
} // namespace sqlite
287
317
 
288
318