/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-02-02 16:13:16 UTC
  • Revision ID: edam@waxworlds.org-20100202161316-tceybmdeotltldow
- print "ok" when test program is successful!
- renamed 'Makefile's 'subdir.mk' so that the edam.mk build system will live happily along side an autotools build system

Show diffs side-by-side

added added

removed removed

24
24
#define SQLITE3CC_QUERY_H_
25
25
 
26
26
 
27
 
#include <boost/iterator/iterator_facade.hpp>
28
27
#include <sqlite3cc/basic_statement.h>
29
 
#include <sqlite3cc/row.h>
30
28
 
31
29
 
32
30
namespace sqlite
33
31
{
34
32
 
35
33
 
 
34
class row;
 
35
 
 
36
 
36
37
class query
37
38
        :
38
39
        public basic_statement
73
74
                const std::string &sql );
74
75
 
75
76
        /**
76
 
         * Perform a step() and return row object that can be used to retrieve the
 
77
         * Peform a step() and return row object that can be used to retrieve the
77
78
         * results.
78
79
         * @return a row object
79
80
         */
80
81
        row step();
81
82
 
82
83
        /**
83
 
         * Get the number of columns in the results
84
 
         * @see sqlite3_column_count()
 
84
         * Get the number of columns in the result of
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
 
 
142
88
};
143
89
 
144
90