The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
mha_parser.cpp File Reference

Namespaces

 MHAParser
 Name space for the openMHA-Parser configuration language.
 
 MHAParser::StrCnv
 String converter namespace.
 

Macros

#define MHAPLATFORM   "undefined-linux"
 

Functions

int MHAParser::get_precision ()
 
int MHAParser::StrCnv::num_brackets (const std::string &s)
 count number of brackets More...
 
int MHAParser::StrCnv::bracket_balance (const std::string &s)
 
static std::ostream & write_float (std::ostream &o, const float &f)
 
static std::string parse_1_float (const std::string &s, mha_real_t &v)
 This internal function parses a floating point number from the beginning of a string. More...
 
static void check_parenthesis_complex (const std::string &str)
 This function checks for unbalanced parenthesis in the string containing complex number. More...
 
static int check_sign_complex (const std::string &str)
 This function checks for valid sign (b/w real & img. More...
 
static std::string parse_1_complex (const std::string &s, mha_complex_t &v)
 This internal function parses a complex number from the beginning of a string. More...
 

Macro Definition Documentation

◆ MHAPLATFORM

#define MHAPLATFORM   "undefined-linux"

Function Documentation

◆ write_float()

static std::ostream& write_float ( std::ostream &  o,
const float &  f 
)
inlinestatic

◆ parse_1_float()

static std::string parse_1_float ( const std::string &  s,
mha_real_t v 
)
static

This internal function parses a floating point number from the beginning of a string.

Parameters
sThe string to parse
Precondition
s.size() > 0
Parameters
vThe float variable to fill with a value
Returns
The rest of the string.

◆ check_parenthesis_complex()

static void check_parenthesis_complex ( const std::string &  str)
static

This function checks for unbalanced parenthesis in the string containing complex number.

Parameters
strThe string to check. This function returns normally only when the string starts with an opening bracket and ends with a closing bracket.
Precondition
str.size() > 0
Exceptions
MHA_ErrorMsgThis function raises an error with an appropriate error message if the string does not start with an opening bracket '(' or if it does not end with a closing bracket ')'.

◆ check_sign_complex()

static int check_sign_complex ( const std::string &  str)
static

This function checks for valid sign (b/w real & img.

parts of complex number). It also checks if real part is missing in complex number.

Parameters
strString containing sign and onward imaginary part.
Precondition
str.size() > 0
Exceptions
Thisfunction raises an error if wrong sign (other than '+' or '-') is found. It also raises error, if it finds 'i' instead of sign. This can happen when real part is missing in complex number and 'i' (of imaginary part) is found where sign was expected.
Returns
+1 for '+' sign and -1 for '-' sign

◆ parse_1_complex()

static std::string parse_1_complex ( const std::string &  s,
mha_complex_t v 
)
static

This internal function parses a complex number from the beginning of a string.

Parameters
sThe string to parse
vThe complex variable to fill with a value
Exceptions
MHA_ErrorMsgThis function raises an error if s does not have characters except spaces, tabs etc
Returns
The rest of the string.