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

Lines of Context:
24
24
#define SQLITE3CC_QUERY_H_
25
25
 
26
26
 
 
27
#include <boost/iterator/iterator_facade.hpp>
27
28
#include <sqlite3cc/basic_statement.h>
 
29
#include <sqlite3cc/row.h>
28
30
 
29
31
 
30
32
namespace sqlite
31
33
{
32
34
 
33
35
 
34
 
class row;
35
 
 
36
 
 
37
36
class query
38
37
        :
39
38
        public basic_statement
81
80
        row step();
82
81
 
83
82
        /**
84
 
         * Get the number of columns in the result of
 
83
         * Get the number of columns in the results
 
84
         * @see sqlite3_column_count()
85
85
         */
86
86
        unsigned int column_count();
87
87
 
 
88
        /**
 
89
         * Get the name of a column in the results
 
90
         * @param index column index
 
91
         * @see sqlite3_column_name()
 
92
         */
 
93
        const std::string column_name(
 
94
                unsigned int index );
 
95
 
 
96
        /**
 
97
         * Query iterator which can be used to obtain rows
 
98
         */
 
99
        class iterator
 
100
                :
 
101
                public boost::iterator_facade< iterator, row,
 
102
                        boost::single_pass_traversal_tag, row >
 
103
        {
 
104
        public:
 
105
                iterator();
 
106
                explicit iterator( query &query, bool valid );
 
107
 
 
108
        private:
 
109
                friend class boost::iterator_core_access;
 
110
 
 
111
                row dereference() const;
 
112
                void increment();
 
113
                bool equal( iterator const &other ) const;
 
114
 
 
115
                /** is this iterator still pointing to a valid row? */
 
116
                bool _valid;
 
117
 
 
118
                /** the query */
 
119
                query &_query;
 
120
        };
 
121
 
 
122
        /**
 
123
         * Return an iterator to the initial row. Note that creating an iterator
 
124
         * causes step() to be called, so it should only be called to begin
 
125
         * iterating over the rows and not for comparison.
 
126
         * @return a query iterator
 
127
         */
 
128
        iterator begin();
 
129
 
 
130
        /**
 
131
         * Return an iterator to after the last row (i.e., an invalid row).
 
132
         */
 
133
        iterator end();
 
134
 
 
135
//______________________________________________________________________________
 
136
//                                                                implementation
 
137
private:
 
138
 
 
139
        /** next row index */
 
140
        unsigned long long _next_row;
 
141
 
88
142
};
89
143
 
90
144