asge::config::toml::TOMLTableView
Fluent handle to one table node while building a TOML document.
#include <TOML_TableView.hpp>Inherited by asge::config::toml::TOMLBuilder.
Inheritance
classDiagram
class N2["asge::config::toml::TOMLBuilder"]
class N1["asge::config::toml::TOMLTableView"]
N1 <|-- N2
click N2 href "classasge_1_1config_1_1toml_1_1TOMLBuilder.html"
click N1 href "classasge_1_1config_1_1toml_1_1TOMLTableView.html"
Set()/SetArray() auto-vivify the key on this table; Table() descends into (creating if needed) a subtable, scoping further calls to it. Returned by TOMLBuilder::Table() — not constructed directly by callers.
Protected Attributes
Public Member Functions
explicit TOMLTableView(table_pointer inTable) noexcepttemplate<typename T> TOMLTableView & Set(std::string const &inKey, T inValue)Sets a scalar key on this table, creating it if it doesn't exist yet.
A failure (e.g. re-setting an existing key with a different type) is logged rather than breaking the chain.
TOMLTableView & Set(std::string const &inKey, float inValue)Sets a float-valued key.
TOML has no separate 32-bit float type — it's stored as the same double a TOML "float" always is — this overload just spares callers the cast at every call site (e.g. every component field that happens to be float).
template<typename T> TOMLTableView & SetArray(std::string const &inKey, std::vector< T > const &inValues)Sets an array-valued key on this table, creating it if it doesn't exist yet.
Elements may themselves be std::vector<U> for a nested TOML array.
TOMLTableView & SetArray(std::string const &inKey, std::vector< float > const &inValues)Sets a float-array-valued key.
Stored as an array of TOML doubles — the array-valued counterpart to the float overload of Set(); see its doc comment for why.
TOMLTableView Table(std::string const &inPath)Descends into a dotted subtable path relative to this table, creating any missing tables along the way, and returns a view scoped to it.
Unlike GetTable()/HasTable(), inPath does not understand [index] segments into an array-of-tables — "entity[0]" is treated as one literal (and unmatched) table name, so this silently creates a garbage sibling instead of finding an existing element. Use GetTable() to read one back.
TOMLTableView ArrayTable(std::string const &inKey)Appends a new element to an array-of-tables ([[inKey]]) under this table and returns a view scoped to it.
Unlike Table(), each call creates a fresh sibling rather than reusing one of the same name — the first call tags it Root, later calls Array, mirroring how the parser distinguishes successive [[inKey]] blocks.
template<typename T> T Get(std::string const &inKey, T inDefault=T{}) constReads a scalar value at inKey on this table, returning inDefault if the key is missing or holds a different type — the read-side counterpart to Set().
std::int64_t Get(std::string const &inKey, std::int64_t inDefault) constReads an int64-valued key, falling back to an int-typed value before giving up to inDefault: the parser stores any integer that fits in 32 bits as int (e.g.
a packed color with alpha 0), so a strict int64 lookup would silently return inDefault.
float Get(std::string const &inKey, float inDefault=0.0f) constReads a float-valued key — the read-side counterpart to the float overload of Set().
Stored/looked up as double underneath; see that overload's doc comment for why. Falls back to an int-typed value (coerced to double) before giving up to inDefault: a bare TOML integer literal (y = 528) and a float literal (y = 528.0) are numerically interchangeable wherever a float is being read, and requiring the latter is a silent-zero footgun for hand-authored files.
template<typename T> std::vector< T > GetArray(std::string const &inKey, std::vector< T > inDefault={}) constReads an array-valued key at inKey on this table, returning inDefault if the array's elements hold a different type — the read-side counterpart to SetArray().
A missing key yields an empty vector rather than inDefault, mirroring the underlying Table::GetTypedArray().
std::vector< float > GetArray(std::string const &inKey, std::vector< float > inDefault={}) constReads a float-array-valued key — the read-side counterpart to the float overload of SetArray().
Stored/looked up as an array of doubles; see that overload's doc comment for why.
Result< TOMLTableView > GetTable(std::string const &inPath) constRead-only descent into an existing subtable at inPath, honoring [index] segments into an array-of-tables (e.g.
"entity[1]") the same way Table::GetTable does. Unlike Table(), never creates anything — this is what a loader walking entity[0], entity[1], ... array elements back out of a parsed document needs; HasTable() is built on top of it.
Result< TOMLTableView > GetTable(std::string const &inPath, int inIndex) constRead-only descent into element inIndex of an array-of-tables named inPath relative to this table — equivalent to GetTable(inPath + "[" + inIndex + "]"), for callers walking a known count of elements (e.g.
Serializer<Animation>::FromToml over "Frame[0]", "Frame[1]", ...) without building that string themselves.