rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::NodeInit Struct Reference

convenience class to initialize nodes More...

#include <tree.hpp>

Public Member Functions

 NodeInit ()
 initialize as an empty node
 NodeInit (NodeType_e t)
 initialize as a typed node
 NodeInit (NodeScalar const &v)
 initialize as a sequence member
 NodeInit (NodeScalar const &v, NodeType_e t)
 initialize as a sequence member with explicit type
 NodeInit (NodeScalar const &k, NodeScalar const &v)
 initialize as a mapping member
 NodeInit (NodeType_e t, NodeScalar const &k, NodeScalar const &v)
 initialize as a mapping member with explicit type
 NodeInit (NodeType_e t, NodeScalar const &k)
 initialize as a mapping member with explicit type (eg for SEQ or MAP)
void clear ()
void _add_flags (type_bits more_flags=0)
bool _check () const

Public Attributes

NodeType type
NodeScalar key
NodeScalar val

Detailed Description

convenience class to initialize nodes

Definition at line 163 of file tree.hpp.

Constructor & Destructor Documentation

◆ NodeInit() [1/7]

c4::yml::NodeInit::NodeInit ( )
inline

initialize as an empty node

Definition at line 173 of file tree.hpp.

173: type(NOTYPE), key(), val() {}
@ NOTYPE
no node type or style is set
Definition node_type.hpp:36
NodeType type
Definition tree.hpp:166
NodeScalar key
Definition tree.hpp:167
NodeScalar val
Definition tree.hpp:168

◆ NodeInit() [2/7]

c4::yml::NodeInit::NodeInit ( NodeType_e t)
inline

initialize as a typed node

Definition at line 175 of file tree.hpp.

175: type(t), key(), val() {}

◆ NodeInit() [3/7]

c4::yml::NodeInit::NodeInit ( NodeScalar const & v)
inline

initialize as a sequence member

Definition at line 177 of file tree.hpp.

177: type(VAL), key(), val(v) { _add_flags(); }
@ VAL
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition node_type.hpp:38
void _add_flags(type_bits more_flags=0)
Definition tree.hpp:196

◆ NodeInit() [4/7]

c4::yml::NodeInit::NodeInit ( NodeScalar const & v,
NodeType_e t )
inline

initialize as a sequence member with explicit type

Definition at line 179 of file tree.hpp.

179: type(t|VAL), key(), val(v) { _add_flags(); }

◆ NodeInit() [5/7]

c4::yml::NodeInit::NodeInit ( NodeScalar const & k,
NodeScalar const & v )
inline

initialize as a mapping member

Definition at line 181 of file tree.hpp.

181: type(KEYVAL), key(k), val(v) { _add_flags(); }

◆ NodeInit() [6/7]

c4::yml::NodeInit::NodeInit ( NodeType_e t,
NodeScalar const & k,
NodeScalar const & v )
inline

initialize as a mapping member with explicit type

Definition at line 183 of file tree.hpp.

183: type(t), key(k), val(v) { _add_flags(); }

◆ NodeInit() [7/7]

c4::yml::NodeInit::NodeInit ( NodeType_e t,
NodeScalar const & k )
inline

initialize as a mapping member with explicit type (eg for SEQ or MAP)

Definition at line 185 of file tree.hpp.

185: type(t), key(k), val( ) { _add_flags(KEY); }
@ KEY
is member of a map
Definition node_type.hpp:37

Member Function Documentation

◆ clear()

void c4::yml::NodeInit::clear ( )
inline

Definition at line 189 of file tree.hpp.

190 {
191 type.clear();
192 key.clear();
193 val.clear();
194 }

◆ _add_flags()

void c4::yml::NodeInit::_add_flags ( type_bits more_flags = 0)
inline

Definition at line 196 of file tree.hpp.

197 {
198 type = (type|more_flags);
199 if( ! key.tag.empty())
200 type = (type|KEYTAG);
201 if( ! val.tag.empty())
202 type = (type|VALTAG);
203 if( ! key.anchor.empty())
204 type = (type|KEYANCH);
205 if( ! val.anchor.empty())
206 type = (type|VALANCH);
207 }
@ VALANCH
the val has an &anchor
Definition node_type.hpp:46
@ KEYTAG
the key has a tag
Definition node_type.hpp:47
@ VALTAG
the val has a tag
Definition node_type.hpp:48
@ KEYANCH
the key has an &anchor
Definition node_type.hpp:45

◆ _check()

bool c4::yml::NodeInit::_check ( ) const
inline

Definition at line 209 of file tree.hpp.

210 {
211 // key cannot be empty
212 _RYML_ASSERT_BASIC(key.scalar.empty() == ((type & KEY) == 0));
213 // key tag cannot be empty
214 _RYML_ASSERT_BASIC(key.tag.empty() == ((type & KEYTAG) == 0));
215 // val may be empty even though VAL is set. But when VAL is not set, val must be empty
216 _RYML_ASSERT_BASIC(((type & VAL) != 0) || val.scalar.empty());
217 // val tag cannot be empty
218 _RYML_ASSERT_BASIC(val.tag.empty() == ((type & VALTAG) == 0));
219 return true;
220 }

Member Data Documentation

◆ type

NodeType c4::yml::NodeInit::type

Definition at line 166 of file tree.hpp.

◆ key

NodeScalar c4::yml::NodeInit::key

Definition at line 167 of file tree.hpp.

◆ val

NodeScalar c4::yml::NodeInit::val

Definition at line 168 of file tree.hpp.


The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/v0.14.0/src/c4/yml/tree.hpp