blob: fb793a5fd5ff6c9e98b85c363d81c6b251e071ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
== `sqlite/resultset.hpp`
A resultset represents the results of a query.
[source,cpp]
----
// Representation of a result from a query.
struct resultset
{
// Returns the current row. The row is a pure view type.
row current() const &;
// Checks if the last row has been reached.
bool done() const;
// Read the next row. Returns false if there's nothing more to read.
// Calling this will change the data of any `row` previously obtained from `current.
bool read_next(system::error_code & ec, error_info & ei);
bool read_next();
// The number of colums in the resultset
std::size_t column_count() const;
// Returns the name of the column idx.
string_view column_name(std::size_t idx) const;
// Returns the name of the source table for column idx.
string_view table_name(std::size_t idx) const;
// Returns the origin name of the column for column idx.
string_view column_origin_name(std::size_t idx) const;
// The input iterator can be used to read every row in a for-loop
struct iterator
{
using value_type = value;
using difference_type = int;
using reference = value&;
using iterator_category = std::forward_iterator_tag;
iterator() {}
bool operator!=(iterator rhs) const;
row &operator*();
row *operator->();
iterator operator++();
iterator operator++(int);
};
// Return an input iterator to the currently unread row
iterator begin();
// Sentinel iterator.
iterator end();
};
----
.Example
[source,cpp]
----
extern sqlite::connection conn;
sqlite::resultset rs = conn.query("select * from users;");
do
{
handle_row(r.current());
}
while (rs.read_next()); // read it line by line
----
|