rapidyaml  0.7.2
parse and emit YAML, and do it fast
Serialization helpers

Classes

struct  c4::yml::Key< K >
 
struct  c4::yml::Key< fmt::const_base64_wrapper >
 
struct  c4::yml::Key< fmt::base64_wrapper >
 

Functions

template<class K >
Key< K > c4::yml::key (K &k)
 
Key< fmt::const_base64_wrapperc4::yml::key (fmt::const_base64_wrapper w)
 
Key< fmt::base64_wrapperc4::yml::key (fmt::base64_wrapper w)
 
template<class T >
void c4::yml::write (NodeRef *n, T const &v)
 
template<class T >
std::enable_if< ! std::is_floating_point< T >::value, bool >::type c4::yml::read (NodeRef const &n, T *v)
 convert the val of a scalar node to a floating point type, by forwarding its val to from_chars_float<T>(). More...
 
template<class T >
auto c4::yml::read (ConstNodeRef const &n, T *v) -> typename std::enable_if< ! std::is_floating_point< T >::value, bool >::type
 convert the val of a scalar node to a particular type, by forwarding its val to from_chars<T>(). More...
 

Detailed Description

Function Documentation

◆ key() [1/3]

◆ key() [2/3]

Definition at line 44 of file node.hpp.

44 { return {w}; }

◆ key() [3/3]

Key<fmt::base64_wrapper> c4::yml::key ( fmt::base64_wrapper  w)
inline

Definition at line 45 of file node.hpp.

45 { return {w}; }

◆ write()

template<class T >
void c4::yml::write ( NodeRef n,
T const &  v 
)
inline

Definition at line 1602 of file node.hpp.

1603 {
1604  n->set_val_serialized(v);
1605 }

References c4::yml::NodeRef::set_val_serialized().

Referenced by c4::yml::NodeRef::operator<<().

◆ read() [1/2]

template<class T >
std::enable_if< ! std::is_floating_point<T>::value, bool>::type c4::yml::read ( NodeRef const &  n,
T *  v 
) -> typename std::enable_if< ! std::is_floating_point< T >::value, bool >::type
inline

convert the val of a scalar node to a floating point type, by forwarding its val to from_chars_float<T>().

Returns
false if the conversion failed
Warning
Unlike non-floating types, only the leading part of the string that may constitute a number is processed. This happens because the float parsing is delegated to fast_float, which is implemented that way. Consequently, for example, all of "34", "34 " "34hg" "34 gh" will be read as 34. If you are not sure about the contents of the data, you can use csubstr::first_real_span() to check before calling >>, for example like this:
csubstr val = node.val();
if(val.first_real_span() == val)
node >> v;
else
ERROR("not a real")

convert the val of a scalar node to a floating point type, by forwarding its val to from_chars_float<T>().

The full string is used.

Returns
false if the conversion failed

Definition at line 1676 of file node.hpp.

1677 {
1678  csubstr val = n.val();
1679  if(val.empty())
1680  return false;
1681  return from_chars_float(val, v);
1682 }
bool from_chars_float(csubstr buf, T *val)
decode a floating point from string.
Definition: tree.hpp:60

References c4::yml::from_chars_float(), c4::yml::detail::read_skip_plus(), and c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::val().

Referenced by c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::operator>>().

◆ read() [2/2]

template<class T >
auto c4::yml::read ( ConstNodeRef const &  n,
T *  v 
) -> typename std::enable_if< ! std::is_floating_point<T>::value, bool>::type
inline

convert the val of a scalar node to a particular type, by forwarding its val to from_chars<T>().

The full string is used.

Returns
false if the conversion failed

Definition at line 1643 of file node.hpp.

1645 {
1646  csubstr val = n.val();
1647  if(val.empty())
1648  return false;
1649  return detail::read_skip_plus(val, v);
1650 }
auto read_skip_plus(csubstr val, T *v) -> typename std::enable_if< std::is_arithmetic< T >::value, bool >::type
Definition: node.hpp:1610

References c4::yml::detail::read_skip_plus().