Struct NodeData

Synopsis

#include <src/c4/yml/tree.hpp>

struct NodeData

Description

contains the data for each YAML node.

Mentioned in

Summary

type
type_str overload
key
key_tag
key_anchor
keysc
val
val_tag
val_anchor
valsc
is_root
is_stream
is_doc
is_container
is_map
is_seq
has_val
has_key
is_val
is_keyval
has_key_tag
has_val_tag
has_key_anchor
has_val_anchor
is_key_ref
is_val_ref

Source

Lines 338-404 in src/c4/yml/tree.hpp.

struct NodeData
{

    NodeType   m_type;

    NodeScalar m_key;
    NodeScalar m_val;

    size_t     m_parent;
    size_t     m_first_child;
    size_t     m_last_child;
    size_t     m_next_sibling;
    size_t     m_prev_sibling;

public:

    NodeType_e type() const { return (NodeType_e)(m_type & _TYMASK); }
    const char* type_str() const { return type_str(m_type); }
    RYML_EXPORT static const char* type_str(NodeType_e ty);

    csubstr const& key() const { RYML_ASSERT(has_key()); return m_key.scalar; }
    csubstr const& key_tag() const { RYML_ASSERT(has_key_tag()); return m_key.tag; }
    csubstr const& key_anchor() const { return m_key.anchor; }
    NodeScalar const& keysc() const { RYML_ASSERT(has_key()); return m_key; }

    csubstr const& val() const { RYML_ASSERT(has_val()); return m_val.scalar; }
    csubstr const& val_tag() const { RYML_ASSERT(has_val_tag()); return m_val.tag; }
    csubstr const& val_anchor() const { RYML_ASSERT(has_val_tag()); return m_val.anchor; }
    NodeScalar const& valsc() const { RYML_ASSERT(has_val()); return m_val; }

public:

#if defined(__clang__)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wnull-dereference"
#elif defined(__GNUC__)
#   pragma GCC diagnostic push
#   if __GNUC__ >= 6
#       pragma GCC diagnostic ignored "-Wnull-dereference"
#   endif
#endif

    bool   is_root() const { return m_parent == NONE; }

    bool   is_stream() const { return m_type.is_stream(); }
    bool   is_doc() const { return m_type.is_doc(); }
    bool   is_container() const { return m_type.is_container(); }
    bool   is_map() const { return m_type.is_map(); }
    bool   is_seq() const { return m_type.is_seq(); }
    bool   has_val() const { return m_type.has_val(); }
    bool   has_key() const { return m_type.has_key(); }
    bool   is_val() const { return m_type.is_val(); }
    bool   is_keyval() const { return m_type.is_keyval(); }
    bool   has_key_tag() const { return m_type.has_key_tag(); }
    bool   has_val_tag() const { return m_type.has_val_tag(); }
    bool   has_key_anchor() const { return ! m_type.has_key_anchor(); }
    bool   has_val_anchor() const { return ! m_type.has_val_anchor(); }
    bool   is_key_ref() const { return m_type.is_key_ref(); }
    bool   is_val_ref() const { return m_type.is_val_ref(); }

#if defined(__clang__)
#   pragma clang diagnostic pop
#elif defined(__GNUC__)
#   pragma GCC diagnostic pop
#endif

};





Add Discussion as Guest

Log in