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

  • Committer: edam
  • Date: 2010-07-29 20:56:19 UTC
  • Revision ID: edam@waxworlds.org-20100729205619-a9yo4uzu647nvnsj
- renamed database to connection to better identify what it is (would database_connection be better though?)
- moved basic_statement and basic_transaction to sqlite::detail
- made sqlite::threadsafe() return the threading mode int, not a bool
- renamed row::index() to row_number() so it isn't confused with column index
- added typedef for deferred_transaction
- added early rollback method to transaction_guard
- allowed transaction_guard::~transaction_guard() to throw exceptions, since when it needs to, we're really screwed anyway
- bugfix: query::reset() didn't reset the internal row counter
- added query::num_results()
- added docs/design-notes
- reimplemented query::iterator so that increment() (which performs a step() on the query) now caches the returned row to be returned during dereference() (previously it stashed details and returned new row!?)
- bugfix: resetting active queries during rollbacks would hang!

Show diffs side-by-side

added added

removed removed

36
36
{
37
37
 
38
38
 
39
 
struct _null_t;
40
 
struct _set_index_t;
41
39
class query;
 
40
namespace detail {
 
41
        struct null_t;
 
42
        struct set_index_t;
 
43
}
42
44
 
43
45
 
44
46
/**
58
60
 
59
61
        /**
60
62
         * Constructor that produces a valid row.
61
 
         * @param the handle of the statement (query) that created this row
62
 
         * @oaram the result index that is this row
 
63
         * @param handle of the statement (query) that created this row
 
64
         * @oaram row_number the index of this row
63
65
         */
64
66
        explicit row(
65
67
                sqlite3_stmt *handle,
66
 
                unsigned long long index );
 
68
                unsigned long long row_number );
67
69
 
68
70
        /**
69
71
         * Constructor that produces an invalid row.
70
 
         * @param the handle of the statement (query) that created this row
71
72
         */
72
73
        explicit row();
73
74
 
79
80
         * Determine if this row is valid or not. If it is not valid, there are no
80
81
         * more rows in the results of the query.
81
82
         */
82
 
        inline operator bool() const
83
 
        {
84
 
                return _index != std::numeric_limits< unsigned long long >::max();
85
 
        }
 
83
        operator bool() const;
86
84
 
87
85
        /**
88
86
         * get the index in to the results that is this row
89
87
         * @return index
90
88
         */
91
 
        inline unsigned long long index()
 
89
        inline unsigned long long row_number()
92
90
        {
93
 
                return _index;
 
91
                return _row_number;
94
92
        }
95
93
 
96
94
        /**
166
164
         * Stream operator for use with set_index().
167
165
         */
168
166
        row &operator >>(
169
 
                _set_index_t t );
 
167
                detail::set_index_t t );
 
168
 
 
169
        /**
 
170
         * Test to see if two rows are the same
 
171
         * @param other the row to compare this one to
 
172
         * @return true if they are
 
173
         */
 
174
        bool operator ==(
 
175
                const row &other )
 
176
                const;
170
177
 
171
178
//______________________________________________________________________________
172
179
//                                                                implementation
173
180
protected:
174
181
 
175
 
        /** the query's handle */
 
182
        /** the query's handle, or NULL */
176
183
        sqlite3_stmt *_handle;
177
184
 
178
185
private:
180
187
        /** index used when auto-column-getting */
181
188
        unsigned int _column_index;
182
189
 
183
 
        /** the index of thi row */
184
 
        unsigned long long _index;
 
190
        /** the index of this row */
 
191
        unsigned long long _row_number;
185
192
 
186
193
};
187
194
 
188
195
 
189
196
// template specialisations
190
197
template< >
191
 
row &row::operator >> < _null_t >(
192
 
        _null_t & );
 
198
row &row::operator >> < detail::null_t >(
 
199
        detail::null_t & );
193
200
 
194
201
 
195
202
} // namespace sqlite