From 16e6180ba7946119538d03463ea7d37fccc4dcb3 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 8 May 2023 13:38:36 +1000 Subject: Database init is now stable! --- src/database/include/records.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/database/include/records.hpp (limited to 'src/database/include/records.hpp') 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 +#include +#include + +#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; + +auto CreateHashKey(const uint64_t& hash) -> OwningSlice; +auto ParseHashValue(const leveldb::Slice&) -> std::optional; +auto CreateHashValue(SongId id) -> OwningSlice; + +auto SongIdToBytes(SongId id) -> OwningSlice; +auto BytesToSongId(const std::string& bytes) -> SongId; + +} // namespace database -- cgit v1.2.3