4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
4
* Copyright (C) 2009 Tim Marston <tim@ed.am>
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.
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.
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.
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
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
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/>.
38
public basic_statement
38
public detail::basic_statement
40
40
//______________________________________________________________________________
45
* Constructor that provides a database upon which to act and the SQL
45
* Constructor that provides a connection upon which to act and the SQL
46
46
* query to execute.
47
* @param database a reference to a database
48
* @param connection a reference to a connection
48
49
* @param sql an SQL statement in UTF-8
52
connection &connection,
52
53
const std::string &sql );
55
* Constructor that provides a database upon which to act.
56
* @param database a reference to a database
57
* @param sql an SQL statement in UTF-8
56
* Constructor that provides a connection upon which to act.
58
* @param connection a reference to a connection
61
connection &connection );
62
63
//______________________________________________________________________________
63
64
// public interface
73
75
const std::string &sql );
76
* Peform a step() and return row object that can be used to retrieve the
78
* Reset the statement, ready to re-execute it. This does not clear any of
79
* the values bound to the statement.
81
* @returns an sqlite error code
82
* @see sqlite3_reset()
87
* Perform a step() and return row object that can be used to retrieve the
78
90
* @return a row object
83
* Get the number of columns in the results
95
* Get the number of columns in the results.
84
97
* @see sqlite3_column_count()
86
99
unsigned int column_count();
89
* Get the name of a column in the results
102
* Get the name of a column in the results.
90
104
* @param index column index
91
105
* @see sqlite3_column_name()
94
108
unsigned int index );
97
* Query iterator which can be used to obtain rows
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
113
* method is intended to be used for convenience, where you only need know
114
* the number of results and not what they are. You could also execute some
115
* SQL like this: "SELECT COUNT(*) ...", but this only causes SQLite to
116
* internally do the same counting as this method does. Also note that this
117
* method reset()s the query.
119
unsigned long long num_results();
122
* Query iterator which can be used to obtain rows.
102
127
boost::single_pass_traversal_tag, row >
106
explicit iterator( query &query, bool valid );
130
explicit iterator( query &query, bool step );
109
133
friend class boost::iterator_core_access;
112
136
void increment();
113
137
bool equal( iterator const &other ) const;
115
/** is this iterator still pointing to a valid row? */
139
/** the current row */
123
* Return an iterator to the initial row. Note that creating an iterator
147
* Get an iterator to the initial row. Note that creating an iterator
124
148
* causes step() to be called, so it should only be called to begin
125
149
* iterating over the rows and not for comparison.
126
151
* @return a query iterator
128
153
iterator begin();
131
* Return an iterator to after the last row (i.e., an invalid row).
156
* Get an iterator to after the last row (i.e., an invalid row).
158
* @return an invalid query iterator