/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/query.h

  • Committer: edam
  • Date: 2010-07-29 06:28:53 UTC
  • Revision ID: edam@waxworlds.org-20100729062853-4i2fec52m86mh724
- made basic_statement::step() protected, for use by query and command only
- moved basic_statement::operator<<() to command and query instead; one needs to accept sqlite::exec, the other doesn't
- added tests for query::operator<<()
- added code to invlaidate in-progress queries during any transaction rollbacks (currently segfaults in basic_statement::finalize())
- added new sqlite_error constructor that obtains a full error message
- implemented database::database_mutex_guard class
- swapped command's step mutex in favour of the database mutex

Show diffs side-by-side

added added

removed removed

73
73
                const std::string &sql );
74
74
 
75
75
        /**
76
 
         * Peform a step() and return row object that can be used to retrieve the
 
76
         * Perform a step() and return row object that can be used to retrieve the
77
77
         * results.
78
78
         * @return a row object
79
79
         */
132
132
         */
133
133
        iterator end();
134
134
 
 
135
        /**
 
136
         * Stream operator is used to bind values to parameters automatically, in
 
137
         * ascending order. In addition, the null and set_index() auto-binding
 
138
         * manipulators can be used.
 
139
         * @param value a value to bind
 
140
         */
 
141
        template< class T >
 
142
        query &operator <<(
 
143
                const T &value )
 
144
        {
 
145
                int code = bind( _bind_index, value );
 
146
                if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
147
                _bind_index++;
 
148
                return *this;
 
149
        }
 
150
 
135
151
//______________________________________________________________________________
136
152
//                                                                implementation
137
153
private:
142
158
};
143
159
 
144
160
 
 
161
// template specialisations for query::operator <<()
 
162
template< >
 
163
query &query::operator << < detail::null_t >(
 
164
        const detail::null_t & );
 
165
template< >
 
166
query &query::operator << < detail::set_index_t >(
 
167
        const detail::set_index_t &t );
 
168
 
 
169
 
145
170
} // namespace sqlite
146
171
 
147
172