/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: 2012-01-23 14:27:08 UTC
  • Revision ID: edam@waxworlds.org-20120123142708-w12277ptwtlspa6f
updated email and web addresses

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * query.h
3
3
 *
4
 
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
 
4
 * Copyright (C) 2009 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of sqlite3cc (hereafter referred to as "this program").
7
 
 * See http://www.waxworlds.org/edam/software/sqlite3cc for more information.
8
 
 *
9
 
 * This program is free software: you can redistribute it and/or modify
10
 
 * it under the terms of the GNU Lesser General Public License as published
11
 
 * by the Free Software Foundation, either version 3 of the License, or
12
 
 * (at your option) any later version.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU Lesser General Public License for more details.
 
7
 * See http://ed.am/dev/sqlite3cc for more information.
 
8
 *
 
9
 * This program is free software: you can redistribute it and/or modify it under
 
10
 * the terms of the GNU Lesser General Public License as published by the Free
 
11
 * Software Foundation, either version 3 of the License, or (at your option) any
 
12
 * later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
16
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
 
17
 * details.
18
18
 *
19
19
 * You should have received a copy of the GNU Lesser General Public License
20
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
44
44
        /**
45
45
         * Constructor that provides a connection upon which to act and the SQL
46
46
         * query to execute.
 
47
         *
47
48
         * @param connection a reference to a connection
48
49
         * @param sql an SQL statement in UTF-8
49
50
         */
53
54
 
54
55
        /**
55
56
         * Constructor that provides a connection upon which to act.
 
57
         *
56
58
         * @param connection a reference to a connection
57
59
         */
58
60
        explicit query(
64
66
 
65
67
        /**
66
68
         * Prepare an SQL statement.
 
69
         *
67
70
         * @param sql an SQL statement in UTF-8
68
71
         * @returns an sqlite error code
69
72
         * @see sqlite3_prepare_v2()
72
75
                const std::string &sql );
73
76
 
74
77
        /**
75
 
         * Reset the statement, ready to re-execute it. This does not clear any of
 
78
         * Reset the statement, ready to re-execute it.  This does not clear any of
76
79
         * the values bound to the statement.
 
80
         *
77
81
         * @returns an sqlite error code
78
82
         * @see sqlite3_reset()
79
83
         */
82
86
        /**
83
87
         * Perform a step() and return row object that can be used to retrieve the
84
88
         * results.
 
89
         *
85
90
         * @return a row object
86
91
         */
87
92
        row step();
88
93
 
89
94
        /**
90
 
         * Get the number of columns in the results
 
95
         * Get the number of columns in the results.
 
96
         *
91
97
         * @see sqlite3_column_count()
92
98
         */
93
99
        unsigned int column_count();
94
100
 
95
101
        /**
96
 
         * Get the name of a column in the results
 
102
         * Get the name of a column in the results.
 
103
         *
97
104
         * @param index column index
98
105
         * @see sqlite3_column_name()
99
106
         */
101
108
                unsigned int index );
102
109
 
103
110
        /**
104
 
         * Gets the number of results. Be aware that this merely step()s over the
105
 
         * results and counts them, which is something you could do yourself. This
 
111
         * Gets the number of results.  Be aware that this merely step()s over the
 
112
         * results and counts them, which is something you could do yourself.  This
106
113
         * method is intended to be used for convenience, where you only need know
107
 
         * the number of results and not what they are. You could also execute some
 
114
         * the number of results and not what they are.  You could also execute some
108
115
         * SQL like this: "SELECT COUNT(*) ...", but this only causes SQLite to
109
 
         * internally do the same counting as this method does. Also note that this
 
116
         * internally do the same counting as this method does.  Also note that this
110
117
         * method reset()s the query.
111
118
         */
112
119
        unsigned long long num_results();
113
120
 
114
121
        /**
115
 
         * Query iterator which can be used to obtain rows
 
122
         * Query iterator which can be used to obtain rows.
116
123
         */
117
124
        class iterator
118
125
                :
137
144
        };
138
145
 
139
146
        /**
140
 
         * Get an iterator to the initial row. Note that creating an iterator
 
147
         * Get an iterator to the initial row.  Note that creating an iterator
141
148
         * causes step() to be called, so it should only be called to begin
142
149
         * iterating over the rows and not for comparison.
 
150
         *
143
151
         * @return a query iterator
144
152
         */
145
153
        iterator begin();
146
154
 
147
155
        /**
148
156
         * Get an iterator to after the last row (i.e., an invalid row).
 
157
         *
149
158
         * @return an invalid query iterator
150
159
         */
151
160
        iterator end();