/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-27 15:46:42 UTC
  • Revision ID: edam@waxworlds.org-20100727154642-1uxrjkpxhp7xl6hq
- moved null_t, exec_t and set_index_t to detail namespace so only their extern instantiations are in the main namespace
- added immediate transation

Show diffs side-by-side

added added

removed removed

245
245
 
246
246
        /**
247
247
         * 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.
 
248
         * ascending order. In addition, the null, set_index() and execute auto-
 
249
         * binding manipulators can be used.
250
250
         * @param value a value to bind
251
251
         */
252
252
        template< class T >
253
253
        basic_statement &operator <<(
254
254
                const T &value )
255
255
        {
256
 
                int code = bind( _bind_index, value );
257
 
                if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
256
                int error_code = bind( _bind_index, value );
 
257
                if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
258
258
                _bind_index++;
259
259
                return *this;
260
260
        }
273
273
        int finalize();
274
274
 
275
275
        /**
 
276
         * Step through one execution cycle of the SQL statement. If this is an SQL
 
277
         * statement that doesn't return any rows, only one cycle is required,
 
278
         * otherwise, each cycle will return another row
 
279
         * @return an sqlite error code
 
280
         * @see sqlite3_step()
 
281
         */
 
282
        int step();
 
283
 
 
284
        /**
276
285
         * Get the index number of a named parameter
277
286
         * @param parameter name
278
287
         * @return index of named parameter
280
289
        int bind_parameter_index(
281
290
                const std::string &name );
282
291
 
283
 
        /**
284
 
         * Perform a step
285
 
         * @return sqlite error code
286
 
         * @see sqlite3_step()
287
 
         */
288
 
        int step();
289
 
 
290
292
        /** the database upon which to act */
291
293
        database &_database;
292
294
 
293
295
        /** the statement handle */
294
296
        sqlite3_stmt *_handle;
295
297
 
 
298
private:
 
299
 
296
300
        /** index used when auto-binding */
297
301
        unsigned int _bind_index;
298
302
 
299
303
};
300
304
 
301
305
 
302
 
// template specialisations for basic_statement::operator <<()
 
306
// template specialisations for statement::operator <<()
303
307
template< >
304
308
basic_statement &basic_statement::operator << < detail::null_t >(
305
309
        const detail::null_t & );
306
310
template< >
 
311
basic_statement &basic_statement::operator << < detail::exec_t >(
 
312
        const detail::exec_t & );
 
313
template< >
307
314
basic_statement &basic_statement::operator << < detail::set_index_t >(
308
315
        const detail::set_index_t &t );
309
316