libcamera
v0.3.1+12-19bbca3c
Supporting cameras in Linux since 2019
|
A class representing the tree structure of the YAML content. More...
Public Member Functions | |
bool | isValue () const |
Return whether the YamlObject is a value. More... | |
bool | isList () const |
Return whether the YamlObject is a list. More... | |
bool | isDictionary () const |
Return whether the YamlObject is a dictionary. More... | |
std::size_t | size () const |
Retrieve the number of elements in a dictionary or list YamlObject. More... | |
template<typename T > | |
std::optional< T > | get () const |
Parse the YamlObject as a T value. More... | |
template<typename T , typename U > | |
T | get (U &&defaultValue) const |
Parse the YamlObject as a T value. More... | |
template<typename T > | |
std::optional< std::vector< T > > | getList () const |
Parse the YamlObject as a list of T. More... | |
DictAdapter | asDict () const |
Wrap a dictionary YamlObject in an adapter that exposes iterators. More... | |
ListAdapter | asList () const |
Wrap a list YamlObject in an adapter that exposes iterators. More... | |
const YamlObject & | operator[] (std::size_t index) const |
Retrieve the element from list YamlObject by index. More... | |
bool | contains (const std::string &key) const |
Check if an element of a dictionary exists. More... | |
const YamlObject & | operator[] (const std::string &key) const |
Retrieve a member by name from the dictionary. More... | |
Friends | |
template<typename T > | |
struct | Getter |
class | YamlParserContext |
A class representing the tree structure of the YAML content.
The YamlObject class represents the tree structure of YAML content. A YamlObject can be a dictionary or list of YamlObjects or a value if a tree leaf.
|
inline |
Wrap a dictionary YamlObject in an adapter that exposes iterators.
The YamlObject class doesn't directly implement iterators, as the iterator type depends on whether the object is a Dictionary or List. This function wraps a YamlObject of Dictionary type into an adapter that exposes iterators, as well as begin() and end() functions, allowing usage of range-based for loops with YamlObject. As YAML mappings are not ordered, the iteration order is not specified.
The iterator's value_type is a std::pair<const std::string &, const YamlObject &>.
If the YamlObject is not of Dictionary type, the returned adapter operates as an empty container.
|
inline |
Wrap a list YamlObject in an adapter that exposes iterators.
The YamlObject class doesn't directly implement iterators, as the iterator type depends on whether the object is a Dictionary or List. This function wraps a YamlObject of List type into an adapter that exposes iterators, as well as begin() and end() functions, allowing usage of range-based for loops with YamlObject. As YAML lists are ordered, the iteration order is identical to the list order in the YAML data.
The iterator's value_type is a const YamlObject &.
If the YamlObject is not of List type, the returned adapter operates as an empty container.
bool libcamera::YamlObject::contains | ( | const std::string & | key | ) | const |
Check if an element of a dictionary exists.
This function check if the YamlObject contains an element. Only YamlObject instances of Dictionary type associate elements with names, calling this function on other types of instances is invalid and results in undefined behaviour.
|
inline |
Parse the YamlObject as a T value.
This function parses the value of the YamlObject as a T object, and returns the value. If parsing fails (usually because the YamlObject doesn't store a T value), std::nullopt is returned.
|
inline |
Parse the YamlObject as a T value.
[in] | defaultValue | The default value when failing to parse |
This function parses the value of the YamlObject as a T object, and returns the value. If parsing fails (usually because the YamlObject doesn't store a T value), the defaultValue is returned.
template< typename T > libcamera::YamlObject::getList< T > | ( | ) | const |
Parse the YamlObject as a list of T.
This function parses the value of the YamlObject as a list of T objects, and returns the value as a std::vector<T>. If parsing fails, std::nullopt is returned.
|
inline |
Return whether the YamlObject is a dictionary.
|
inline |
Return whether the YamlObject is a list.
|
inline |
Return whether the YamlObject is a value.
const YamlObject & libcamera::YamlObject::operator[] | ( | std::size_t | index | ) | const |
Retrieve the element from list YamlObject by index.
This function retrieves an element of the YamlObject. Only YamlObject instances of List type associate elements with index, calling this function on other types of instances is invalid and results in undefined behaviour.
const YamlObject & libcamera::YamlObject::operator[] | ( | const std::string & | key | ) | const |
Retrieve a member by name from the dictionary.
This function retrieve a member of a YamlObject by name. Only YamlObject instances of Dictionary type associate elements with names, calling this function on other types of instances is invalid and results in undefined behaviour.
std::size_t libcamera::YamlObject::size | ( | ) | const |
Retrieve the number of elements in a dictionary or list YamlObject.
This function retrieves the size of the YamlObject, defined as the number of child elements it contains. Only YamlObject instances of Dictionary or List types have a size, calling this function on other types of instances is invalid and results in undefined behaviour.