SigPack - the C++ signal processing library
sp::parser Class Reference

#include <parser.h>

Collaboration diagram for sp::parser:
Collaboration graph

Public Member Functions

 parser (const std::string &fname)
 
 ~parser ()
 
template<typename T >
getParam (const std::string key, const T def_val)
 
std::string getString (const std::string key, const std::string def_val)
 
template<typename T >
arma::Col< T > getCol (const std::string key, const arma::Col< T > def_val)
 
arma::cx_vec getCxCol (const std::string key, const arma::cx_vec def_val)
 
template<typename T >
arma::Row< T > getRow (const std::string key, const arma::Row< T > def_val)
 
arma::cx_rowvec getCxRow (const std::string key, const arma::cx_rowvec def_val)
 
template<typename T >
arma::Mat< T > getMat (const std::string key, const arma::Mat< T > def_val)
 
arma::cx_mat getCxMat (const std::string key, const arma::cx_mat def_val)
 

Private Member Functions

bool valid_key (const std::string &key)
 
std::complex< double > parse_cx (std::string str)
 

Private Attributes

std::map< std::string, std::string > par_map
 

Detailed Description

Implements parsing from text file for different types

Examples:
parser.cpp.

Definition at line 20 of file parser.h.

Constructor & Destructor Documentation

◆ parser()

sp::parser::parser ( const std::string &  fname)
inline

Constructor.

Opens parameter file and puts the key and value in the map structure

Parameters
fnameParameter file name

Definition at line 82 of file parser.h.

References par_map, and wrn_handler.

◆ ~parser()

sp::parser::~parser ( )
inline

Destructor.

Definition at line 159 of file parser.h.

Member Function Documentation

◆ getCol()

template<typename T >
arma::Col<T> sp::parser::getCol ( const std::string  key,
const arma::Col< T >  def_val 
)
inline

Col type get function.

Returns
Col value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 205 of file parser.h.

References par_map, and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getCxCol()

arma::cx_vec sp::parser::getCxCol ( const std::string  key,
const arma::cx_vec  def_val 
)
inline

cx_vec type get function.

Returns
cx_vec value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 233 of file parser.h.

References par_map, parse_cx(), and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getCxMat()

arma::cx_mat sp::parser::getCxMat ( const std::string  key,
const arma::cx_mat  def_val 
)
inline

cx_mat type get function.

Returns
cx_mat value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 357 of file parser.h.

References par_map, parse_cx(), and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getCxRow()

arma::cx_rowvec sp::parser::getCxRow ( const std::string  key,
const arma::cx_rowvec  def_val 
)
inline

cx_rowvec type get function.

Returns
cx_rowvec value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file

Definition at line 288 of file parser.h.

References par_map, parse_cx(), and valid_key().

Here is the call graph for this function:

◆ getMat()

template<typename T >
arma::Mat<T> sp::parser::getMat ( const std::string  key,
const arma::Mat< T >  def_val 
)
inline

Mat type get function.

Returns
Mat value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 315 of file parser.h.

References par_map, and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getParam()

template<typename T >
T sp::parser::getParam ( const std::string  key,
const T  def_val 
)
inline

Generic type get function.

Returns
Value of type T, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 168 of file parser.h.

References par_map, and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getRow()

template<typename T >
arma::Row<T> sp::parser::getRow ( const std::string  key,
const arma::Row< T >  def_val 
)
inline

Row type get function.

Returns
Row value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 260 of file parser.h.

References par_map, and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ getString()

std::string sp::parser::getString ( const std::string  key,
const std::string  def_val 
)
inline

String type get function.

Returns
String value, if it not exists in file the default value is returned
Parameters
keyParameter name
def_valDefault value if key was not found in file
Examples:
parser.cpp.

Definition at line 188 of file parser.h.

References par_map, and valid_key().

Referenced by main().

Here is the call graph for this function:

◆ parse_cx()

std::complex<double> sp::parser::parse_cx ( std::string  str)
inlineprivate

Parse complex value.

String may be in format e.g. "1+1i","1+1j" or entirely real or imaginary "1", "1i" or "1j"

Returns
Complex value
Parameters
strComplex notation string

Definition at line 49 of file parser.h.

References err_handler.

Referenced by getCxCol(), getCxMat(), and getCxRow().

◆ valid_key()

bool sp::parser::valid_key ( const std::string &  key)
inlineprivate

Check if key is valid.

Returns
TRUE if key is valid FALSE otherwise
Parameters
keyKey string

Definition at line 31 of file parser.h.

References par_map.

Referenced by getCol(), getCxCol(), getCxMat(), getCxRow(), getMat(), getParam(), getRow(), and getString().

Member Data Documentation

◆ par_map

std::map<std::string, std::string> sp::parser::par_map
private

Map structure to store parameter and value.

Definition at line 24 of file parser.h.

Referenced by getCol(), getCxCol(), getCxMat(), getCxRow(), getMat(), getParam(), getRow(), getString(), parser(), and valid_key().


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