Version: SMASH-3.1
YAML::convert< T > Struct Template Reference

#include <configuration.h>

template<typename T>
struct YAML::convert< T >

Convert from YAML::Node to SMASH-readable (C++) format and vice versa.

Template Parameters
TType of the values (could be any data type that needs conversion).

Definition at line 37 of file configuration.h.

Static Public Member Functions

static Node encode (const T &x)
 Serialization: Converts x (of any type) to a YAML::Node. More...
 
static bool decode (const Node &node, T &x)
 Deserialization: Converts a YAML::Node to any SMASH-readable data type and returns whether or not this operation was successful. More...
 

Member Function Documentation

◆ encode()

template<typename T >
static Node YAML::convert< T >::encode ( const T &  x)
inlinestatic

Serialization: Converts x (of any type) to a YAML::Node.

To do this, the type of x needs first be cast to a string.

Parameters
[in]xValue that is to be converted to a YAML::Node.
Returns
YAML node

Definition at line 45 of file configuration.h.

45 { return Node{static_cast<std::string>(x)}; }

◆ decode()

template<typename T >
static bool YAML::convert< T >::decode ( const Node &  node,
T &  x 
)
inlinestatic

Deserialization: Converts a YAML::Node to any SMASH-readable data type and returns whether or not this operation was successful.

Parameters
[in]nodeYAML::Node that is to be converted.
[in]xValue that the YAML:Node is cast to.
Returns
True in case conversion was successful.

Definition at line 55 of file configuration.h.

55  {
56  if (!node.IsScalar()) {
57  return false;
58  } else {
59  x = static_cast<T>(node.Scalar());
60  return true;
61  }
62  }

The documentation for this struct was generated from the following file: