Handle class for value tree compounds. More...
#include <eagine/value_tree/wrappers.hpp>
Public Types | |
using | visit_handler = callable_ref< bool(compound &, const attribute &, const basic_string_path &)> |
Type of traverse/visit handler. | |
using | stack_visit_handler = callable_ref< bool(compound &, const attribute &, const basic_string_path &, span< const attribute >)> |
Type of traverse/visit handler using full attribute stack. | |
Public Member Functions | |
compound () noexcept=default | |
Default constructor. Constructs an empty compound. | |
operator bool () const noexcept | |
Indicates if this compound actually refers to some tree. | |
auto | type_id () const noexcept -> identifier_t |
Returns the implementation type id of this attribute. | |
auto | structure () const -> attribute |
Returns the root of attribute hierarchy describing the tree structure. More... | |
auto | root () const -> compound_attribute |
Returns the structure root as an compound_attribute. More... | |
auto | attribute_name (const attribute &attrib) const -> string_view |
Returns the name of an attribute. More... | |
auto | canonical_type (const attribute &attrib) const -> value_type |
Returns the caninical value type of an attribute. More... | |
auto | is_link (const attribute &attrib) const -> bool |
Indicates if the specified attribute is a reference or link in the tree. More... | |
auto | nested_count (const attribute &attrib) const -> span_size_t |
Returns the count of nested attributes of an attribute. More... | |
auto | has_nested (const attribute &attrib) const -> bool |
Indicates if an attribute has nested attribute accessible by index. More... | |
auto | nested (const attribute &attrib, span_size_t index) const -> attribute |
Returns nested attribute of an attribute at the specified index. More... | |
auto | nested (const attribute &attrib, string_view name) const -> attribute |
Returns nested attribute of an attribute with the specified name. More... | |
auto | nested (string_view name) const -> attribute |
Returns nested attribute of the root attribute with the specified name. More... | |
auto | find (const attribute &attrib, const basic_string_path &path) const -> attribute |
Returns nested attribute of an attribute at the specified path. More... | |
auto | find (const attribute &attrib, const basic_string_path &path, span< const string_view > tags) const -> attribute |
Returns nested attribute of an attribute at path with tags. More... | |
auto | find (const basic_string_path &path) const -> attribute |
Returns nested attribute of root attribute at the specified path. More... | |
auto | find (const basic_string_path &path, span< const string_view > tags) const -> attribute |
Returns nested attribute of root attribute at path with tags. More... | |
auto | value_count (const attribute &attrib) const -> span_size_t |
Returns the number of value elements accessible through an attribute. | |
auto | value_count (const basic_string_path &path) const -> span_size_t |
Returns the number of value elements at the specified path. | |
auto | value_count (string_view name) -> span_size_t |
Returns the number of value elements at attribute with the given name. | |
template<typename T > | |
auto | fetch_values (const attribute &attrib, span_size_t offset, span< T > dest) const -> span< T > |
Fetches values at the given attribute, starting at offset into dest . | |
template<typename T > | |
auto | fetch_values (const basic_string_path &path, span_size_t offset, span< T > dest) const -> span< T > |
Fetches values at the given path, starting at offset into dest . | |
template<typename T > | |
auto | fetch_values (string_view name, span_size_t offset, span< T > dest) const -> span< T > |
Fetches values at the given name, starting at offset into dest . | |
template<typename T > | |
auto | fetch_values (const attribute &attrib, span< T > dest) const -> span< T > |
Fetches values at the given attribute, into dest . | |
template<typename T > | |
auto | fetch_values (const basic_string_path &path, span< T > dest) const -> span< T > |
Fetches values at the attribute with the specified path, into dest . | |
template<typename T > | |
auto | fetch_values (string_view name, span< T > dest) const -> span< T > |
Fetches values at the attribute with the specified name, into dest . | |
auto | fetch_blob (const attribute &attrib, memory::block dest) const -> memory::block |
Fetches a BLOB at the given attribute, into dest . | |
auto | fetch_blob (const basic_string_path &path, memory::block dest) const -> memory::block |
Fetches a BLOB at the attribute with the specified path, into dest . | |
auto | fetch_blob (string_view name, memory::block dest) const -> memory::block |
Fetches a BLOB at the attribute with the specified name, into dest . | |
template<typename T , identifier_t V> | |
auto | select_value (const attribute &attrib, span_size_t offset, T &dest, selector< V > sel) const -> bool |
Fetches a single value at the specified attribute, with a selector. | |
template<typename T > | |
auto | fetch_value (const attribute &attrib, span_size_t offset, T &dest) const -> bool |
Fetches a single value at the specified attribute, at offset into dest . | |
template<typename T , identifier_t V> | |
auto | select_values (const attribute &attrib, span_size_t offset, span< T > dest, selector< V > sel) const -> span< T > |
Fetches values at the specified attribute, with a selector, into dest. | |
template<typename T , identifier_t V> | |
auto | select_value (string_view name, span_size_t offset, T &dest, selector< V > sel) const -> bool |
Fetches values through the specified name, with a selector, into dest. | |
template<typename T > | |
auto | fetch_value (string_view name, span_size_t offset, T &dest) const -> bool |
Fetches values through the specified name, into dest. | |
template<typename T , identifier_t V> | |
auto | select_value (const basic_string_path &path, span_size_t offset, T &dest, selector< V > sel) const -> bool |
Fetches values through the specified path, with a selector, into dest. | |
template<typename T > | |
auto | fetch_value (const basic_string_path &path, span_size_t offset, T &dest) const -> bool |
Fetches values through the specified path, into dest. | |
template<typename T , identifier_t V> | |
auto | select_value (string_view name, T &dest, selector< V > sel) const -> bool |
Fetches values through the specified name, with a selector, into dest. | |
template<typename T > | |
auto | fetch_value (string_view name, T &dest) const -> bool |
Fetches values through the specified name, into dest. | |
template<typename T , identifier_t V> | |
auto | select_value (const attribute &attrib, T &dest, selector< V > sel) const -> bool |
Fetches a value at the specified attribute, with a selector, into dest. | |
template<typename T , identifier_t V> | |
auto | select_values (const attribute &attrib, span< T > dest, selector< V > sel) const -> span< T > |
Fetches values at the specified attribute, with a selector, into dest. | |
template<typename T > | |
auto | fetch_value (const attribute &attrib, T &dest) const -> bool |
Fetches a single value at the specified attribute, into dest. | |
template<typename T , identifier_t V> | |
auto | select_value (const basic_string_path &path, T &dest, selector< V > sel) const -> bool |
Fetches a value through the specified path, with selector, into dest. | |
template<typename T > | |
auto | fetch_value (const basic_string_path &path, T &dest) const -> bool |
Fetches a value through the specified path, into dest. | |
template<std::size_t L> | |
auto | has_value (const attribute &attrib, const char(&what)[L]) const -> bool |
Tests if there is an value at an attribute, that starts with what . | |
template<typename T , identifier_t V> | |
auto | get (const attribute &attrib, span_size_t offset, type_identity< T >, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at an attribute, at offset, with selector. | |
template<typename T > | |
auto | get (const attribute &attrib, span_size_t offset, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at an attribute, at the given offset. | |
template<typename T , identifier_t V> | |
auto | get (const basic_string_path &path, span_size_t offset, type_identity< T >, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at path, at given offset, with selector. | |
template<typename T > | |
auto | get (const basic_string_path &path, span_size_t offset, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at path, at given offset. | |
template<typename T , identifier_t V> | |
auto | get (string_view name, span_size_t offset, type_identity< T >, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at name, at given offset, with selector. | |
template<typename T > | |
auto | get (string_view name, span_size_t offset, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at name, at given offset. | |
template<typename T , identifier_t V> | |
auto | get (const attribute &attrib, type_identity< T > tid, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at an attribute, with selector. | |
template<typename T > | |
auto | get (const attribute &attrib, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at an attribute. | |
template<typename T , identifier_t V> | |
auto | get (const basic_string_path &path, type_identity< T > tid, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at path, with selector. | |
template<typename T > | |
auto | get (const basic_string_path &path, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at path. | |
template<typename T , identifier_t V> | |
auto | get (string_view name, type_identity< T > tid, selector< V > sel) const -> optionally_valid< T > |
Returns the value of type T at name, with selector. | |
template<typename T > | |
auto | get (string_view name, type_identity< T > tid={}) const -> optionally_valid< T > |
Returns the value of type T at name. | |
void | traverse (visit_handler visitor) |
Traverses the tree, calls the visitor function on each node. | |
void | traverse (stack_visit_handler visitor) |
Traverses the tree, calls the visitor function on each node. | |
Static Public Member Functions | |
template<typename Compound , typename... Args> | |
static auto | make (Args &&... args) -> std::enable_if_t< std::is_base_of_v< compound_interface, Compound >, compound > |
Instantiates a particular implementation. More... | |
Handle class for value tree compounds.
Compounds own, manage and parse the actual tree data of some structured tree hierarchy (JSON, YAML, XML, filesystem hierarchy, etc.). A compound represents the parsed or "open" instance of such a tree and allows to traverse and explore the tree structure and access the stored data through an unified interface.
|
inline |
Returns the name of an attribute.
Referenced by eagine::valtree::compound_attribute::name().
|
inline |
Returns the caninical value type of an attribute.
Tree data referred-to by an attribute can be fetched either using the canonical type or using a different, related value type, if the necessary conversion is implemented.
Referenced by eagine::valtree::compound_attribute::canonical_type().
|
inline |
Returns nested attribute of an attribute at the specified path.
Returns empty attribute handle if no such nested attribute exists.
Referenced by fetch_values(), find(), eagine::valtree::compound_attribute::find(), select_value(), and value_count().
|
inline |
Returns nested attribute of an attribute at path with tags.
Returns empty attribute handle if no such nested attribute exists.
|
inline |
Returns nested attribute of root attribute at the specified path.
Returns empty attribute handle if no such nested attribute exists.
|
inline |
Returns nested attribute of root attribute at path with tags.
Returns empty attribute handle if no such nested attribute exists.
|
inline |
Indicates if an attribute has nested attribute accessible by index.
Referenced by eagine::valtree::compound_attribute::has_nested().
|
inline |
Indicates if the specified attribute is a reference or link in the tree.
Referenced by eagine::valtree::compound_attribute::is_link().
|
inlinestatic |
Instantiates a particular implementation.
|
inline |
Returns nested attribute of an attribute at the specified index.
Returns empty attribute handle if no such nested attribute exists.
Referenced by fetch_values(), nested(), eagine::valtree::compound_attribute::nested(), select_value(), and value_count().
|
inline |
Returns nested attribute of an attribute with the specified name.
Returns empty attribute handle if no such nested attribute exists.
|
inline |
Returns nested attribute of the root attribute with the specified name.
Returns empty attribute handle if no such nested attribute exists.
|
inline |
Returns the count of nested attributes of an attribute.
Referenced by has_nested(), and eagine::valtree::compound_attribute::nested_count().
|
inline |
Returns the structure root as an compound_attribute.
|
inline |