wavelength
1.0.0
Loading...
Searching...
No Matches
datanode.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <string>
5
#include <string_view>
6
#include <vector>
7
9
namespace
Tools::Ark
{
10
16
struct
DataNode
{
18
enum class
Type
: std::uint8_t {
19
Int
= 0,
20
Symbol
= 1,
21
Float
= 2,
22
Array
= 3,
23
};
24
25
Type
type
=
Type::Int
;
26
std::uint32_t
value
= 0;
27
std::string
symbol
;
28
std::vector<DataNode>
children
;
29
std::uint16_t
line
= 0;
30
std::uint16_t
sorted
= 0;
31
std::int32_t
file
= 0;
32
39
static
DataNode
makeInt
(std::int32_t
value
);
40
47
static
DataNode
makeSymbol
(std::string
symbol
);
48
55
static
DataNode
makeFloat
(
float
value
);
56
64
static
DataNode
makeArray
(std::uint16_t
line
, std::int32_t
file
);
65
72
[[nodiscard]]
bool
isKeyed
(std::string_view key)
const
;
73
80
DataNode
*
findArray
(std::string_view key);
81
83
[[nodiscard]]
const
DataNode
*
findArray
(std::string_view key)
const
;
84
91
[[nodiscard]]
int
indexOf
(std::string_view key)
const
;
92
98
template
<
typename
Map>
99
void
remapFiles
(
const
Map &map) {
100
if
(
type
!=
Type::Array
) {
101
return
;
102
}
103
file
= map(
file
);
104
for
(
auto
&child :
children
) {
105
child.remapFiles(map);
106
}
107
}
108
115
bool
operator==
(
const
DataNode
&other)
const
=
default
;
116
};
117
118
}
// namespace Tools::Ark
Tools::Ark
Readers and writers of Harmonix archives and compiled DataArray files.
Definition
arkreader.h:14
Tools::Ark::DataNode
One element of a DataArray, as a compiled DataArray file stores it.
Definition
datanode.h:16
Tools::Ark::DataNode::findArray
const DataNode * findArray(std::string_view key) const
Find a child array by the symbol that opens it, the way DataArray::FindArray does.
Tools::Ark::DataNode::line
std::uint16_t line
Definition
datanode.h:29
Tools::Ark::DataNode::value
std::uint32_t value
Definition
datanode.h:26
Tools::Ark::DataNode::children
std::vector< DataNode > children
Definition
datanode.h:28
Tools::Ark::DataNode::makeSymbol
static DataNode makeSymbol(std::string symbol)
Make a symbol element.
Tools::Ark::DataNode::type
Type type
Definition
datanode.h:25
Tools::Ark::DataNode::isKeyed
bool isKeyed(std::string_view key) const
Report whether the element is an array whose first element is a symbol.
Tools::Ark::DataNode::symbol
std::string symbol
Definition
datanode.h:27
Tools::Ark::DataNode::file
std::int32_t file
Definition
datanode.h:31
Tools::Ark::DataNode::Type
Type
Kind of element, numbered as the two-bit tags of the compiled file.
Definition
datanode.h:18
Tools::Ark::DataNode::Type::Symbol
@ Symbol
Definition
datanode.h:20
Tools::Ark::DataNode::Type::Int
@ Int
Definition
datanode.h:19
Tools::Ark::DataNode::Type::Float
@ Float
Definition
datanode.h:21
Tools::Ark::DataNode::Type::Array
@ Array
Definition
datanode.h:22
Tools::Ark::DataNode::sorted
std::uint16_t sorted
Definition
datanode.h:30
Tools::Ark::DataNode::indexOf
int indexOf(std::string_view key) const
Find the index of a child array by the symbol that opens it.
Tools::Ark::DataNode::makeArray
static DataNode makeArray(std::uint16_t line, std::int32_t file)
Make an empty array element.
Tools::Ark::DataNode::makeFloat
static DataNode makeFloat(float value)
Make a float element.
Tools::Ark::DataNode::remapFiles
void remapFiles(const Map &map)
Change the file index of the element and of every array below it.
Definition
datanode.h:99
Tools::Ark::DataNode::makeInt
static DataNode makeInt(std::int32_t value)
Make an integer element.
Tools::Ark::DataNode::operator==
bool operator==(const DataNode &other) const =default
Compare two elements, their kinds, values, and arrays.
Tools::Ark::DataNode::findArray
DataNode * findArray(std::string_view key)
Find a child array by the symbol that opens it, the way DataArray::FindArray does.
tools
ark
datanode.h
Generated by
1.15.0