/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 06:39:13 UTC
  • Revision ID: edam@waxworlds.org-20100729063913-wvcvkogsa2alwkhr
- moved basic_statement::operator <<() back to basic_statement and just create another specialisation in command so that it can use sqlite::exec

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, set_index() and execute auto-
249
 
         * binding manipulators can be used.
 
248
         * ascending order. In addition, the null and set_index() auto-binding
 
249
         * 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 error_code = bind( _bind_index, value );
257
 
                if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
 
256
                int code = bind( _bind_index, value );
 
257
                if( code != SQLITE_OK ) throw sqlite_error( _database, 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
 
        /**
285
276
         * Get the index number of a named parameter
286
277
         * @param parameter name
287
278
         * @return index of named parameter
289
280
        int bind_parameter_index(
290
281
                const std::string &name );
291
282
 
 
283
        /**
 
284
         * Perform a step
 
285
         * @return sqlite error code
 
286
         * @see sqlite3_step()
 
287
         */
 
288
        int step();
 
289
 
292
290
        /** the database upon which to act */
293
291
        database &_database;
294
292
 
295
293
        /** the statement handle */
296
294
        sqlite3_stmt *_handle;
297
295
 
298
 
private:
299
 
 
300
296
        /** index used when auto-binding */
301
297
        unsigned int _bind_index;
302
298
 
303
299
};
304
300
 
305
301
 
306
 
// template specialisations for statement::operator <<()
 
302
// template specialisations for basic_statement::operator <<()
307
303
template< >
308
304
basic_statement &basic_statement::operator << < detail::null_t >(
309
305
        const detail::null_t & );
310
306
template< >
311
 
basic_statement &basic_statement::operator << < detail::exec_t >(
312
 
        const detail::exec_t & );
313
 
template< >
314
307
basic_statement &basic_statement::operator << < detail::set_index_t >(
315
308
        const detail::set_index_t &t );
316
309