/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-27 15:12:55 UTC
  • Revision ID: edam@waxworlds.org-20100727151255-goaqgdz4kj13q7gz
- update TODO
- added some missing includes for <string>
- changed usage of database::exec() to not require return code!
- prevented transaction_guard destructor from throwing an exception

Show diffs side-by-side

added added

removed removed

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