summaryrefslogtreecommitdiff
path: root/src/database/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-11-21 13:49:47 +1100
committerjacqueline <me@jacqueline.id.au>2023-11-21 13:49:47 +1100
commitd70ec9bf447f7a46e347c3bc5ad58fd88aff46a2 (patch)
treeab75c1663934d7408fad36d134a0cfd4f4cb089b /src/database/include
parentf34b6405884c4073158c3f36158c6351fa135a0f (diff)
downloadtangara-fw-d70ec9bf447f7a46e347c3bc5ad58fd88aff46a2.tar.gz
Add lua functions to get database content
Diffstat (limited to 'src/database/include')
-rw-r--r--src/database/include/database.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/database/include/database.hpp b/src/database/include/database.hpp
index 544e4a62..972871db 100644
--- a/src/database/include/database.hpp
+++ b/src/database/include/database.hpp
@@ -183,4 +183,21 @@ auto Database::ParseRecord<std::pmr::string>(const leveldb::Slice& key,
const leveldb::Slice& val)
-> std::shared_ptr<std::pmr::string>;
+/*
+ * Utility for accessing a large set of database records, one record at a time.
+ */
+class Iterator {
+ public:
+ Iterator(std::weak_ptr<Database>, const IndexInfo&);
+ Iterator(std::weak_ptr<Database>, const Continuation&);
+
+ auto Prev() -> std::optional<IndexRecord>;
+ auto Next() -> std::optional<IndexRecord>;
+
+ private:
+ std::weak_ptr<Database> db_;
+ std::optional<Continuation> prev_pos_;
+ std::optional<Continuation> current_pos_;
+};
+
} // namespace database