Toast Engine
Loading...
Searching...
No Matches
renderer::DataValue Class Reference

Typed value for TOML files. More...

#include <data_value.hpp>

Public Types

using ObjectMap = std::vector<std::pair<std::string, DataValue>>
using Array = std::vector<DataValue>

Public Member Functions

 DataValue (bool v)
 DataValue (int64_t v)
 DataValue (double v)
 DataValue (std::string v)
 DataValue (toast::UID v, DataType kind)
 DataValue (glm::vec2 v)
 DataValue (glm::vec3 v, DataType kind)
 DataValue (glm::vec4 v)
auto type () const noexcept -> DataType
auto isNull () const noexcept -> bool
auto isArray () const noexcept -> bool
auto isObject () const noexcept -> bool
template<class T>
auto as () const -> T
template<class T>
auto value () const -> std::optional< T >
 operator bool () const
 operator int64_t () const
 operator int () const
 operator float () const
 operator double () const
 operator std::string () const
 operator toast::UID () const
 operator glm::vec2 () const
 operator glm::vec3 () const
 operator glm::vec4 () const
auto operator[] (std::string_view key) -> DataValue &
auto operator[] (std::string_view key) const -> const DataValue &
auto operator[] (size_t index) -> DataValue &
auto operator[] (size_t index) const -> const DataValue &
auto contains (std::string_view key) const noexcept -> bool
auto size () const noexcept -> size_t
auto empty () const noexcept -> bool
void push (DataValue v)
 Array: appends an element.
void set (std::string key, DataValue v)
 Object: inserts or replaces by key.
void remove (std::string_view key)
 Object: removes a key (no-op if absent).
auto items () -> ObjectMap &
auto items () const -> const ObjectMap &
auto operator= (bool v) -> DataValue &
auto operator= (int64_t v) -> DataValue &
auto operator= (int v) -> DataValue &
auto operator= (double v) -> DataValue &
auto operator= (float v) -> DataValue &
auto operator= (std::string v) -> DataValue &
void appendTo (toml::table &tbl, const std::string &key) const
void appendTo (toml::array &arr) const
auto asTomlTable () const -> toml::table
auto toJson () const -> json_t

Static Public Member Functions

static auto makeArray () -> DataValue
static auto makeObject () -> DataValue
static auto fromToml (const toml::node &n, const SchemaField *field, const toml::table *root=nullptr) -> DataValue
 Parse a DataValue from a TOML node, using the schema field for type context.
static auto fromObject (const toml::table &t, const std::vector< SchemaField > &fields, const toml::table *root=nullptr) -> DataValue
 Build an Object DataValue from a TOML table, guided by a field list.
static auto fromJson (const json_t &j, DataType hint=DataType::null) -> DataValue

Detailed Description

Typed value for TOML files.

Member Function Documentation

◆ appendTo() [1/2]

void assets::DataValue::appendTo ( toml::array & arr) const

Appends this value to a TOML array

◆ appendTo() [2/2]

void assets::DataValue::appendTo ( toml::table & tbl,
const std::string & key ) const

Inserts this value into a TOML table under key

◆ asTomlTable()

auto assets::DataValue::asTomlTable ( ) const -> toml::table
nodiscard

Converts an Object DataValue to a toml::table

◆ fromJson()

auto assets::DataValue::fromJson ( const json_t & j,
DataType hint = DataType::null ) -> DataValue
static

Reconstruct a DataValue from nlohmann::json


The documentation for this class was generated from the following files:
  • engine/src/toast/assets/data_value.hpp
  • engine/src/toast/assets/data_value.cpp