rapidyaml  0.16.0
parseandemitYAML,anddoitfast

Implementation of deserialization from a tree. More...

Functions

template<class T >
ReadResult c4::yml::read (Tree const *tree, id_type id, T *v)
 Deserialize a scalar node's val from a tree object, returning false if the conversion failed. More...
 
template<class Wrapper >
ReadResult c4::yml::read (Tree const *tree, id_type id, Wrapper const &w)
 overload to enable use of wrapper tag-types like eg c4::fmt::base64() More...
 
template<class T >
ReadResult c4::yml::read_key (Tree const *tree, id_type id, T *v)
 Deserialize a node's key from a tree object, returning false if the conversion failed. More...
 
template<class Wrapper >
ReadResult c4::yml::read_key (Tree const *tree, id_type id, Wrapper const &w)
 overload to enable use of wrapper tag-types like eg c4::fmt::base64() More...
 

Detailed Description

Implementation of deserialization from a tree.

Function Documentation

template<class T >
ReadResult c4::yml::read ( Tree const *  tree,
id_type  id,
T *  v 
)
inline

Deserialize a scalar node's val from a tree object, returning false if the conversion failed.

Returns
false if the conversion failed
See also
scalar_deserialize()
the counterpart function read_key()

Definition at line 1871 of file tree.hpp.

1872 {
1873  // caller only checks that type is one of VAL|MAP|SEQ (because it
1874  // can't be more concrete than that). Here, we expect a VAL so now
1875  // we can check for that:
1876  NodeData const* C4_RESTRICT nd = tree->_p(id);
1877  return ReadResult((nd->m_type & VAL) && scalar_deserialize(nd->m_val.scalar, v), id);
1878 }
bool scalar_deserialize(csubstr str, T *val)
Deserialize a scalar from its string representation, dispatching to one of from_chars(), from_chars_float() or from_chars_integral() as appropriate.
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:34
template<class Wrapper >
ReadResult c4::yml::read ( Tree const *  tree,
id_type  id,
Wrapper const &  w 
)
inline

overload to enable use of wrapper tag-types like eg c4::fmt::base64()

Definition at line 1882 of file tree.hpp.

Referenced by c4::yml::Tree::deserialize(), and c4::yml::Tree::load().

1883 {
1884  // caller only checks that type is one of VAL|MAP|SEQ (because it
1885  // can't be more concrete than that). Here, we expect a VAL so now
1886  // we can check for that:
1887  NodeData const* C4_RESTRICT nd = tree->_p(id);
1888  return ReadResult((nd->m_type & VAL) && from_chars(nd->m_val.scalar, w), id);
1889 }
bool from_chars(ryml::csubstr buf, vec2< T > *v)
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:34
template<class T >
ReadResult c4::yml::read_key ( Tree const *  tree,
id_type  id,
T *  v 
)
inline

Deserialize a node's key from a tree object, returning false if the conversion failed.

Returns
false if the conversion failed
See also
the counterpart function read(Tree const*, id_type, T*)

Definition at line 1898 of file tree.hpp.

1899 {
1900  // caller already checks availability of key
1901  return ReadResult(scalar_deserialize(tree->_p(id)->m_key.scalar, v), id);
1902 }
bool scalar_deserialize(csubstr str, T *val)
Deserialize a scalar from its string representation, dispatching to one of from_chars(), from_chars_float() or from_chars_integral() as appropriate.
template<class Wrapper >
ReadResult c4::yml::read_key ( Tree const *  tree,
id_type  id,
Wrapper const &  w 
)
inline

overload to enable use of wrapper tag-types like eg c4::fmt::base64()

Definition at line 1906 of file tree.hpp.

Referenced by c4::yml::Tree::deserialize_key(), and c4::yml::Tree::load_key().

1907 {
1908  // caller already checks availability of key
1909  return ReadResult(from_chars(tree->_p(id)->m_key.scalar, w), id);
1910 }
bool from_chars(ryml::csubstr buf, vec2< T > *v)