The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHAParser::StrCnv Namespace Reference

String converter namespace. More...

Functions

int num_brackets (const std::string &s)
 count number of brackets More...
 
int bracket_balance (const std::string &s)
 
void str2val (const std::string &, bool &)
 Convert from string. More...
 
void str2val (const std::string &, float &)
 Convert from string. More...
 
void str2val (const std::string &, mha_complex_t &)
 Convert from string. More...
 
void str2val (const std::string &, int &)
 Convert from string. More...
 
void str2val (const std::string &, keyword_list_t &)
 Convert from string. More...
 
void str2val (const std::string &, std::string &)
 Convert from string. More...
 
template<class arg_t >
void str2val (const std::string &s, std::vector< arg_t > &val)
 Converter for vector types. More...
 
template<>
void str2val< mha_real_t > (const std::string &s, std::vector< mha_real_t > &v)
 Converter for vector<mha_real_t> with Matlab-style expansion. More...
 
template<class arg_t >
void str2val (const std::string &s, std::vector< std::vector< arg_t > > &val)
 Converter for matrix types. More...
 
std::string val2str (const bool &)
 Convert to string. More...
 
std::string val2str (const float &)
 Convert to string. More...
 
std::string val2str (const mha_complex_t &)
 Convert to string. More...
 
std::string val2str (const int &)
 Convert to string. More...
 
std::string val2str (const keyword_list_t &)
 Convert to string. More...
 
std::string val2str (const std::string &)
 Convert to string. More...
 
std::string val2str (const std::vector< float > &)
 Convert to string. More...
 
std::string val2str (const std::vector< mha_complex_t > &)
 Convert to string. More...
 
std::string val2str (const std::vector< int > &)
 Convert to string. More...
 
std::string val2str (const std::vector< std::vector< int > > &)
 Convert to string. More...
 
std::string val2str (const std::vector< std::string > &)
 Convert to string. More...
 
std::string val2str (const std::vector< std::vector< float > > &)
 Convert to string. More...
 
std::string val2str (const std::vector< std::vector< mha_complex_t > > &)
 Convert to string. More...
 

Detailed Description

String converter namespace.

The functions defined in this namespace manage the conversions from C++ variables to strings and back. It was tried to keep a matlab compatible string format for vectors and vectors of vectors.

Function Documentation

◆ num_brackets()

int MHAParser::StrCnv::num_brackets ( const std::string &  s)

count number of brackets

Return number of brackets according to layer depth (vector:2, matrix:4, etc)

Parameters
sString
Returns
Number of brackets, or -1 for empty string, or -2 for invalid brackets

◆ bracket_balance()

int MHAParser::StrCnv::bracket_balance ( const std::string &  s)

◆ str2val() [1/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
bool &  v 
)

Convert from string.

◆ str2val() [2/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
float &  v 
)

Convert from string.

◆ str2val() [3/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
mha_complex_t v 
)

Convert from string.

◆ str2val() [4/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
int &  v 
)

Convert from string.

◆ str2val() [5/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
MHAParser::keyword_list_t v 
)

Convert from string.

◆ str2val() [6/8]

void MHAParser::StrCnv::str2val ( const std::string &  s,
std::string &  v 
)

Convert from string.

◆ str2val() [7/8]

template<class arg_t >
void MHAParser::StrCnv::str2val ( const std::string &  s,
std::vector< arg_t > &  val 
)

Converter for vector types.

◆ str2val< mha_real_t >()

template<>
void MHAParser::StrCnv::str2val< mha_real_t > ( const std::string &  s,
std::vector< mha_real_t > &  v 
)

Converter for vector<mha_real_t> with Matlab-style expansion.

◆ str2val() [8/8]

template<class arg_t >
void MHAParser::StrCnv::str2val ( const std::string &  s,
std::vector< std::vector< arg_t > > &  val 
)

Converter for matrix types.

◆ val2str() [1/13]

std::string MHAParser::StrCnv::val2str ( const bool &  v)

Convert to string.

◆ val2str() [2/13]

std::string MHAParser::StrCnv::val2str ( const float &  v)

Convert to string.

◆ val2str() [3/13]

std::string MHAParser::StrCnv::val2str ( const mha_complex_t v)

Convert to string.

◆ val2str() [4/13]

std::string MHAParser::StrCnv::val2str ( const int &  v)

Convert to string.

◆ val2str() [5/13]

std::string MHAParser::StrCnv::val2str ( const keyword_list_t v)

Convert to string.

◆ val2str() [6/13]

std::string MHAParser::StrCnv::val2str ( const std::string &  v)

Convert to string.

◆ val2str() [7/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< float > &  v)

Convert to string.

◆ val2str() [8/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< mha_complex_t > &  v)

Convert to string.

◆ val2str() [9/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< int > &  v)

Convert to string.

◆ val2str() [10/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< std::vector< int > > &  v)

Convert to string.

◆ val2str() [11/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< std::string > &  v)

Convert to string.

◆ val2str() [12/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< std::vector< float > > &  v)

Convert to string.

◆ val2str() [13/13]

std::string MHAParser::StrCnv::val2str ( const std::vector< std::vector< mha_complex_t > > &  v)

Convert to string.