Version: SMASH-2.0
smash::anonymous_namespace{configuration.cc} Namespace Reference

Functions

YAML::Node find_node_at (YAML::Node node, std::initializer_list< const char * > keys)
 Finds a node, copies its structure and replaces the previous keys by the newly provided keys. More...
 
YAML::Node remove_empty_maps (YAML::Node root)
 Removes all empty maps of a YAML::Node. More...
 
YAML::Node operator|= (YAML::Node a, const YAML::Node &b)
 Merge two YAML::Nodes. More...
 

Function Documentation

◆ find_node_at()

YAML::Node smash::anonymous_namespace{configuration.cc}::find_node_at ( YAML::Node  node,
std::initializer_list< const char * >  keys 
)

Finds a node, copies its structure and replaces the previous keys by the newly provided keys.

Parameters
[in]nodeYAML::node whose structure will be copied and whose key values will be replaced.
[in]keysKeys that will replace the previous keys in the copied node.
Returns
Node with the same structure as the input node but with updated keys.

Definition at line 36 of file configuration.cc.

37  {
38  assert(keys.size() > 0);
39  for (auto key : keys) {
40  // see comment in take on Node::reset
41  node.reset(node[key]);
42  }
43  return node;
44 }
Here is the caller graph for this function:

◆ remove_empty_maps()

YAML::Node smash::anonymous_namespace{configuration.cc}::remove_empty_maps ( YAML::Node  root)

Removes all empty maps of a YAML::Node.

Parameters
[in]rootYAML::Node that contains empty maps.
Returns
YAML::Node from above without empty maps.

Definition at line 52 of file configuration.cc.

52  {
53  if (root.IsMap()) {
54  std::vector<std::string> to_remove(root.size());
55  for (auto n : root) {
56  remove_empty_maps(n.second);
57  if ((n.second.IsMap() || n.second.IsSequence()) && n.second.size() == 0) {
58  to_remove.emplace_back(n.first.Scalar());
59  }
60  }
61  for (const auto &key : to_remove) {
62  root.remove(key);
63  }
64  }
65  return root;
66 }
Here is the caller graph for this function:

◆ operator|=()

YAML::Node smash::anonymous_namespace{configuration.cc}::operator|= ( YAML::Node  a,
const YAML::Node &  b 
)

Merge two YAML::Nodes.

Parameters
[in]aYAML::Node into which b is merged.
[in]bYAML::Node that is merged into a.
Returns
YAML::Node which is the merge of a and b.

Definition at line 75 of file configuration.cc.

75  {
76  if (b.IsMap()) {
77  for (auto n0 : b) {
78  a[n0.first.Scalar()] |= n0.second;
79  }
80  } else {
81  a = b;
82  }
83  return a;
84 }
smash::anonymous_namespace{configuration.cc}::remove_empty_maps
YAML::Node remove_empty_maps(YAML::Node root)
Removes all empty maps of a YAML::Node.
Definition: configuration.cc:52
smash::pdg::n
constexpr int n
Neutron.
Definition: pdgcode_constants.h:30