22 #ifndef QMUPARSERTOKEN_H
23 #define QMUPARSERTOKEN_H
57 template<
typename TBase,
typename TString>
100 if ( &a_Tok ==
this )
142 assert ( a_iType !=
cmVAR );
143 assert ( a_iType !=
cmVAL );
144 assert ( a_iType !=
cmFUNC );
161 assert ( a_pCallback.
GetAddr() );
208 m_pTok =
reinterpret_cast<void*
> ( a_pVar );
329 template <
class FunctionPtr >
339 Q_STATIC_ASSERT_X(
sizeof(
void *) ==
sizeof(
void (*)(
void)),
340 "object pointer and function pointer sizes must equal");
363 return ( union_cast<generic_fun_type>(
m_pCallback.get() ) ) ?
364 union_cast<generic_fun_type>(
m_pCallback->GetAddr() ) : union_cast<generic_fun_type>(
nullptr);
381 return * (
reinterpret_cast<TBase*
>(
m_pTok) );
435 return reinterpret_cast<TBase*
>(
m_pTok );
Encapsulation of prototypes for a numerical parser function.
ECmdCode GetCode() const
Return the callback code.
void * GetAddr() const
Get the callback address for the parser function.
Error class of the parser.
Encapsulation of the data for a single formula token.
ETypeCode GetType() const
QmuParserToken & Set(const QmuParserCallback &a_pCallback, const TString &a_sTok)
Set Callback type.
void * m_pTok
Stores Token pointer; not applicable for all tokens.
EOprtAssociativity GetAssociativity() const
ECmdCode m_iCode
Type of the token; The token type is a constant of type ECmdCode.
generic_fun_type GetFuncAddr() const
Return the address of the callback function assoziated with function and operator tokens.
void SetIdx(int a_iIdx)
Set an index associated with the token related data.
ECmdCode GetCode() const
Return the token type.
static FunctionPtr union_cast(void *objectPtr)
int GetIdx() const
Return Index associated with the token related data.
QmuParserToken & operator=(const QmuParserToken &a_Tok)
Assignement operator.
int m_iIdx
An otional index to an external buffer storing the token data.
std::unique_ptr< QmuParserCallback > m_pCallback
QmuParserToken & SetVal(TBase a_fVal, const TString &a_strTok=TString())
Make this token a value token.
TString m_strTok
Token string.
int GetArgCount() const
Return the number of function arguments.
QmuParserToken & SetVar(TBase *a_pVar, const TString &a_strTok)
make this token a variable token.
QmuParserToken()
Constructor (default).
TString m_strVal
Value for string variables.
QmuParserToken & Set(ECmdCode a_iType, const TString &a_strTok=TString())
Assign a token type.
QmuParserToken & SetString(const TString &a_strTok, int a_iSize)
Make this token a variable token.
const TString & GetAsString() const
Return the token identifier.
QmuParserToken(const QmuParserToken &a_Tok)
Create token from another one.
void Assign(const QmuParserToken &a_Tok)
Copy token information from argument.
TBase GetVal() const
Get value of the token.
TBase * GetVar() const
Get address of a variable token.
Namespace for mathematical applications.
@ ecVAL_EXPECTED
A numerical function has been called with a non value type of argument.
@ ecINTERNAL_ERROR
Internal error of any kind.
@ cmOPRT_INFIX
code for infix operators
@ cmBC
Operator item: closing bracket.
@ cmLE
Operator item: less or equal.
@ cmUNKNOWN
uninitialized item
@ cmSUB
Operator item: subtract.
@ cmGT
Operator item: greater than.
@ cmSTRING
Code for a string token.
@ cmFUNC
Code for a generic function item.
@ cmFUNC_STR
Code for a function with a string parameter.
@ cmLT
Operator item: less than.
@ cmMUL
Operator item: multiply.
@ cmGE
Operator item: greater or equal.
@ cmADD
Operator item: add.
@ cmASSIGN
Operator item: Assignment operator.
@ cmENDIF
For use in the ternary if-then-else operator.
@ cmELSE
For use in the ternary if-then-else operator.
@ cmEQ
Operator item: equals.
@ cmFUNC_BULK
Special callbacks for Bulk mode with an additional parameter for the bulk index.
@ cmARG_SEP
function argument separator
@ cmPOW
Operator item: y to the power of ...
@ cmNEQ
Operator item: not equal.
@ cmOPRT_BIN
user defined binary operator
@ cmIF
For use in the ternary if-then-else operator.
@ cmOPRT_POSTFIX
code for postfix operators
@ cmDIV
Operator item: division.
@ cmBO
Operator item: opening bracket.
qreal(* generic_fun_type)()
Callback type used for functions without arguments.
EOprtAssociativity
Parser operator precedence values.
ETypeCode
Types internally used by the parser.
@ tpDBL
Floating point variables.
@ tpSTR
String type (Function arguments and constants only, no string variables)
Definition of the parser callback class.
This file defines the error class used by the parser.