diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-05-08 13:38:36 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-05-08 17:47:29 +1000 |
| commit | 16e6180ba7946119538d03463ea7d37fccc4dcb3 (patch) | |
| tree | 968483bfa477b43a72b8b6dfefaac3e771163e9e /src/database/include/records.hpp | |
| parent | fe19478e0f286191c3bf1b9946b89ed26d5c4bae (diff) | |
| download | tangara-fw-16e6180ba7946119538d03463ea7d37fccc4dcb3.tar.gz | |
Database init is now stable!
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 |
