NCBI C++ ToolKit
Namespaces | Classes | Typedefs | Enumerations | Functions
mu Namespace Reference

Namespace for mathematical applications. More...

Namespaces

 Test
 Namespace for test cases.
 

Classes

class  Parser
 Mathematical expressions parser. More...
 
class  ParserBase
 Mathematical expressions parser (base parser engine). More...
 
class  ParserByteCode
 Bytecode implementation of the Math Parser. More...
 
class  ParserCallback
 Encapsulation of prototypes for a numerical parser function. More...
 
class  ParserComplex
 Mathematical expressions parser. More...
 
struct  STATIC_ASSERTION_FAILURE
 Static type checks. More...
 
struct  STATIC_ASSERTION_FAILURE< true >
 
class  ParserErrorMsg
 A class that handles the error messages. More...
 
class  ParserError
 Error class of the parser. More...
 
class  ParserInt
 Mathematical expressions parser. More...
 
class  ParserStack
 Parser stack implementation. More...
 
class  ParserToken
 Encapsulation of the data for a single formula token. More...
 
class  ParserTokenReader
 Token reader for the ParserBase class. More...
 

Typedefs

typedef std::map< string_type, ParserCallbackfunmap_type
 Container for Callback objects. More...
 
typedef double value_type
 The numeric datatype used by the parser. More...
 
typedef std::string string_type
 The stringtype used by the parser. More...
 
typedef long bytecode_type
 The bytecode type used by the parser. More...
 
typedef string_type::value_type char_type
 The character type used by the parser. More...
 
typedef std::basic_stringstream< char_type, std::char_traits< char_type >, std::allocator< char_type > > stringstream_type
 Typedef for easily using stringstream that respect the parser stringtype. More...
 
typedef std::map< string_type, value_type * > varmap_type
 Type used for storing variables. More...
 
typedef std::map< string_type, value_typevalmap_type
 Type used for storing constants. More...
 
typedef std::map< string_type, std::size_t > strmap_type
 Type for assigning a string name to an index in the internal string table. More...
 
typedef value_type(* fun_type0) ()
 Callback type used for functions without arguments. More...
 
typedef value_type(* fun_type1) (value_type)
 Callback type used for functions with a single arguments. More...
 
typedef value_type(* fun_type2) (value_type, value_type)
 Callback type used for functions with two arguments. More...
 
typedef value_type(* fun_type3) (value_type, value_type, value_type)
 Callback type used for functions with three arguments. More...
 
typedef value_type(* fun_type4) (value_type, value_type, value_type, value_type)
 Callback type used for functions with four arguments. More...
 
typedef value_type(* fun_type5) (value_type, value_type, value_type, value_type, value_type)
 Callback type used for functions with five arguments. More...
 
typedef value_type(* multfun_type) (const value_type *, int)
 Callback type used for functions with a variable argument list. More...
 
typedef value_type(* strfun_type1) (const char_type *)
 Callback type used for functions taking a string as an argument. More...
 
typedef value_type(* strfun_type2) (const char_type *, value_type)
 Callback type used for functions taking a string and a value as arguments. More...
 
typedef value_type(* strfun_type3) (const char_type *, value_type, value_type)
 Callback type used for functions taking a string and two values as arguments. More...
 
typedef int(* identfun_type) (const char_type *sExpr, int *nPos, value_type *fVal)
 Callback used for functions that identify values in a string. More...
 
typedef value_type *(* facfun_type) (const char_type *, void *)
 Callback used for variable creation factory functions. More...
 
typedef char MAP_TYPE_CANT_BE_UNSIGNED[sizeof(STATIC_ASSERTION_FAILURE< bytecode_type(-1)< 0 >)]
 This is a static typecheck. More...
 

Enumerations

enum  ECmdCode {
  cmLE = 0 , cmGE = 1 , cmNEQ = 2 , cmEQ = 3 ,
  cmLT = 4 , cmGT = 5 , cmADD = 6 , cmSUB = 7 ,
  cmMUL = 8 , cmDIV = 9 , cmPOW = 10 , cmAND = 11 ,
  cmOR = 12 , cmXOR = 13 , cmASSIGN = 14 , cmBO = 15 ,
  cmBC = 16 , cmARG_SEP , cmVAR , cmVAL ,
  cmFUNC , cmFUNC_STR , cmSTRING , cmOPRT_BIN ,
  cmOPRT_POSTFIX , cmOPRT_INFIX , cmEND , cmUNKNOWN
}
 Bytecode values. More...
 
enum  ETypeCode { tpSTR = 0 , tpDBL = 1 , tpVOID = 2 }
 Types internally used by the parser. More...
 
enum  EPrec {
  prLOGIC = 1 , prCMP = 2 , prADD_SUB = 3 , prMUL_DIV = 4 ,
  prPOW = 5 , prINFIX = 4 , prPOSTFIX = 4
}
 Parser operator precedence values. More...
 
enum  EErrorCodes {
  ecUNEXPECTED_OPERATOR = 0 , ecUNASSIGNABLE_TOKEN = 1 , ecUNEXPECTED_EOF = 2 , ecUNEXPECTED_ARG_SEP = 3 ,
  ecUNEXPECTED_ARG = 4 , ecUNEXPECTED_VAL = 5 , ecUNEXPECTED_VAR = 6 , ecUNEXPECTED_PARENS = 7 ,
  ecUNEXPECTED_STR = 8 , ecSTRING_EXPECTED = 9 , ecVAL_EXPECTED = 10 , ecMISSING_PARENS = 11 ,
  ecUNEXPECTED_FUN = 12 , ecUNTERMINATED_STRING = 13 , ecTOO_MANY_PARAMS = 14 , ecTOO_FEW_PARAMS = 15 ,
  ecOPRT_TYPE_CONFLICT = 16 , ecSTR_RESULT = 17 , ecINVALID_NAME = 18 , ecBUILTIN_OVERLOAD = 19 ,
  ecINVALID_FUN_PTR = 20 , ecINVALID_VAR_PTR = 21 , ecEMPTY_EXPRESSION = 22 , ecNAME_CONFLICT = 23 ,
  ecOPT_PRI = 24 , ecDOMAIN_ERROR = 25 , ecDIV_BY_ZERO = 26 , ecGENERIC = 27 ,
  ecLOCALE = 28 , ecINTERNAL_ERROR = 29 , ecCOUNT , ecUNDEFINED = -1
}
 Error codes. More...
 

Functions

std::ostream & console ()
 Encapsulate cout. More...
 
std::istream & console_in ()
 Encapsulate cin. More...
 

Detailed Description

Namespace for mathematical applications.

Typedef Documentation

◆ bytecode_type

typedef long mu::bytecode_type

The bytecode type used by the parser.

The bytecode type depends on the value_type.

Definition at line 240 of file muParserDef.h.

◆ char_type

typedef string_type::value_type mu::char_type

The character type used by the parser.

Depends on wether UNICODE is used or not.

Definition at line 246 of file muParserDef.h.

◆ facfun_type

typedef value_type*(* mu::facfun_type) (const char_type *, void *)

Callback used for variable creation factory functions.

Definition at line 300 of file muParserDef.h.

◆ fun_type0

typedef value_type(* mu::fun_type0) ()

Callback type used for functions without arguments.

Definition at line 267 of file muParserDef.h.

◆ fun_type1

typedef value_type(* mu::fun_type1) (value_type)

Callback type used for functions with a single arguments.

Definition at line 270 of file muParserDef.h.

◆ fun_type2

typedef value_type(* mu::fun_type2) (value_type, value_type)

Callback type used for functions with two arguments.

Definition at line 273 of file muParserDef.h.

◆ fun_type3

typedef value_type(* mu::fun_type3) (value_type, value_type, value_type)

Callback type used for functions with three arguments.

Definition at line 276 of file muParserDef.h.

◆ fun_type4

typedef value_type(* mu::fun_type4) (value_type, value_type, value_type, value_type)

Callback type used for functions with four arguments.

Definition at line 279 of file muParserDef.h.

◆ fun_type5

Callback type used for functions with five arguments.

Definition at line 282 of file muParserDef.h.

◆ funmap_type

Container for Callback objects.

Definition at line 93 of file muParserCallback.h.

◆ identfun_type

typedef int(* mu::identfun_type) (const char_type *sExpr, int *nPos, value_type *fVal)

Callback used for functions that identify values in a string.

Definition at line 297 of file muParserDef.h.

◆ MAP_TYPE_CANT_BE_UNSIGNED

typedef char mu::MAP_TYPE_CANT_BE_UNSIGNED[sizeof(STATIC_ASSERTION_FAILURE< bytecode_type(-1)< 0 >)]

This is a static typecheck.

If you get a compiler error here you tried to use an unsigned bytecode map type!

Definition at line 317 of file muParserDef.h.

◆ multfun_type

typedef value_type(* mu::multfun_type) (const value_type *, int)

Callback type used for functions with a variable argument list.

Definition at line 285 of file muParserDef.h.

◆ strfun_type1

typedef value_type(* mu::strfun_type1) (const char_type *)

Callback type used for functions taking a string as an argument.

Definition at line 288 of file muParserDef.h.

◆ strfun_type2

typedef value_type(* mu::strfun_type2) (const char_type *, value_type)

Callback type used for functions taking a string and a value as arguments.

Definition at line 291 of file muParserDef.h.

◆ strfun_type3

typedef value_type(* mu::strfun_type3) (const char_type *, value_type, value_type)

Callback type used for functions taking a string and two values as arguments.

Definition at line 294 of file muParserDef.h.

◆ string_type

The stringtype used by the parser.

Depends on wether UNICODE is used or not.

Definition at line 234 of file muParserDef.h.

◆ stringstream_type

typedef std::basic_stringstream<char_type, std::char_traits<char_type>, std::allocator<char_type> > mu::stringstream_type

Typedef for easily using stringstream that respect the parser stringtype.

Definition at line 251 of file muParserDef.h.

◆ strmap_type

typedef std::map<string_type, std::size_t> mu::strmap_type

Type for assigning a string name to an index in the internal string table.

Definition at line 262 of file muParserDef.h.

◆ valmap_type

Type used for storing constants.

Definition at line 259 of file muParserDef.h.

◆ value_type

typedef double mu::value_type

The numeric datatype used by the parser.

Normally this is a floating point type either single or double precision.

Examples
/home/coremake/doxygen/cxx/include/corelib/ncbistr.hpp.

Definition at line 228 of file muParserDef.h.

◆ varmap_type

typedef std::map<string_type, value_type*> mu::varmap_type

Type used for storing variables.

Definition at line 256 of file muParserDef.h.

Enumeration Type Documentation

◆ ECmdCode

Bytecode values.

Attention
The order of the operator entries must match the order in ParserBase::c_DefaultOprt!
Enumerator
cmLE 

Operator item: less or equal.

cmGE 

Operator item: greater or equal.

cmNEQ 

Operator item: not equal.

cmEQ 

Operator item: equals.

cmLT 

Operator item: less than.

cmGT 

Operator item: greater than.

cmADD 

Operator item: add.

cmSUB 

Operator item: subtract.

cmMUL 

Operator item: multiply.

cmDIV 

Operator item: division.

cmPOW 

Operator item: y to the power of ...

cmAND 

Operator item: logical and.

cmOR 

Operator item: logical or.

cmXOR 

Operator item: logical xor.

cmASSIGN 

Operator item: Assignment operator.

cmBO 

Operator item: opening bracket.

cmBC 

Operator item: closing bracket.

cmARG_SEP 

function argument separator

cmVAR 

variable item

cmVAL 

value item

cmFUNC 

Code for a function item.

cmFUNC_STR 

Code for a function with a string parameter.

cmSTRING 

Code for a string token.

cmOPRT_BIN 

user defined binary operator

cmOPRT_POSTFIX 

code for postfix operators

cmOPRT_INFIX 

code for infix operators

cmEND 

end of formula

cmUNKNOWN 

uninitialized item

Definition at line 160 of file muParserDef.h.

◆ EErrorCodes

Error codes.

Enumerator
ecUNEXPECTED_OPERATOR 

Unexpected binary operator found.

ecUNASSIGNABLE_TOKEN 

Token cant be identified.

ecUNEXPECTED_EOF 

Unexpected end of formula. (Example: "2+sin(")

ecUNEXPECTED_ARG_SEP 

An unexpected comma has been found. (Example: "1,23")

ecUNEXPECTED_ARG 

An unexpected argument has been found.

ecUNEXPECTED_VAL 

An unexpected value token has been found.

ecUNEXPECTED_VAR 

An unexpected variable token has been found.

ecUNEXPECTED_PARENS 

Unexpected Parenthesis, opening or closing.

ecUNEXPECTED_STR 

A string has been found at an inapropriate position.

ecSTRING_EXPECTED 

A string function has been called with a different type of argument.

ecVAL_EXPECTED 

A numerical function has been called with a non value type of argument.

ecMISSING_PARENS 

Missing parens. (Example: "3*sin(3")

ecUNEXPECTED_FUN 

Unexpected function found. (Example: "sin(8)cos(9)")

ecUNTERMINATED_STRING 

unterminated string constant. (Example: "3*valueof("hello)")

ecTOO_MANY_PARAMS 

Too many function parameters.

ecTOO_FEW_PARAMS 

Too few function parameters. (Example: "ite(1<2,2)")

ecOPRT_TYPE_CONFLICT 

binary operators may only be applied to value items of the same type

ecSTR_RESULT 

result is a string

ecINVALID_NAME 

Invalid function, variable or constant name.

ecBUILTIN_OVERLOAD 

Trying to overload builtin operator.

ecINVALID_FUN_PTR 

Invalid callback function pointer.

ecINVALID_VAR_PTR 

Invalid variable pointer.

ecEMPTY_EXPRESSION 

The Expression is empty.

ecNAME_CONFLICT 

Name conflict.

ecOPT_PRI 

Invalid operator priority.

ecDOMAIN_ERROR 

catch division by zero, sqrt(-1), log(0) (currently unused)

ecDIV_BY_ZERO 

Division by zero (currently unused)

ecGENERIC 

Generic error.

ecLOCALE 

Conflict with current locale.

ecINTERNAL_ERROR 

Internal error of any kind.

ecCOUNT 

This is no error code, It just stores just the total number of error codes.

ecUNDEFINED 

Undefined message, placeholder to detect unassigned error messages.

Definition at line 46 of file muParserError.h.

◆ EPrec

enum mu::EPrec

Parser operator precedence values.

Enumerator
prLOGIC 

logic operators

prCMP 

comparsion operators

prADD_SUB 

addition

prMUL_DIV 

multiplication/division

prPOW 

power operator priority (highest)

prINFIX 

Signs have a higher priority than ADD_SUB, but lower than power operator.

prPOSTFIX 

Postfix operator priority (currently unused)

Definition at line 207 of file muParserDef.h.

◆ ETypeCode

Types internally used by the parser.

Enumerator
tpSTR 

String type (Function arguments and constants only, no string variables)

tpDBL 

Floating point variables.

tpVOID 

Undefined type.

Definition at line 198 of file muParserDef.h.

Function Documentation

◆ console()

std::ostream& mu::console ( )
inline

◆ console_in()

std::istream& mu::console_in ( )
inline

Encapsulate cin.

Used for supporting UNICODE more easily.

Definition at line 148 of file muParserDef.h.

Modified on Fri Dec 08 08:23:11 2023 by modify_doxy.py rev. 669887