/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/command.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

126
126
                return _last_insert_rowid;
127
127
        }
128
128
 
 
129
        /**
 
130
         * Stream operator is used to bind values to parameters automatically, in
 
131
         * ascending order. In addition, the null, set_index() and execute auto-
 
132
         * binding manipulators can be used.
 
133
         * @param value a value to bind
 
134
         */
 
135
        template< class T >
 
136
        command &operator <<(
 
137
                const T &value )
 
138
        {
 
139
                int code = bind( _bind_index, value );
 
140
                if( code != SQLITE_OK ) throw sqlite_error( _database, code );
 
141
                _bind_index++;
 
142
                return *this;
 
143
        }
 
144
 
129
145
//______________________________________________________________________________
130
146
//                                                                implementation
131
147
private:
142
158
};
143
159
 
144
160
 
145
 
// template specialisations for basic_statement::operator <<()
146
 
template< >
147
 
basic_statement &basic_statement::operator << < detail::exec_t >(
 
161
// template specialisations for command::operator <<()
 
162
template< >
 
163
command &command::operator << < detail::null_t >(
 
164
        const detail::null_t & );
 
165
template< >
 
166
command &command::operator << < detail::exec_t >(
148
167
        const detail::exec_t & );
 
168
template< >
 
169
command &command::operator << < detail::set_index_t >(
 
170
        const detail::set_index_t &t );
149
171
 
150
172
 
151
173
} // namespace sqlite