4
4
* Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
6
* This file is part of sqlitepp (hereafter referred to as "this program").
7
* See http://www.waxworlds.org/edam/software/sqlitepp for more information.
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
9
* This program is free software: you can redistribute it and/or modify
10
10
* it under the terms of the GNU Lesser General Public License as published
20
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
27
#include <sqlitepp/statement.hpp>
23
#ifndef SQLITE3CC_QUERY_H_
24
#define SQLITE3CC_QUERY_H_
27
#include <boost/iterator/iterator_facade.hpp>
28
#include <sqlite3cc/basic_statement.h>
29
#include <sqlite3cc/row.h>
38
public basic_statement
40
//______________________________________________________________________________
45
* Constructor that provides a database upon which to act and the SQL
47
* @param database a reference to a database
48
* @param sql an SQL statement in UTF-8
52
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
62
//______________________________________________________________________________
67
* Prepare an SQL statement.
68
* @param sql an SQL statement in UTF-8
69
* @returns an sqlite error code
70
* @see sqlite3_prepare_v2()
73
const std::string &sql );
76
* Peform a step() and return row object that can be used to retrieve the
78
* @return a row object
83
* Get the number of columns in the results
84
* @see sqlite3_column_count()
86
unsigned int column_count();
89
* Get the name of a column in the results
90
* @param index column index
91
* @see sqlite3_column_name()
93
const std::string column_name(
97
* Query iterator which can be used to obtain rows
101
public boost::iterator_facade< iterator, row,
102
boost::single_pass_traversal_tag, row >
106
explicit iterator( query &query, bool valid );
109
friend class boost::iterator_core_access;
111
row dereference() const;
113
bool equal( iterator const &other ) const;
115
/** is this iterator still pointing to a valid row? */
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
131
* Return an iterator to after the last row (i.e., an invalid row).
135
//______________________________________________________________________________
139
/** next row index */
140
unsigned long long _next_row;
45
#endif /* QUERY_HPP_ */
145
} // namespace sqlite
148
#endif /* SQLITE3CC_QUERY_H_ */