-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistryData.hpp
More file actions
53 lines (37 loc) · 1.34 KB
/
RegistryData.hpp
File metadata and controls
53 lines (37 loc) · 1.34 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef MC_CPP_SERVER_DATA_REGISTRY_HPP
#define MC_CPP_SERVER_DATA_REGISTRY_HPP
#include "lib/nbt.hpp"
#include <memory>
#include <optional>
#include <string>
#include <vector>
struct RegistryDataEntry {
std::string entry_id;
bool has_data;
std::optional<std::shared_ptr<nbt::Tag>> data;
RegistryDataEntry() : has_data(false) {}
RegistryDataEntry(const std::string& id, bool hasData = false, std::optional<std::shared_ptr<nbt::Tag>> nbtData = std::nullopt)
: entry_id(id), has_data(hasData), data(nbtData) {}
};
class RegistryData {
private:
std::string _registry_id;
std::vector<RegistryDataEntry> _entries;
public:
RegistryData();
RegistryData(const std::string& registryId);
~RegistryData();
RegistryData(const RegistryData& other);
RegistryData& operator=(const RegistryData& other);
RegistryData(RegistryData&& other) noexcept;
RegistryData& operator=(RegistryData&& other) noexcept;
const std::string& getRegistryId() const;
const std::vector<RegistryDataEntry>& getEntries() const;
size_t getEntryCount() const;
void addEntry(const std::string& entryId, bool hasData = false, std::optional<std::shared_ptr<nbt::Tag>> data = std::nullopt);
std::vector<uint8_t> serialize() const;
static constexpr uint8_t PACKET_ID = 0x07;
bool isEmpty() const;
void reserve(size_t capacity);
};
#endif