summaryrefslogtreecommitdiff
path: root/doc/reference/resultset.adoc
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-14 00:16:10 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-14 00:16:10 -0400
commitefcea3a80da7c4479d5fe168435ecc9fd06bdc72 (patch)
tree5cb0177e17b1b00a177f2e830e809f606334571b /doc/reference/resultset.adoc
downloadsqlite-kv-bench-efcea3a80da7c4479d5fe168435ecc9fd06bdc72.tar.gz
Squashed 'subprojects/boost-sqlite/' content from commit 3378e35
git-subtree-dir: subprojects/boost-sqlite git-subtree-split: 3378e353705271e569cf4ba15c467b840a39798c
Diffstat (limited to 'doc/reference/resultset.adoc')
-rw-r--r--doc/reference/resultset.adoc72
1 files changed, 72 insertions, 0 deletions
diff --git a/doc/reference/resultset.adoc b/doc/reference/resultset.adoc
new file mode 100644
index 0000000..fb793a5
--- /dev/null
+++ b/doc/reference/resultset.adoc
@@ -0,0 +1,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
+----
+
+