Wrapper around yaml-cpp node with ergonomic accessors.
More...
#include <YamlNode.hpp>
|
| | YamlNode (YAML::Node node, std::string path="root") |
| | Wrap an existing yaml-cpp node.
|
| YamlNode | operator[] (const std::string &key) const |
| | Access child by key (map).
|
| YamlNode | operator[] (std::size_t index) const |
| | Access child by index (sequence).
|
| bool | Has (const std::string &key) const |
| | Check if key exists.
|
| bool | IsDefined () const |
| | Check if node is defined.
|
| bool | IsSequence () const |
| | Check if node is a sequence.
|
| bool | IsMap () const |
| | Check if node is a map.
|
| bool | IsScalar () const |
| | Check if node is a scalar.
|
| bool | IsNull () const |
| | Check if node is null.
|
| std::size_t | Size () const |
| | Get sequence size.
|
| const std::string & | Path () const |
| | Get current path (for error messages).
|
| template<typename T> |
| T | Require (const std::string &key) const |
| | Get required value (throws YamlError if missing or wrong type).
|
| template<typename T> |
| T | As () const |
| | Get required value from current node.
|
| template<typename T> |
| T | Get (const std::string &key, const T &default_value) const |
| | Get optional value with default.
|
| template<typename T> |
| std::optional< T > | GetOptional (const std::string &key) const |
| | Get optional value (returns nullopt if missing).
|
| template<typename Func> |
| void | ForEach (Func &&func) const |
| | Iterate over sequence elements.
|
| template<typename Func> |
| void | ForEachEntry (Func &&func) const |
| | Iterate over map entries: func(key, node).
|
| template<typename T> |
| std::vector< T > | ToVector () const |
| | Convert sequence to vector.
|
| const YAML::Node & | Raw () const |
| | Get underlying yaml-cpp node.
|
| template<> |
| double | As () const |
| | Convert node to double.
|
| template<> |
| float | As () const |
| | Convert node to float.
|
| template<> |
| int | As () const |
| | Convert node to int.
|
| template<> |
| int64_t | As () const |
| | Convert node to int64_t.
|
| template<> |
| bool | As () const |
| | Convert node to bool.
|
Wrapper around yaml-cpp node with ergonomic accessors.
Provides:
- Type-safe extraction with good error messages
- Path tracking for debugging
- Support for Janus math types
◆ YamlNode()
| vulcan::io::YamlNode::YamlNode |
( |
YAML::Node | node, |
|
|
std::string | path = "root" ) |
|
inlineexplicit |
Wrap an existing yaml-cpp node.
◆ As() [1/6]
template<>
| bool vulcan::io::YamlNode::As |
( |
| ) |
const |
|
inline |
◆ As() [2/6]
template<>
| int64_t vulcan::io::YamlNode::As |
( |
| ) |
const |
|
inline |
◆ As() [3/6]
template<>
| int vulcan::io::YamlNode::As |
( |
| ) |
const |
|
inline |
◆ As() [4/6]
template<>
| float vulcan::io::YamlNode::As |
( |
| ) |
const |
|
inline |
◆ As() [5/6]
template<>
| double vulcan::io::YamlNode::As |
( |
| ) |
const |
|
inline |
◆ As() [6/6]
template<typename T>
| T vulcan::io::YamlNode::As |
( |
| ) |
const |
|
nodiscard |
Get required value from current node.
◆ ForEach()
template<typename Func>
| void vulcan::io::YamlNode::ForEach |
( |
Func && | func | ) |
const |
|
inline |
Iterate over sequence elements.
◆ ForEachEntry()
template<typename Func>
| void vulcan::io::YamlNode::ForEachEntry |
( |
Func && | func | ) |
const |
|
inline |
Iterate over map entries: func(key, node).
◆ Get()
template<typename T>
| T vulcan::io::YamlNode::Get |
( |
const std::string & | key, |
|
|
const T & | default_value ) const |
|
inlinenodiscard |
Get optional value with default.
◆ GetOptional()
template<typename T>
| std::optional< T > vulcan::io::YamlNode::GetOptional |
( |
const std::string & | key | ) |
const |
|
inlinenodiscard |
Get optional value (returns nullopt if missing).
◆ Has()
| bool vulcan::io::YamlNode::Has |
( |
const std::string & | key | ) |
const |
|
inlinenodiscard |
◆ IsDefined()
| bool vulcan::io::YamlNode::IsDefined |
( |
| ) |
const |
|
inlinenodiscard |
Check if node is defined.
◆ IsMap()
| bool vulcan::io::YamlNode::IsMap |
( |
| ) |
const |
|
inlinenodiscard |
◆ IsNull()
| bool vulcan::io::YamlNode::IsNull |
( |
| ) |
const |
|
inlinenodiscard |
◆ IsScalar()
| bool vulcan::io::YamlNode::IsScalar |
( |
| ) |
const |
|
inlinenodiscard |
Check if node is a scalar.
◆ IsSequence()
| bool vulcan::io::YamlNode::IsSequence |
( |
| ) |
const |
|
inlinenodiscard |
Check if node is a sequence.
◆ LoadFile()
| YamlNode vulcan::io::YamlNode::LoadFile |
( |
const std::string & | path | ) |
|
|
inlinestatic |
◆ operator[]() [1/2]
| YamlNode vulcan::io::YamlNode::operator[] |
( |
const std::string & | key | ) |
const |
|
inlinenodiscard |
Access child by key (map).
◆ operator[]() [2/2]
| YamlNode vulcan::io::YamlNode::operator[] |
( |
std::size_t | index | ) |
const |
|
inlinenodiscard |
Access child by index (sequence).
◆ Parse()
| YamlNode vulcan::io::YamlNode::Parse |
( |
const std::string & | yaml_content | ) |
|
|
inlinestatic |
◆ Path()
| const std::string & vulcan::io::YamlNode::Path |
( |
| ) |
const |
|
inlinenodiscard |
Get current path (for error messages).
◆ Raw()
| const YAML::Node & vulcan::io::YamlNode::Raw |
( |
| ) |
const |
|
inlinenodiscard |
Get underlying yaml-cpp node.
◆ Require()
template<typename T>
| T vulcan::io::YamlNode::Require |
( |
const std::string & | key | ) |
const |
|
inlinenodiscard |
Get required value (throws YamlError if missing or wrong type).
◆ Size()
| std::size_t vulcan::io::YamlNode::Size |
( |
| ) |
const |
|
inlinenodiscard |
◆ ToVector()
template<typename T>
| std::vector< T > vulcan::io::YamlNode::ToVector |
( |
| ) |
const |
|
inlinenodiscard |
Convert sequence to vector.
The documentation for this class was generated from the following file: