metadata.hpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef CRUCIBLE_BOBA_METADATA_HPP #define CRUCIBLE_BOBA_METADATA_HPP #include "crucible/boba/errors.hpp" #include <cstddef> #include <span> #include <vector> namespace crucible::boba::metadata { struct Header final { bool is_internal { false }; std::uint32_t signature { 0 }; std::uint32_t data_size { 0 }; std::uint32_t user_data[2] = { 0, 0 }; std::size_t offset { 0 }; }; class Schema final { public: struct Entry final { std::uint32_t signature { 0 }; std::uint32_t metadata { 0 }; }; explicit Schema(Header const &header); auto get_underlying_header() const -> Header; auto get_full_header_count() const -> std::size_t; auto get_user_header_count() const -> std::size_t; auto get_header_size() const -> std::size_t; auto get_entry_count() const -> std::size_t; auto get_entry_size() const -> std::size_t; private: Header my_header {}; std::vector<Entry> my_entries {}; }; class Container final { public: using IteratorType = std::vector<Header>::const_iterator; explicit Container(Schema const &schema); Container(Schema const &schema, std::vector<Header> const &headers); auto get_schema() const -> Schema; auto begin() const -> IteratorType; auto end() const -> IteratorType; private: Schema my_schema; std::vector<Header> my_headers {}; }; auto from_bytes(std::span<std::byte const> bytes) -> errors::BobaResult<Container>; } #endif // CRUCIBLE_BOBA_METADATA_HPP