diff options
Diffstat (limited to 'src/database/include/records.hpp')
| -rw-r--r-- | src/database/include/records.hpp | 32 |
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 |
