Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
data.hpp
Go to the documentation of this file.
1
7
8
#pragma once
9
10
#include "
core_types.hpp
"
11
#include "
data_value.hpp
"
12
#include "
schema.hpp
"
13
14
namespace
assets {
15
16
class
TOAST_API Data :
public
Asset,
public
ISaveable
{
17
public
:
19
struct
KeepAllKeysTag
{ };
20
21
static
constexpr
KeepAllKeysTag
keep_all_keys {};
22
23
explicit
Data
(
const
toml::table& table,
Handle<Schema>
schema = {});
24
27
Data(
const
toml::table& table, Handle<Schema> schema, KeepAllKeysTag);
28
29
[[nodiscard]]
30
auto
type() const -> std::string_view
override
{
31
return
"data"
;
32
}
33
34
[[nodiscard]]
35
auto
operator[](std::string_view k) -> DataValue& {
36
return
m_root[k];
37
}
38
39
[[nodiscard]]
40
auto
operator[](std::string_view k)
const
->
const
DataValue& {
41
return
m_root[k];
42
}
43
44
[[nodiscard]]
45
auto
contains(std::string_view k)
const
->
bool
{
46
return
m_root.contains(k);
47
}
48
49
[[nodiscard]]
50
auto
root
() const -> const DataValue& {
51
return
m_root;
52
}
53
54
[[nodiscard]]
55
auto
schema() const -> const Handle<Schema>& {
56
return
m_schema;
57
}
58
59
[[nodiscard]]
60
auto
serialize(SaveMode mode)
const
-> std::vector<uint8_t>
override
;
61
63
virtual
void
reload(
const
toml::table& table);
64
65
protected
:
66
virtual
void
onReloaded() { }
67
68
DataValue
m_root
;
69
Handle<Schema>
m_schema
;
70
bool
m_keep_all_keys =
false
;
71
72
private
:
73
static
auto
buildRoot(
const
toml::table& table,
const
Schema
* schema) ->
DataValue
;
74
};
75
76
}
assets::DataValue
Typed value for TOML files.
Definition
data_value.hpp:50
assets::Data
Definition
data.hpp:16
assets::Data::m_root
DataValue m_root
Object DataValue holding all fields.
Definition
data.hpp:68
assets::Data::m_schema
Handle< Schema > m_schema
optional
Definition
data.hpp:69
assets::Handle
Type-safe smart pointer for assets.
Definition
core_types.hpp:149
assets::ISaveable
Inherit from this class to allow an asset to be saved.
Definition
core_types.hpp:33
assets::Schema
Asset wrapping a parsed .schema.json.
Definition
schema.hpp:60
core_types.hpp
Base types for the asset system.
data_value.hpp
Recursive typed value for schema-driven TOML data assets.
toast::NodeState::root
@ root
The node is currently in use within world::root_node.
Definition
node.hpp:55
schema.hpp
Used as "reflection data" for Data types.
assets::Data::KeepAllKeysTag
Tag type for the keep-all-keys constructor.
Definition
data.hpp:19
engine
src
toast
assets
data.hpp
Generated by
1.17.0