class
SushiAI::Config::Value
One node of a parsed configuration document.
- Declared in
include/SushiAI/config/value.hpp
Public member functions
Value()=defaultConstructs the null value.
Kind kind() const noexceptWhat this node holds.
bool is_null() const noexceptWhether this node is JSON null.
bool as_bool(std::string_view context) constReads this value as a boolean.
Parameters
contextWhat this value is, for the diagnostic, e.g. "layer 3 'use_bias'".
Returns
The boolean.
Exceptions
ErrorIf this is not a boolean; names
contextand the kind found.
std::int64_t as_int(std::string_view context) constReads this value as a whole number.
Parameters
contextWhat this value is, for the diagnostic.
Returns
The number.
Exceptions
ErrorIf this is not a whole number; names
contextand the kind found.
double as_real(std::string_view context) constReads this value as a real number, widening integers.
Parameters
contextContext string for error diagnostics.
Returns
Floating-point numeric value.
Exceptions
ErrorIf value is neither real nor integer.
const std::string & as_string(std::string_view context) constReads this value as a string.
Parameters
contextWhat this value is, for the diagnostic.
Returns
The string.
Exceptions
ErrorIf this is not a string; names
contextand the kind found.
const std::vector< Value > & as_array(std::string_view context) constReads this value as an array.
Parameters
contextWhat this value is, for the diagnostic.
Returns
Its entries.
Exceptions
ErrorIf this is not an array; names
contextand the kind found.
bool has(std::string_view key) const noexceptWhether this object holds key; false for any non-object.
Parameters
keyThe key to look for.
Returns
True when this is an object carrying key.
const Value & at(std::string_view key, std::string_view context) constAccesses child value associated with key.
Parameters
keyProperty key to look up.
contextContext string for error diagnostics.
Returns
Const reference to value mapped to key.
Exceptions
ErrorIf node is not an object or key is absent.
const Value & at_or(std::string_view key, const Value &fallback) const noexceptThis object's value for key, or fallback when absent.
Parameters
keyThe key to look up.
fallbackReturned when
keyis absent; must outlive the result.
Returns
The value, or fallback.
const std::vector< std::string > & keys() const noexceptThis object's keys, in the order the file spelled them.
void reject_unknown_keys(std::string_view context, SushiRuntime::span< const std::string_view > allowed) constRejects any key of this object absent from allowed.
Parameters
contextContext string for error diagnostics.
allowedPermitted property key names.
Exceptions
ErrorIf an unrecognized key is present.
Value without(std::string_view key) constReturns a copy of this object with key removed.
Parameters
keyProperty key to omit.
Returns
New value copy omitting specified key.
Static public member functions
static Value boolean(bool value)Builds a boolean.
Parameters
valueIts value.
Returns
The node.
static Value integer(std::int64_t value)Builds a whole number.
Parameters
valueIts value.
Returns
The node.
static Value real(double value)Builds a real.
Parameters
valueIts value.
Returns
The node.
static Value string(std::string value)Builds a string.
Parameters
valueIts value; moved in.
Returns
The node.
static Value array(std::vector< Value > entries)Builds an array.
Parameters
entriesIts entries; moved in.
Returns
The node.
static Value object(std::vector< std::string > keys, std::vector< Value > values)Builds an object.
Parameters
keysIts keys, in file order; moved in.
valuesIts values, positionally matching
keys; moved in.
Returns
The node.
Exceptions
ErrorIf the two vectors are of different lengths.

