summaryrefslogtreecommitdiff
path: root/src/database/include/records.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-05-08 13:38:36 +1000
committerjacqueline <me@jacqueline.id.au>2023-05-08 17:47:29 +1000
commit16e6180ba7946119538d03463ea7d37fccc4dcb3 (patch)
tree968483bfa477b43a72b8b6dfefaac3e771163e9e /src/database/include/records.hpp
parentfe19478e0f286191c3bf1b9946b89ed26d5c4bae (diff)
downloadtangara-fw-16e6180ba7946119538d03463ea7d37fccc4dcb3.tar.gz
Database init is now stable!
Diffstat (limited to 'src/database/include/records.hpp')
-rw-r--r--src/database/include/records.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/database/include/records.hpp b/src/database/include/records.hpp
new file mode 100644
index 00000000..22d2ca5b
--- /dev/null
+++ b/src/database/include/records.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <leveldb/db.h>
+#include <stdint.h>
+#include <string>
+
+#include "leveldb/slice.h"
+#include "song.hpp"
+
+namespace database {
+
+class OwningSlice {
+ public:
+ std::string data;
+ leveldb::Slice slice;
+
+ explicit OwningSlice(std::string d);
+};
+
+auto CreateDataPrefix() -> OwningSlice;
+auto CreateDataKey(const SongId& id) -> OwningSlice;
+auto CreateDataValue(const SongData& song) -> OwningSlice;
+auto ParseDataValue(const leveldb::Slice& slice) -> std::optional<SongData>;
+
+auto CreateHashKey(const uint64_t& hash) -> OwningSlice;
+auto ParseHashValue(const leveldb::Slice&) -> std::optional<SongId>;
+auto CreateHashValue(SongId id) -> OwningSlice;
+
+auto SongIdToBytes(SongId id) -> OwningSlice;
+auto BytesToSongId(const std::string& bytes) -> SongId;
+
+} // namespace database