/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-02-02 16:13:16 UTC
  • Revision ID: edam@waxworlds.org-20100202161316-tceybmdeotltldow
- print "ok" when test program is successful!
- renamed 'Makefile's 'subdir.mk' so that the edam.mk build system will live happily along side an autotools build system

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
/**
74
72
        explicit basic_statement(
75
73
                database &database );
76
74
 
77
 
        virtual ~basic_statement();
 
75
        virtual ~basic_statement() throw( );
78
76
 
79
77
//______________________________________________________________________________
80
78
//                                                              public interface
245
243
 
246
244
        /**
247
245
         * Stream operator is used to bind values to parameters automatically, in
248
 
         * ascending order. In addition, the null and set_index() auto-binding
249
 
         * manipulators can be used.
 
246
         * ascending order. In addition, the null, set_index() and execute auto-
 
247
         * binding manipulators can be used.
250
248
         * @param value a value to bind
251
249
         */
252
250
        template< class T >
253
251
        basic_statement &operator <<(
254
252
                const T &value )
255
253
        {
256
 
                int code = bind( _bind_index, value );
257
 
                if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
254
                int error_code = bind( _bind_index, value );
 
255
                if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
258
256
                _bind_index++;
259
257
                return *this;
260
258
        }
273
271
        int finalize();
274
272
 
275
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
        /**
276
283
         * Get the index number of a named parameter
277
284
         * @param parameter name
278
285
         * @return index of named parameter
280
287
        int bind_parameter_index(
281
288
                const std::string &name );
282
289
 
283
 
        /**
284
 
         * Perform a step
285
 
         * @return sqlite error code
286
 
         * @see sqlite3_step()
287
 
         */
288
 
        int step();
289
 
 
290
290
        /** the database upon which to act */
291
291
        database &_database;
292
292
 
293
293
        /** the statement handle */
294
294
        sqlite3_stmt *_handle;
295
295
 
 
296
private:
 
297
 
296
298
        /** index used when auto-binding */
297
299
        unsigned int _bind_index;
298
300
 
299
301
};
300
302
 
301
303
 
302
 
// template specialisations for basic_statement::operator <<()
303
 
template< >
304
 
basic_statement &basic_statement::operator << < detail::null_t >(
305
 
        const detail::null_t & );
306
 
template< >
307
 
basic_statement &basic_statement::operator << < detail::set_index_t >(
308
 
        const detail::set_index_t &t );
 
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 );
309
314
 
310
315
 
311
316
} // namespace sqlite