A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/muParserBase_8cpp_source.html below:

NCBI C++ ToolKit: src/gui/utils/muparser/muParserBase.cpp Source File

37 #define wxT(x) MUP_T(x) 53  const char_type

* ParserBase::c_DefaultOprt[] =

60  wxT

(

"("

),

wxT

(

")"

), 0

68

ParserBase::ParserBase()

82

,m_bUseByteCode(

true

)

106

,m_bUseByteCode(

true

)

107

,m_bBuiltInOp(

true

)

142  if

(&a_Parser==

this

)

235

a_Storage[a_strName] = a_Callback;

247  if

( !a_sName.length() ||

248

(a_sName.find_first_not_of(a_szCharSet)!=string_type::npos) ||

249

(a_sName[0]>=

'0'

&& a_sName[0]<=

'9'

))

484  case cmEND

:

return

-5;

487  case cmBC

:

return

-2;

575  const

std::vector<token_type> &a_vArg)

const 578  int

iArgCount = (unsigned)a_vArg.size();

592

std::vector<value_type> vArg(iArgCount);

593  for

(

int i

=0;

i

<iArgCount; ++

i

)

594

vArg[iArgCount-(

i

+1)] = a_vArg[

i

].GetVal();

601  case

1: valTok.

SetVal

( ((

fun_type1

)pFunc)(a_vArg[0].GetVal()) );

break

;

603

a_vArg[0].GetVal()) );

break

;

606

a_vArg[0].GetVal()) );

break

;

610

a_vArg[0].GetVal()) );

break

;

615

a_vArg[0].GetVal()) );

break

;

625  for

(

int i

=0; (bVolatile==

false

) && (

i

<iArgCount); ++

i

)

631  #if defined(_MSC_VER) 632  #pragma warning( disable : 4311 ) 652  #if defined(_MSC_VER) 653  #pragma warning( default : 4311 ) 663  const

std::vector<token_type> &a_vArg)

const 665  if

(a_vArg.back().GetCode()!=

cmSTRING

)

669  int

iArgCount = (unsigned)a_vArg.size();

678  case

0: valTok.

SetVal

( ((

strfun_type1

)pFunc)(a_vArg[0].GetAsString().c_str()) );

break

;

680

a_vArg[0].GetVal()) );

break

;

683

a_vArg[0].GetVal()) );

break

;

698  for

(

int i

=0; (bVolatile==

false

) && (

i

<iArgCount); ++

i

)

719  int

a_iArgCount)

const 724  if

(a_stOpt.

empty

() || a_stOpt.

top

().GetFuncAddr()==0 )

740  int

iArgNumerical = iArgCount - ((funTok.

GetType

()==

tpSTR

) ? 1 : 0);

745  if

(funTok.

GetArgCount

()>=0 && iArgCount>iArgRequired)

756

std::vector<token_type> stArg;

757  for

(

int i

=0;

i

<iArgNumerical; ++

i

)

759

stArg.push_back( a_stVal.

pop

() );

767

stArg.push_back( a_stVal.

pop

() );

776

a_stVal.

push

( token );

781

a_stVal.

push

( token );

802

valTok2 = a_stVal.

pop

(),

803

optTok = a_stOpt.

pop

(),

806  if

( valTok1.

GetType

()!=valTok2.GetType() ||

813  switch

(optTok.GetCode())

816  case cmAND

: resTok.SetVal( (

int

)x & (

int

)y );

break

;

817  case cmOR

: resTok.SetVal( (

int

)x | (

int

)y );

break

;

818  case cmXOR

: resTok.SetVal( (

int

)x ^ (

int

)y );

break

;

819  case cmLT

: resTok.SetVal( x < y );

break

;

820  case cmGT

: resTok.SetVal( x > y );

break

;

821  case cmLE

: resTok.SetVal( x <= y );

break

;

822  case cmGE

: resTok.SetVal( x >= y );

break

;

823  case cmNEQ

: resTok.SetVal( x != y );

break

;

824  case cmEQ

: resTok.SetVal( x == y );

break

;

825  case cmADD

: resTok.SetVal( x + y );

break

;

826  case cmSUB

: resTok.SetVal( x - y );

break

;

827  case cmMUL

: resTok.SetVal( x * y );

break

;

828  case cmDIV

: resTok.SetVal( x / y );

break

;

829  case cmPOW

: resTok.SetVal(pow(x, y));

break

;

835  if

(valTok2.GetCode()!=

cmVAR

)

839

resTok.SetVal( *pVar = y );

840

a_stVal.

push

( resTok );

873

a_stVal.

push

( resTok );

887  #if defined(_MSC_VER) 888  #pragma warning( disable : 4312 ) 910  case cmAND

: Stack[idx] = (

int

)Stack[idx] & (

int

)Stack[idx+1];

goto

__start;

911  case cmOR

: Stack[idx] = (

int

)Stack[idx] | (

int

)Stack[idx+1];

goto

__start;

912  case cmXOR

: Stack[idx] = (

int

)Stack[idx] ^ (

int

)Stack[idx+1];

goto

__start;

913  case cmLE

: Stack[idx] = Stack[idx] <= Stack[idx+1];

goto

__start;

914  case cmGE

: Stack[idx] = Stack[idx] >= Stack[idx+1];

goto

__start;

915  case cmNEQ

: Stack[idx] = Stack[idx] != Stack[idx+1];

goto

__start;

916  case cmEQ

: Stack[idx] = Stack[idx] == Stack[idx+1];

goto

__start;

917  case cmLT

: Stack[idx] = Stack[idx] < Stack[idx+1];

goto

__start;

918  case cmGT

: Stack[idx] = Stack[idx] > Stack[idx+1];

goto

__start;

919  case cmADD

: Stack[idx] += Stack[1+idx];

goto

__start;

920  case cmSUB

: Stack[idx] -= Stack[1+idx];

goto

__start;

921  case cmMUL

: Stack[idx] *= Stack[1+idx];

goto

__start;

922  case cmDIV

: Stack[idx] /= Stack[1+idx];

goto

__start;

923  case cmPOW

: Stack[idx] = pow(Stack[idx], Stack[1+idx]);

goto

__start;

934

Stack[idx] = **pDest = Stack[idx+1];

986  case

3: Stack[idx] = (*(

fun_type3

*)(&

m_pCmdCode

[

i

]))(Stack[idx], Stack[idx+1], Stack[idx+2]);

break

;

987  case

4: Stack[idx] = (*(

fun_type4

*)(&

m_pCmdCode

[

i

]))(Stack[idx], Stack[idx+1], Stack[idx+2], Stack[idx+3]);

break

;

988  case

5: Stack[idx] = (*(

fun_type5

*)(&

m_pCmdCode

[

i

]))(Stack[idx], Stack[idx+1], Stack[idx+2], Stack[idx+3], Stack[idx+4]);

break

;

1008  #if defined(_MSC_VER) 1009  #pragma warning( default : 4312 ) 1036  #if defined(_MSC_VER) 1037  #pragma warning( disable : 4311 ) 1076  if

(stArgCount.

empty

())

1079

++stArgCount.

top

();

1090

--stArgCount.

top

();

1092  while

( stOpt.

size

() && stOpt.

top

().GetCode() !=

cmBO

)

1114  int

iArgCount = stArgCount.

pop

();

1118  if

(iArgCount>1 && ( stOpt.

size

()==0 ||

1148  while

( stOpt.

size

() && stOpt.

top

().GetCode() !=

cmBO

)

1167

stArgCount.

push

(1);

1196  #if defined(MUP_DUMP_STACK) 1198

StackDump(stVal, stOpt);

1206  #if defined(MUP_DUMP_CMDCODE) 1211  if

(stVal.

size

()!=1)

1214  if

(stVal.

top

().GetType()!=

tpDBL

)

1237  #if defined(_MSC_VER) 1238  #pragma warning( default : 4311 ) 1278

varmap_type::iterator item =

m_VarDef

.find(a_strVarName);

1426 #if defined(MUP_DUMP_STACK) | defined(MUP_DUMP_CMDCODE) 1439  while

( !stVal.empty() )

1449  while

( !stOprt.empty() )

1451  if

(stOprt.top().GetCode()<=

cmASSIGN

)

1459  switch

(stOprt.top().GetCode())

1464

<< stOprt.top().GetAsString()

1465

<<

wxT

(

"\"\n"

);

break

;

1467

<< stOprt.top().GetAsString()

1468

<<

wxT

(

"\"\n"

);

break

;

1470

<< stOprt.top().GetAsString()

1471

<<

wxT

(

"\"\n"

);

break

;

1477  default

:

mu::console

() << stOprt.top().GetType() <<

wxT

(

" "

);

break

;

Mathematical expressions parser (base parser engine).

varmap_type m_VarDef

user defind variables.

ParserTokenReader token_reader_type

Typedef for the token reader.

const string_type & GetExpr() const

Retrieve the formula.

value_type ParseValue() const

Return result for constant functions.

const char_type * ValidInfixOprtChars() const

Virtual function that defines the characters allowed in infix operator definitions.

void Assign(const ParserBase &a_Parser)

Copy state of a parser object to this.

const ParserByteCode::map_type * m_pCmdCode

Formula converted to bytecode, points to the data of the bytecode class.

void AddValIdent(identfun_type a_pCallback)

token_type ApplyNumFunc(const token_type &a_FunTok, const std::vector< token_type > &a_vArg) const

static const char_type * c_DefaultOprt[]

Identifiers for built in binary operators.

ParseFunction m_pParseFormula

Pointer to the parser function.

value_type ParseString() const

One of the two main parse functions.

void ApplyBinOprt(ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal) const

void CheckName(const string_type &a_strName, const string_type &a_CharSet) const

Check if a name contains invalid characters.

const varmap_type & GetVar() const

Return a map containing the used variables only.

void Init()

Initialize user defined functions.

stringbuf_type m_vStringBuf

String buffer, used for storing string function arguments.

void AddCallback(const string_type &a_strName, const ParserCallback &a_Callback, funmap_type &a_Storage, const char_type *a_szCharSet)

Add a function or operator callback to the parser.

void ClearFormula()

Clear the formula.

bool HasBuiltInOprt() const

Query status of built in variables.

bool m_bOptimize

Flag that indicates if the optimizer is on or off.

const char_type ** GetOprtDef() const

Get the default symbols used for the built in operators.

virtual void InitCharSets()=0

void Error(EErrorCodes a_iErrc, int a_iPos=(int) mu::string_type::npos, const string_type &a_strTok=string_type()) const

Create an error containing the parse error position.

ParserBase()

Constructor.

void EnableOptimizer(bool a_bIsOn=true)

Enable or disable the formula optimization feature.

funmap_type m_InfixOprtDef

unary infix operator.

bool m_bUseByteCode

Flag that indicates if bytecode parsing is on or off.

void ApplyFunc(ParserStack< token_type > &a_stOpt, ParserStack< token_type > &a_stVal, int iArgCount) const

Apply a function token.

virtual void InitOprt()=0

const valmap_type & GetConst() const

Return a map containing all parser constants.

ParserToken< value_type, string_type > token_type

Type used for parser tokens.

void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true)

Add a user defined operator.

void EnableByteCode(bool a_bIsOn=true)

Enable or disable parsing from Bytecode.

void DefineStrConst(const string_type &a_sName, const string_type &a_strVal)

Define a new string constant.

valmap_type m_ConstDef

user constants.

int GetOprtPri(const token_type &a_Tok) const

Get operator priority.

void SetVarFactory(facfun_type a_pFactory, void *pUserData=NULL)

const funmap_type & GetFunDef() const

Return prototypes of all parser functions.

void ClearInfixOprt()

Clear the user defined Prefix operators.

const char_type * ValidNameChars() const

Virtual function that defines the characters allowed in name identifiers.

void DefineVar(const string_type &a_sName, value_type *a_fVar)

Add a user defined variable.

value_type ParseCmdCode() const

Parse the command code.

void DefineConst(const string_type &a_sName, value_type a_fVal)

Add a user defined constant.

void RemoveVar(const string_type &a_strVarName)

Remove a variable from internal storage.

funmap_type m_FunDef

Map of function names and pointers.

funmap_type m_PostOprtDef

Postfix operator callbacks.

funmap_type m_OprtDef

Binary operator callbacks.

void ClearOprt()

Clear all user defined binary operators.

void DefineOprt(const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, bool a_bAllowOpt=false)

Define a binary operator.

virtual void InitConst()=0

string_type m_sInfixOprtChars

Charset for infix operator tokens.

void DefineOprtChars(const char_type *a_szCharset)

Define the set of valid characters to be used in names of binary operators and postfix operators.

ParserError exception_type

Type of the error class.

void ClearPostfixOprt()

Clear all user defined postfix operators.

void ClearFun()

Clear all functions.

token_type ApplyStrFunc(const token_type &a_FunTok, const std::vector< token_type > &a_vArg) const

Execute a function that takes a single string argument.

void DefineInfixOprtChars(const char_type *a_szCharset)

Define the set of valid characters to be used in names of infix operators.

ParserBase & operator=(const ParserBase &a_Parser)

Assignement operator.

void ClearConst()

Clear all user defined constants.

const char_type * ValidOprtChars() const

Virtual function that defines the characters allowed in operator definitions.

void ClearVar()

Clear all user defined variables.

void SetArgSep(char_type cArgSep)

Set argument separator.

std::unique_ptr< token_reader_type > m_pTokenReader

Managed pointer to the token reader object.

void DefineNameChars(const char_type *a_szCharset)

Define the set of valid characters to be used in names of functions, variables, constants.

void EnableBuiltInOprt(bool a_bIsOn=true)

Enable or disable the built in binary operators.

void ReInit() const

Reset parser to string parsing mode and clear internal buffers.

strmap_type m_StrVarDef

user defined string constants

void DefinePostfixOprt(const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true)

Add a user defined operator.

void InitTokenReader()

Initialize the token reader.

void SetExpr(const string_type &a_sExpr)

Set the formula.

char_type GetArgSep() const

Get the argument separator character.

ParserByteCode m_vByteCode

The Bytecode class.

string_type m_sNameChars

Charset for names.

bool m_bBuiltInOp

Flag that can be used for switching built in operators on and off.

string_type m_sOprtChars

Charset for postfix/ binary operator tokens.

stringbuf_type m_vStringVarBuf

const varmap_type & GetUsedVar() const

Return a map containing the used variables only.

void AddOp(ECmdCode a_Oprt)

Add an operator identifier to bytecode.

unsigned GetValSize() const

Return size of a value entry.

const map_type * GetRawData() const

Get Pointer to bytecode data storage.

void AddVal(value_type a_fVal)

Add a Variable pointer to bytecode.

void RemoveValEntries(unsigned a_iNumber)

Remove a value number of entries from the bytecode.

void clear()

Delete the bytecode.

std::size_t GetBufSize() const

void AsciiDump()

Dump bytecode (for debugging only!).

void AddStrFun(void *a_pFun, int a_iArgc, int a_iIdx)

Add Strung function entry to the parser bytecode.

void AddVar(value_type *a_pVar)

Add a Variable pointer to bytecode.

unsigned GetPtrSize() const

Return size of a pointer entry.

void Finalize()

Add end marker to bytecode.

void AddAssignOp(value_type *a_pVar)

Add an assignement operator.

void AddFun(void *a_pFun, int a_iArgc)

Add function to bytecode.

Encapsulation of prototypes for a numerical parser function.

void * GetAddr() const

Get the callback address for the parser function.

Error class of the parser.

Parser stack implementation.

void push(const TValueType &a_Val)

Push an object into the stack.

TValueType & top()

Return reference to the top object in the stack.

TValueType pop()

Pop a value from the stack.

unsigned size() const

Return the number of stored elements.

bool empty() const

Returns true if stack is empty false otherwise.

ECmdCode GetCode() const

Return the token type.

bool IsFlagSet(int a_iFlags) const

Check if a certain flag ist set.

void * GetFuncAddr() const

Return the address of the callback function assoziated with function and operator tokens.

ParserToken & SetVal(TBase a_fVal, const TString &a_strTok=TString())

Make this token a value token.

const TString & GetAsString() const

Return the token identifier.

int GetArgCount() const

Return the number of function arguments.

void AddFlags(int a_iFlags)

Add additional flags to the token.

ETypeCode GetType() const

TBase GetVal() const

\biref Get value of the token.

void SetIdx(int a_iIdx)

Set an index associated with the token related data.

TBase * GetVar() const

Get address of a variable token.

@ flVOLATILE

Mark a token that depends on a variable or a function that is not conservative.

unsigned int

A callback function used to compare two keys in a database.

#define MUP_ASSERT(COND)

An assertion that does not kill the program.

#define MUP_USE_FACET(FACET, LOCALE)

Definition of the standard floating point parser.

Namespace for mathematical applications.

value_type(* multfun_type)(const value_type *, int)

Callback type used for functions with a variable argument list.

std::ostream & console()

Encapsulate cout.

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

Callback used for functions that identify values in a string.

value_type(* strfun_type2)(const char_type *, value_type)

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

value_type(* strfun_type3)(const char_type *, value_type, value_type)

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

value_type(* strfun_type1)(const char_type *)

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

std::map< string_type, value_type > valmap_type

Type used for storing constants.

long bytecode_type

The bytecode type used by the parser.

value_type(* fun_type5)(value_type, value_type, value_type, value_type, value_type)

Callback type used for functions with five arguments.

string_type::value_type char_type

The character type used by the parser.

value_type *(* facfun_type)(const char_type *, void *)

Callback used for variable creation factory functions.

std::map< string_type, ParserCallback > funmap_type

Container for Callback objects.

std::map< string_type, value_type * > varmap_type

Type used for storing variables.

ECmdCode

Bytecode values.

@ cmADD

Operator item: add.

@ cmGE

Operator item: greater or equal.

@ cmLT

Operator item: less than.

@ cmPOW

Operator item: y to the power of ...

@ cmASSIGN

Operator item: Assignment operator.

@ cmARG_SEP

function argument separator

@ cmLE

Operator item: less or equal.

@ cmBO

Operator item: opening bracket.

@ cmMUL

Operator item: multiply.

@ cmXOR

Operator item: logical xor.

@ cmSTRING

Code for a string token.

@ cmDIV

Operator item: division.

@ cmOPRT_INFIX

code for infix operators

@ cmAND

Operator item: logical and.

@ cmBC

Operator item: closing bracket.

@ cmOPRT_BIN

user defined binary operator

@ cmUNKNOWN

uninitialized item

@ cmOR

Operator item: logical or.

@ cmNEQ

Operator item: not equal.

@ cmGT

Operator item: greater than.

@ cmEQ

Operator item: equals.

@ cmSUB

Operator item: subtract.

@ cmFUNC_STR

Code for a function with a string parameter.

@ cmFUNC

Code for a function item.

@ cmOPRT_POSTFIX

code for postfix operators

@ prPOSTFIX

Postfix operator priority (currently unused)

@ prCMP

comparsion operators

@ prLOGIC

logic operators

@ prPOW

power operator priority (highest)

@ prMUL_DIV

multiplication/division

value_type(* fun_type2)(value_type, value_type)

Callback type used for functions with two arguments.

@ tpDBL

Floating point variables.

@ tpSTR

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

value_type(* fun_type3)(value_type, value_type, value_type)

Callback type used for functions with three arguments.

@ ecINVALID_NAME

Invalid function, variable or constant name.

@ ecBUILTIN_OVERLOAD

Trying to overload builtin operator.

@ ecUNEXPECTED_EOF

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

@ ecNAME_CONFLICT

Name conflict.

@ ecSTRING_EXPECTED

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

@ ecTOO_MANY_PARAMS

Too many function parameters.

@ ecVAL_EXPECTED

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

@ ecSTR_RESULT

result is a string

@ ecUNEXPECTED_ARG

An unexpected argument has been found.

@ ecUNEXPECTED_OPERATOR

Unexpected binary operator found.

@ ecOPRT_TYPE_CONFLICT

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

@ ecLOCALE

Conflict with current locale.

@ ecINTERNAL_ERROR

Internal error of any kind.

@ ecINVALID_VAR_PTR

Invalid variable pointer.

@ ecUNEXPECTED_ARG_SEP

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

@ ecINVALID_FUN_PTR

Invalid callback function pointer.

@ ecTOO_FEW_PARAMS

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

@ ecEMPTY_EXPRESSION

The Expression is empty.

@ ecGENERIC

Generic error.

double value_type

The numeric datatype used by the parser.

value_type(* fun_type4)(value_type, value_type, value_type, value_type)

Callback type used for functions with four arguments.

std::string string_type

The stringtype used by the parser.

value_type(* fun_type0)()

Callback type used for functions without arguments.

value_type(* fun_type1)(value_type)

Callback type used for functions with a single arguments.

static const char * locale


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4