blob: 22d2ca5bf51f350d959f63515737898ef103f4b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
|