wavelength 1.0.0
Loading...
Searching...
No Matches
Tools::Ark::DataNode Struct Reference

One element of a DataArray, as a compiled DataArray file stores it. More...

#include <datanode.h>

Public Types

enum class  Type : std::uint8_t { Int = 0 , Symbol = 1 , Float = 2 , Array = 3 }
 Kind of element, numbered as the two-bit tags of the compiled file. More...

Public Member Functions

bool isKeyed (std::string_view key) const
 Report whether the element is an array whose first element is a symbol.
DataNode * findArray (std::string_view key)
 Find a child array by the symbol that opens it, the way DataArray::FindArray does.
const DataNode * findArray (std::string_view key) const
 Find a child array by the symbol that opens it, the way DataArray::FindArray does.
int indexOf (std::string_view key) const
 Find the index of a child array by the symbol that opens it.
template<typename Map>
void remapFiles (const Map &map)
 Change the file index of the element and of every array below it.
bool operator== (const DataNode &other) const =default
 Compare two elements, their kinds, values, and arrays.

Static Public Member Functions

static DataNode makeInt (std::int32_t value)
 Make an integer element.
static DataNode makeSymbol (std::string symbol)
 Make a symbol element.
static DataNode makeFloat (float value)
 Make a float element.
static DataNode makeArray (std::uint16_t line, std::int32_t file)
 Make an empty array element.

Public Attributes

Type type = Type::Int
std::uint32_t value = 0
std::string symbol
std::vector< DataNode > children
std::uint16_t line = 0
std::uint16_t sorted = 0
std::int32_t file = 0

Detailed Description

One element of a DataArray, as a compiled DataArray file stores it.

A symbol and a quoted string share one kind, because the compiled file does not tell them apart.

Member Enumeration Documentation

◆ Type

enum class Tools::Ark::DataNode::Type : std::uint8_t
strong

Kind of element, numbered as the two-bit tags of the compiled file.

Enumerator
Int 

A 32-bit integer.

Symbol 

A symbol or a string.

Float 

A 32-bit float.

Array 

A nested array.

Member Function Documentation

◆ makeInt()

DataNode Tools::Ark::DataNode::makeInt ( std::int32_t value)
static

Make an integer element.

Parameters
valueThe integer.
Returns
The element.

◆ makeSymbol()

DataNode Tools::Ark::DataNode::makeSymbol ( std::string symbol)
static

Make a symbol element.

Parameters
symbolThe symbol or string.
Returns
The element.

◆ makeFloat()

DataNode Tools::Ark::DataNode::makeFloat ( float value)
static

Make a float element.

Parameters
valueThe float.
Returns
The element.

◆ makeArray()

DataNode Tools::Ark::DataNode::makeArray ( std::uint16_t line,
std::int32_t file )
static

Make an empty array element.

Parameters
lineSource line.
fileIndex of the source file in the file table.
Returns
The element.

◆ isKeyed()

bool Tools::Ark::DataNode::isKeyed ( std::string_view key) const
nodiscard

Report whether the element is an array whose first element is a symbol.

Parameters
keyThe symbol.
Returns
Whether the first element is the symbol.

◆ findArray() [1/2]

DataNode * Tools::Ark::DataNode::findArray ( std::string_view key)

Find a child array by the symbol that opens it, the way DataArray::FindArray does.

Parameters
keyThe symbol.
Returns
The first matching child, or null when there is none.

◆ findArray() [2/2]

const DataNode * Tools::Ark::DataNode::findArray ( std::string_view key) const
nodiscard

Find a child array by the symbol that opens it, the way DataArray::FindArray does.

Parameters
keyThe symbol.
Returns
The first matching child, or null when there is none.

◆ indexOf()

int Tools::Ark::DataNode::indexOf ( std::string_view key) const
nodiscard

Find the index of a child array by the symbol that opens it.

Parameters
keyThe symbol.
Returns
The index, or -1 when there is no match.

◆ remapFiles()

template<typename Map>
void Tools::Ark::DataNode::remapFiles ( const Map & map)
inline

Change the file index of the element and of every array below it.

Parameters
mapCallable taking an old index and returning the new one.

◆ operator==()

bool Tools::Ark::DataNode::operator== ( const DataNode & other) const
default

Compare two elements, their kinds, values, and arrays.

Parameters
otherThe other element.
Returns
Whether they are equal.

Member Data Documentation

◆ type

Type Tools::Ark::DataNode::type = Type::Int

Kind of element.

◆ value

std::uint32_t Tools::Ark::DataNode::value = 0

The integer, or the bits of the float.

◆ symbol

std::string Tools::Ark::DataNode::symbol

The symbol or string.

◆ children

std::vector<DataNode> Tools::Ark::DataNode::children

The elements of an array.

◆ line

std::uint16_t Tools::Ark::DataNode::line = 0

Source line of an array.

◆ sorted

std::uint16_t Tools::Ark::DataNode::sorted = 0

Whether the game sorted an array before it was saved.

◆ file

std::int32_t Tools::Ark::DataNode::file = 0

Index of an array's source file in the file table.


The documentation for this struct was generated from the following file: