Iguana 0.0.0
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
iguana::YAMLReader Class Reference

#include <YAMLReader.h>

Detailed Description

A YAMLReader based on yaml-cpp.

Definition at line 14 of file YAMLReader.h.

Public Types

using node_finder_t = std::function<YAML::Node(const YAML::Node)>
 A function f : Node A -> Node B which searches YAML::Node A for a specific YAML::Node B, returning it.
 
using node_id_t = std::variant<std::string, node_finder_t>
 
using node_path_t = std::deque<node_id_t>
 Representation of a path of YAML::Nodes in a YAML::Node tree, e.g., in a YAML file.
 

Public Member Functions

 YAMLReader (std::string_view name="config")
 
void LoadFiles ()
 Parse the YAML files added by ConfigFileReader::AddFile
 
template<typename SCALAR >
std::optional< SCALAR > GetScalar (YAML::Node node)
 
template<typename SCALAR >
std::optional< SCALAR > GetScalar (node_path_t node_path)
 
template<typename SCALAR >
std::optional< std::vector< SCALAR > > GetVector (YAML::Node node)
 
template<typename SCALAR >
std::optional< std::vector< SCALAR > > GetVector (node_path_t node_path)
 
template<typename SCALAR >
node_finder_t InRange (std::string const &key, SCALAR val)
 
- Public Member Functions inherited from iguana::ConfigFileReader
 ConfigFileReader (std::string_view name="config")
 
void AddDirectory (std::string const &dir)
 
void AddFile (std::string const &name)
 
void PrintDirectories (Logger::Level const level=Logger::info)
 
std::string FindFile (std::string const &name)
 
- Public Member Functions inherited from iguana::Object
 Object (std::string_view name="", Logger::Level lev=Logger::DEFAULT_LEVEL)
 
std::unique_ptr< Logger > & Log ()
 
void SetName (std::string_view name)
 
std::string GetName () const
 
void SetLogLevel (std::string_view lev)
 
void SetLogLevel (Logger::Level const lev)
 
std::unique_ptr< Logger > & GetLog ()
 

Additional Inherited Members

- Static Public Member Functions inherited from iguana::ConfigFileReader
static std::string GetConfigInstallationPrefix ()
 
static std::string ConvertAlgoNameToConfigName (std::string_view algo_name, std::string_view ext="yaml")
 
- Protected Attributes inherited from iguana::ConfigFileReader
std::deque< std::string > m_directories
 Stack of directories to search for a file.
 
std::deque< std::string > m_files
 Stack of file names to parse.
 
- Protected Attributes inherited from iguana::Object
std::string m_name
 The name of this object.
 
std::unique_ptr< Loggerm_log
 Logger instance for this object
 
Inheritance diagram for iguana::YAMLReader:
Inheritance graph

Member Typedef Documentation

◆ node_finder_t

using iguana::YAMLReader::node_finder_t = std::function<YAML::Node(const YAML::Node)>

A function f : Node A -> Node B which searches YAML::Node A for a specific YAML::Node B, returning it.

Definition at line 20 of file YAMLReader.h.

◆ node_id_t

using iguana::YAMLReader::node_id_t = std::variant<std::string, node_finder_t>

Variant for identifying a YAML::Node:

  • std::string: the key name of the node
  • node_finder_t: how to find the node

Definition at line 25 of file YAMLReader.h.

◆ node_path_t

Representation of a path of YAML::Nodes in a YAML::Node tree, e.g., in a YAML file.

Definition at line 28 of file YAMLReader.h.

Constructor & Destructor Documentation

◆ YAMLReader()

iguana::YAMLReader::YAMLReader ( std::string_view name = "config")
inline
Parameters
nameof this reader (for Logger)

Definition at line 31 of file YAMLReader.h.

◆ ~YAMLReader()

iguana::YAMLReader::~YAMLReader ( )
inline

Definition at line 34 of file YAMLReader.h.

Member Function Documentation

◆ GetScalar() [1/2]

template<typename SCALAR >
std::optional< SCALAR > iguana::YAMLReader::GetScalar ( node_path_t node_path)

Read a scalar value from a YAML::Node path; searches all currently loaded config files.

Parameters
node_paththe YAML::Node path
Returns
the scalar, if found

◆ GetScalar() [2/2]

template<typename SCALAR >
std::optional< SCALAR > iguana::YAMLReader::GetScalar ( YAML::Node node)

Read a scalar value from a YAML::Node

Parameters
nodethe YAML::Node to read
Returns
the scalar, if found

◆ GetVector() [1/2]

template<typename SCALAR >
std::optional< std::vector< SCALAR > > iguana::YAMLReader::GetVector ( node_path_t node_path)

Read a vector value from a YAML::Node path; searches all currently loaded config files.

Parameters
node_paththe YAML::Node path
Returns
the vector, if found

◆ GetVector() [2/2]

template<typename SCALAR >
std::optional< std::vector< SCALAR > > iguana::YAMLReader::GetVector ( YAML::Node node)

Read a vector value from a YAML::Node

Parameters
nodethe YAML::Node to read
Returns
the vector, if found

◆ InRange()

template<typename SCALAR >
node_finder_t iguana::YAMLReader::InRange ( std::string const & key,
SCALAR val )

Create a function to search a YAML::Node for a sub-YAML::Node such that the scalar val is within a range specified by key

Parameters
keythe key of the sub-YAML::Node to use as the range (its value must be a 2-vector)
valthe scalar value to check
Returns
the search function

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