Classes | |
struct | IsStdMap |
A utility type to be specialized to check if a type is a std::map . More... | |
struct | IsStdMap< std::map< MapKey, MapValue > > |
A specialization of IsStdMap<T> for cases where the boolean value should be set to true . More... | |
Functions | |
void | descend_one_existing_level (std::optional< YAML::Node > &node, std::string_view key) |
Reset the passed in node to that one at the provided key, which is expected to exist in the node. More... | |
YAML::Node | remove_empty_maps (YAML::Node root) |
Remove all empty maps of a YAML::Node. More... | |
YAML::Node | operator|= (YAML::Node a, const YAML::Node &b) |
Merge two YAML::Nodes. More... | |
std::string | join_quoted (std::initializer_list< const char * > keys) |
Build a string with a list of keys as specified in the code. More... | |
void | fill_list_of_labels_per_key_in_yaml_tree (const YAML::Node &root_node, std::vector< KeyLabels > &list, KeyLabels &new_list_entry) |
Implementation of the algorithm to translate a YAML tree into lists of labels, each identifying a key from the YAML root node. More... | |
auto | get_list_of_labels_per_key_in_yaml_tree (const YAML::Node &root_node) |
Create a list of lists of key labels present in the passed YAML node considered to be the root one of a YAML tree. More... | |
auto | collect_input_keys_taken_as_maps () |
Extract from the InputKeys database the labels of keys that have a std::map as type. More... | |
void | adjust_list_of_labels_dealing_with_keys_taken_as_maps (std::vector< KeyLabels > &list_of_input_key_labels) |
Remove last labels of keys that are taken as maps in SMASH and remove duplicates from the resulting list. More... | |
Configuration::Is | validate_key (const KeyLabels &labels) |
Given some YAML labels (assumed to be in order from the top section), it is checked whether any valid SMASH key with the same key exists. More... | |
void | accumulate_validation (Configuration::Is &result_so_far, Configuration::Is new_value) |
Utility function to accumulate validation results of keys. More... | |
void smash::anonymous_namespace{configuration.cc}::descend_one_existing_level | ( | std::optional< YAML::Node > & | node, |
std::string_view | key | ||
) |
Reset the passed in node to that one at the provided key, which is expected to exist in the node.
If this is not the case, the node is set to std::nullopt
.
[in,out] | node | An optional node to be reset. |
[in] | key | The key expected to exist in the given node. |
Definition at line 38 of file configuration.cc.
YAML::Node smash::anonymous_namespace{configuration.cc}::remove_empty_maps | ( | YAML::Node | root | ) |
Remove all empty maps of a YAML::Node.
[in] | root | YAML::Node that contains empty maps. |
Definition at line 69 of file configuration.cc.
YAML::Node smash::anonymous_namespace{configuration.cc}::operator|= | ( | YAML::Node | a, |
const YAML::Node & | b | ||
) |
Merge two YAML::Nodes.
[in] | a | YAML::Node into which b is merged. |
[in] | b | YAML::Node that is merged into a. |
Definition at line 93 of file configuration.cc.
std::string smash::anonymous_namespace{configuration.cc}::join_quoted | ( | std::initializer_list< const char * > | keys | ) |
Build a string with a list of keys as specified in the code.
keys | The list of keys. |
std::string
with the desired result. Definition at line 110 of file configuration.cc.
void smash::anonymous_namespace{configuration.cc}::fill_list_of_labels_per_key_in_yaml_tree | ( | const YAML::Node & | root_node, |
std::vector< KeyLabels > & | list, | ||
KeyLabels & | new_list_entry | ||
) |
Implementation of the algorithm to translate a YAML tree into lists of labels, each identifying a key from the YAML root node.
Since the level of nesting sections in a YAML input file is arbitrary, this is a typical task to be solved using recursion. The main idea here is to take advantage of YAML functionality and in particular of the possibility to iterate over trees and test for nature of a node (is it a Map or not?). Roughly speaking, from the tree top-level all upmost nodes are extracted and for each of them, recursively, the same procedure is done over and over again if they are maps. If a non-map node is found, i.e. a key value is found, then recursion ends and a new entry is added to list
.
[in] | root_node | The root YAML node to extract from. |
[in,out] | list | The list of lists of labels to be filled. |
[in,out] | new_list_entry | New list of labels in process to be filled during recursion. |
Definition at line 370 of file configuration.cc.
auto smash::anonymous_namespace{configuration.cc}::get_list_of_labels_per_key_in_yaml_tree | ( | const YAML::Node & | root_node | ) |
Create a list of lists of key labels present in the passed YAML node considered to be the root one of a YAML tree.
Given a YAML::Node
, for each key having a value, all labels to reach the given key from the passed node are collected and a std::vector
containing them is built and inserted into the given list. This function is calling the actual implementation preparing auxiliary needed variables.
[in] | root_node | The root node of the YAML tree to be considered. |
std::vector<KeyLabels>
containing the desired information. Definition at line 399 of file configuration.cc.
auto smash::anonymous_namespace{configuration.cc}::collect_input_keys_taken_as_maps | ( | ) |
Extract from the InputKeys
database the labels of keys that have a std::map
as type.
Definition at line 443 of file configuration.cc.
void smash::anonymous_namespace{configuration.cc}::adjust_list_of_labels_dealing_with_keys_taken_as_maps | ( | std::vector< KeyLabels > & | list_of_input_key_labels | ) |
Remove last labels of keys that are taken as maps in SMASH and remove duplicates from the resulting list.
The keys that are taken as maps in SMASH are here collected using the database InputKeys
and the list of keys contained in the configuration must be adjusted by hand. This is a corner case, since YAML nodes that are maps are by definition sections and cannot be distinguished from keys "with a map value" in the recursive process to create the list of key labels.
[in,out] | list_of_input_key_labels | The list of key labels to adjust. |
Definition at line 479 of file configuration.cc.
Configuration::Is smash::anonymous_namespace{configuration.cc}::validate_key | ( | const KeyLabels & | labels | ) |
Given some YAML labels (assumed to be in order from the top section), it is checked whether any valid SMASH key with the same key exists.
All possible checks are done in a way such that the user is informed about
[in] | labels | The series of labels identifying the key. |
Configuration::Is::Valid
if the key is valid; Configuration::Is::Deprecated
if the key is Deprecated and Configuration::Is::Invalid
if the key is invalid. Definition at line 515 of file configuration.cc.
void smash::anonymous_namespace{configuration.cc}::accumulate_validation | ( | Configuration::Is & | result_so_far, |
Configuration::Is | new_value | ||
) |
Utility function to accumulate validation results of keys.
This is basically the logic needed to make a full validation of a configuration, considered that we have three possible states. It extend the logical AND between two boolean values.
[in,out] | result_so_far | Status of the configuration so far to be combined with the new key state. |
[in] | new_value | New key state to be considered. |
Definition at line 567 of file configuration.cc.