rapidyaml  0.16.0
parseandemitYAML,anddoitfast

Implementation of serialization to a tree. More...

Modules

 Arena utils
 Implementation utils for serializing scalars in a tree's arena.
 

Functions

template<class T >
type_bits c4::yml::scalar_flags_val (T const &) noexcept
 Return extra style flags to use when setting a scalar as val. More...
 
template<class T >
type_bits c4::yml::scalar_flags_key (T const &) noexcept
 Return extra style flags to use when setting a scalar as key. More...
 
template<class T >
void c4::yml::write (Tree *tree, id_type id, T const &v)
 Serialize a variable to the tree's arena, and set it as the node's val. More...
 
template<class T >
void c4::yml::write_key (Tree *tree, id_type id, T const &v)
 Serialize a variable to the tree's arena, and set it as the node's key. More...
 

Detailed Description

Implementation of serialization to a tree.

Function Documentation

template<class T >
type_bits c4::yml::scalar_flags_val ( T const &  )
inlinenoexcept

Return extra style flags to use when setting a scalar as val.

Defaults to VAL_PLAIN for arithmetic types, or NOTYPE otherwise

Definition at line 1785 of file tree.hpp.

Referenced by c4::yml::write().

1786 {
1787  if constexpr (std::is_arithmetic_v<T>)
1788  return VAL_PLAIN;
1789  else
1790  return NOTYPE;
1791 }
mark val scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:156
no node type or style is set
Definition: node_type.hpp:32
template<class T >
type_bits c4::yml::scalar_flags_key ( T const &  )
inlinenoexcept

Return extra style flags to use when setting a scalar as key.

Defaults to KEY_PLAIN for arithmetic types, or NOTYPE otherwise

Definition at line 1795 of file tree.hpp.

Referenced by c4::yml::write_key().

1796 {
1797  if constexpr (std::is_arithmetic_v<T>)
1798  return KEY_PLAIN;
1799  else
1800  return NOTYPE;
1801 }
no node type or style is set
Definition: node_type.hpp:32
mark key scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:155
template<class T >
void c4::yml::write ( Tree *  tree,
id_type  id,
T const &  v 
)
inline

Serialize a variable to the tree's arena, and set it as the node's val.

Definition at line 1838 of file tree.hpp.

Referenced by c4::yml::Tree::save(), and c4::yml::Tree::set_serialized().

1839 {
1840  tree->set_val(id, serialize_to_arena(tree, v), scalar_flags_val(v));
1841 }
csubstr serialize_to_arena(Tree *, std::nullptr_t) noexcept
implementation for null values
Definition: tree.hpp:136
type_bits scalar_flags_val(T const &) noexcept
Return extra style flags to use when setting a scalar as val.
Definition: tree.hpp:1785
template<class T >
void c4::yml::write_key ( Tree *  tree,
id_type  id,
T const &  v 
)
inline

Serialize a variable to the tree's arena, and set it as the node's key.

Warning
The key MUST be a scalar value. The tree cannot handle container keys.

Definition at line 1848 of file tree.hpp.

Referenced by c4::yml::Tree::save_key(), and c4::yml::Tree::set_key_serialized().

1849 {
1850  tree->set_key(id, serialize_to_arena(tree, v), scalar_flags_key(v));
1851 }
csubstr serialize_to_arena(Tree *, std::nullptr_t) noexcept
implementation for null values
Definition: tree.hpp:136
type_bits scalar_flags_key(T const &) noexcept
Return extra style flags to use when setting a scalar as key.
Definition: tree.hpp:1795