Class yaml_ref

Class Documentation

class yaml_ref

Non-owning mutable reference into a yaml tree node. Returned by yaml::operator[]. Implicitly converts to yaml (deep copy) for reading; assignments write through to the referenced node.

Note

Invalidated if the parent yaml container reallocates (e.g. a new map key is inserted). Treat it as a temporary handle, not a persistent reference.

Note

[New in MRPT 3.x]

Public Types

using node_t = yaml::node_t
using scalar_t = yaml::scalar_t
using sequence_t = yaml::sequence_t
using map_t = yaml::map_t

Public Functions

yaml_ref() = delete
yaml_ref(const yaml_ref&) = default
inline explicit yaml_ref(node_t &n)
inline operator yaml() const
inline node_t &node()
inline const node_t &node() const
inline bool isNullNode() const
inline bool isScalar() const
inline bool isMap() const
inline bool isSequence() const
inline std::string typeName() const
template<typename T>
inline T as() const
inline size_t size() const
inline bool empty() const
inline bool has(const std::string &key) const
inline void clear()
inline sequence_t &asSequence()
inline const sequence_t &asSequence() const
inline map_t &asMap()
inline const map_t &asMap() const
inline map_t asMapRange() const
inline scalar_t &asScalar()
inline const scalar_t &asScalar() const
inline bool keyHasComment(const std::string &key) const
inline std::string keyComment(const std::string &key) const
inline const node_t &keyNode(const std::string &key) const
inline node_t &keyNode(const std::string &key)
inline size_t erase(const std::string &key)
inline bool erase(int index)
inline bool hasComment() const
inline bool hasComment(CommentPosition pos) const
inline const std::string &comment() const
inline const std::string &comment(CommentPosition pos) const
inline void comment(const std::string &c, CommentPosition pos = CommentPosition::RIGHT)
inline void printAsYAML(std::ostream &o, const YamlEmitOptions &eo = {}) const
inline void printAsYAML() const
yaml_ref operator[](const std::string &key)
yaml_ref operator[](const char *key)
yaml_cref operator[](const std::string &key) const
yaml_cref operator[](const char *key) const
yaml_ref operator[](int index)
yaml_cref operator[](int index) const
inline yaml_ref operator()(int index)
inline yaml_cref operator()(int index) const
inline const std::type_info &scalarType() const
template<typename T>
inline T getOrDefault(const std::string &key, const T &def) const
template<typename T>
inline T &asRef()
inline yaml_ref &operator=(bool v)
inline yaml_ref &operator=(float v)
inline yaml_ref &operator=(double v)
inline yaml_ref &operator=(int8_t v)
inline yaml_ref &operator=(uint8_t v)
inline yaml_ref &operator=(int16_t v)
inline yaml_ref &operator=(uint16_t v)
inline yaml_ref &operator=(int32_t v)
inline yaml_ref &operator=(uint32_t v)
inline yaml_ref &operator=(int64_t v)
inline yaml_ref &operator=(uint64_t v)
inline yaml_ref &operator=(const std::string &v)
inline yaml_ref &operator=(const char *v)
inline yaml_ref &operator=(const std::string_view &v)
inline yaml_ref &operator=(const yaml &v)
inline yaml_ref &operator=(const yaml_ref &v)
template<typename = std::enable_if<!std::is_same_v<std::size_t, uint64_t> && !std::is_same_v<std::size_t, int64_t> && !std::is_same_v<std::size_t, uint32_t> && !std::is_same_v<std::size_t, int32_t>>>
inline yaml_ref &operator=(std::size_t v)
template<typename T>
inline yaml_ref &operator=(const ValueCommentPair<T> &vc)

vcp (value-comment) wrapper

inline operator bool() const
inline operator double() const
inline operator float() const
inline operator int8_t() const
inline operator uint8_t() const
inline operator int16_t() const
inline operator uint16_t() const
inline operator int32_t() const
inline operator uint32_t() const
inline operator int64_t() const
inline operator uint64_t() const
inline operator std::string() const
inline void push_back(double v)
inline void push_back(const std::string &v)
inline void push_back(uint64_t v)
inline void push_back(bool v)
inline void push_back(const yaml &v)