22 #ifndef QMUPARSERTOKENREADER_H
23 #define QMUPARSERTOKENREADER_H
25 #include <qcompilerdetection.h>
104 int ExtractToken(
const QString &a_szCharSet, QString &a_strTok,
int a_iPos)
const;
114 bool IsValTok(
token_type &a_Tok,
const QLocale &locale,
const QChar &decimal,
const QChar &thousand);
119 void Q_NORETURN
Error(
EErrorCodes a_iErrc,
int a_iPos = -1,
const QString &a_sTok = QString() )
const;
Mathematical expressions parser (base parser engine).
Token reader for the ParserBase class.
std::list< identfun_type > m_vIdentFun
Value token identification function.
int ExtractOperatorToken(QString &a_sTok, int a_iPos) const
Check Expression for the presence of a binary operator token.
QChar m_cArgSep
The character used for separating function arguments.
varmap_type * m_pVarDef
The only non const pointer to parser internals.
const funmap_type * m_pPostOprtDef
bool IsBuiltIn(token_type &a_Tok)
Check if a built in operator or other token can be found.
const funmap_type * m_pFunDef
qreal m_fZero
Dummy value of zero, referenced by undefined variables.
int ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const
Extract all characters that belong to a certain charset.
bool IsArgSep(token_type &a_Tok)
bool IsEOF(token_type &a_Tok)
Check for End of Formula.
void ReInit()
Reset the token reader to the start of the formula.
void AddValIdent(identfun_type a_pCallback)
void SetParent(QmuParserBase *a_pParent)
QmuParserTokenReader(QmuParserBase *a_pParent)
Constructor.
const funmap_type * m_pInfixOprtDef
bool IsValTok(token_type &a_Tok, const QLocale &locale, const QChar &decimal, const QChar &thousand)
Check whether the token at a given position is a value token.
bool IsUndefVarTok(token_type &a_Tok)
Check wheter a token at a given position is an undefined variable.
bool IsStrVarTok(token_type &a_Tok)
QmuParserToken< qreal, QString > token_type
bool IsFunTok(token_type &a_Tok)
Check whether the token at a given position is a function token.
int m_iBrackets
Keep count open brackets.
bool IsInfixOpTok(token_type &a_Tok)
Check if a string position contains a unary infix operator.
const valmap_type * m_pConstDef
bool IsString(token_type &a_Tok)
Check wheter a token at a given position is a string.
void SetFormula(const QString &a_strFormula)
Initialize the token Reader.
const QString & GetExpr() const
Return a reference to the formula.
int GetPos() const
Return the current position of the token reader in the formula string.
bool IsOprt(token_type &a_Tok)
Check if a string position contains a binary operator.
void SetArgSep(char_type cArgSep)
QmuParserBase * m_pParser
token_type ReadNextToken(const QLocale &locale, const QChar &decimal, const QChar &thousand)
Read the next token from the string.
QmuParserTokenReader * Clone(QmuParserBase *a_pParent) const
Create instance of a QParserTokenReader identical with this and return its pointer.
bool IsVarTok(token_type &a_Tok)
Check wheter a token at a given position is a variable token.
const strmap_type * m_pStrVarDef
void Assign(const QmuParserTokenReader &a_Reader)
Assign state of a token reader to this token reader.
varmap_type & GetUsedVar()
Return a map containing the used variables only.
const funmap_type * m_pOprtDef
QmuParserTokenReader & operator=(const QmuParserTokenReader &a_Reader)
Assignement operator.
bool IsPostOpTok(token_type &a_Tok)
Check if a string position contains a unary post value operator.
void SetVarCreator(facfun_type a_pFactory, void *pUserData)
@ noOPT
to avoid i.e. "(+)"
@ noBC
to avoid i.e. "sin)" or "()"
@ noANY
All of he above flags set.
@ noSTR
to block numeric arguments on string functions
@ noBO
to avoid i.e. "cos(7)("
@ noINFIXOP
to avoid i.e. "++4" "!!4"
@ noEND
to avoid unexpected end of formula
@ noASSIGN
to block assignement to constant i.e. "4=7"
@ noARG_SEP
to avoid i.e. ",," or "+," ...
@ noVAL
to avoid i.e. "tan 2" or "sin(8)3.14"
@ noPOSTOP
to avoid i.e. "(5!!)" "sin!"
@ noFUN
to avoid i.e. "sqrt cos" or "(1)sin"
@ noVAR
to avoid i.e. "sin a" or "sin(8)a"
token_type & SaveBeforeReturn(const token_type &tok)
void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos=-1, const QString &a_sTok=QString()) const
Create an error containing the parse error position.
void IgnoreUndefVar(bool bIgnore)
Set Flag that contronls behaviour in case of undefined variables beeing found.
Namespace for mathematical applications.
std::map< QString, QmuParserCallback > funmap_type
Container for Callback objects.
std::map< QString, int > strmap_type
Type for assigning a string name to an index in the internal string table.
string_type::value_type char_type
The character type used by the parser.
qreal *(* facfun_type)(const QString &, void *)
Callback used for variable creation factory functions.
int(* identfun_type)(const QString &sExpr, int *nPos, qreal *fVal, const QLocale &locale, const QChar &decimal, const QChar &thousand)
Callback used for functions that identify values in a string.
std::map< QString, qreal > valmap_type
Type used for storing constants.
std::map< QString, qreal * > varmap_type
Type used for storing variables.
Definition of the parser callback class.
This file contains standard definitions used by the parser.
This file defines the error class used by the parser.
This file contains the parser token definition.