Made possible methods include.

--HG--
branch : develop
This commit is contained in:
dismine 2014-05-06 17:36:42 +03:00
parent 88c8c7ec41
commit 6a8869bc1b
13 changed files with 424 additions and 420 deletions

View File

@ -29,7 +29,6 @@
#ifndef VERSION_H
#define VERSION_H
#include <QtCore/QString>
extern const int MAJOR_VERSION;
extern const int MINOR_VERSION;

View File

@ -110,17 +110,6 @@ qreal QmuParser::Sign(qreal v)
return ((v<0) ? -1 : (v>0) ? 1 : 0);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Callback for the unary minus operator.
* @param v The value to negate
* @return -v
*/
qreal QmuParser::UnaryMinus(qreal v)
{
return -v;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Callback for adding multiple values.

View File

@ -74,13 +74,24 @@ namespace qmu
static qreal Sign(qreal);
// Prefix operators
// !!! Unary Minus is a MUST if you want to use negative signs !!!
static qreal UnaryMinus(qreal);
static qreal UnaryMinus(qreal v);
// Functions with variable number of arguments
static qreal Sum(const qreal*, int); // sum
static qreal Avg(const qreal*, int); // mean value
static qreal Min(const qreal*, int); // minimum
static qreal Max(const qreal*, int); // maximum
};
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Callback for the unary minus operator.
* @param v The value to negate
* @return -v
*/
inline qreal QmuParser::UnaryMinus(qreal v)
{
return -v;
}
} // namespace qmu

View File

@ -192,20 +192,6 @@ void QmuParserBase::ResetLocale()
SetArgSep(',');
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Initialize the token reader.
*
* Create new token reader object and submit pointers to function, operator, constant and variable definitions.
*
* @post m_pTokenReader.get()!=0
* @throw nothrow
*/
void QmuParserBase::InitTokenReader() Q_DECL_NOEXCEPT
{
m_pTokenReader.reset(new token_reader_type(this));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Reset parser to string parsing mode and clear internal buffers.
@ -283,30 +269,6 @@ QString QmuParserBase::GetVersion(EParserVersionInfo eInfo)
return versionInfo;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Add a value parsing function.
*
* When parsing an expression muParser tries to detect values in the expression string using different valident
* callbacks. Thuis it's possible to parse for hex values, binary values and floating point values.
*/
void QmuParserBase::AddValIdent(identfun_type a_pCallback)
{
m_pTokenReader->AddValIdent(a_pCallback);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set a function that can create variable pointer for unknown expression variables.
* @param a_pFactory A pointer to the variable factory.
* @param pUserData A user defined context pointer.
*/
// cppcheck-suppress unusedFunction
void QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData)
{
m_pTokenReader->SetVarCreator(a_pFactory, pUserData);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Add a function or operator callback to the parser.
@ -464,43 +426,6 @@ void QmuParserBase::SetExpr(const QString &a_sExpr)
ReInit();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Get the default symbols used for the built in operators.
* @sa c_DefaultOprt
*/
const QStringList &QmuParserBase::GetOprtDef()
{
return c_DefaultOprt;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of functions, variables, constants.
*/
void QmuParserBase::DefineNameChars(const QString &a_szCharset)
{
m_sNameChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of binary operators and postfix operators.
*/
void QmuParserBase::DefineOprtChars(const QString &a_szCharset)
{
m_sOprtChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of infix operators.
*/
void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset)
{
m_sInfixOprtChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Virtual function that defines the characters allowed in name identifiers.
@ -809,49 +734,6 @@ const varmap_type& QmuParserBase::GetUsedVar() const
return m_pTokenReader->GetUsedVar();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing the used variables only.
*/
const varmap_type& QmuParserBase::GetVar() const
{
return m_VarDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing all parser constants.
*/
const valmap_type& QmuParserBase::GetConst() const
{
return m_ConstDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return prototypes of all parser functions.
* @return #m_FunDef
* @sa FunProt
* @throw nothrow
*
* The return type is a map of the public type #funmap_type containing the prototype definitions for all numerical
* parser functions. String functions are not part of this map. The Prototype definition is encapsulated in objects
* of the class FunProt one per parser function each associated with function names via a map construct.
*/
const funmap_type& QmuParserBase::GetFunDef() const Q_DECL_NOEXCEPT
{
return m_FunDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Retrieve the formula.
*/
const QString& QmuParserBase::GetExpr() const
{
return m_pTokenReader->GetExpr();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Execute a function that takes a single string argument.
@ -2003,17 +1885,6 @@ void QmuParserBase::EnableBuiltInOprt(bool a_bIsOn) Q_DECL_NOEXCEPT
ReInit();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Query status of built in variables.
* @return #m_bBuiltInOp; true if built in operators are enabled.
* @throw nothrow
*/
bool QmuParserBase::HasBuiltInOprt() const Q_DECL_NOEXCEPT
{
return m_bBuiltInOp;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Get the argument separator character.
@ -2160,41 +2031,6 @@ qreal* QmuParserBase::Eval(int &nStackSize) const
return &m_vStackBuffer[1];
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the number of results on the calculation stack.
*
* If the expression contains comma seperated subexpressions (i.e. "sin(y), x+y"). There mey be more than one return
* value. This function returns the number of available results.
*/
// cppcheck-suppress unusedFunction
int QmuParserBase::GetNumResults() const
{
return m_nFinalResultIdx;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Calculate the result.
*
* A note on const correctness:
* I consider it important that Calc is a const function.
* Due to caching operations Calc changes only the state of internal variables with one exception
* m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making
* Calc non const GetUsedVar is non const because it explicitely calls Eval() forcing this update.
*
* @pre A formula must be set.
* @pre Variables must have been set (if needed)
*
* @sa #m_pParseFormula
* @return The evaluation result
* @throw ParseException if no Formula is set or in case of any other error related to the formula.
*/
qreal QmuParserBase::Eval() const
{
return (this->*m_pParseFormula)();
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserBase::Eval(qreal *results, int nBulkSize) const
{

View File

@ -255,6 +255,170 @@ private:
void StackDump(const QStack<token_type > &a_stVal, const QStack<token_type > &a_stOprt) const;
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Initialize the token reader.
*
* Create new token reader object and submit pointers to function, operator, constant and variable definitions.
*
* @post m_pTokenReader.get()!=0
* @throw nothrow
*/
inline void QmuParserBase::InitTokenReader() Q_DECL_NOEXCEPT
{
m_pTokenReader.reset(new token_reader_type(this));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Add a value parsing function.
*
* When parsing an expression muParser tries to detect values in the expression string using different valident
* callbacks. Thuis it's possible to parse for hex values, binary values and floating point values.
*/
inline void QmuParserBase::AddValIdent(identfun_type a_pCallback)
{
m_pTokenReader->AddValIdent(a_pCallback);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set a function that can create variable pointer for unknown expression variables.
* @param a_pFactory A pointer to the variable factory.
* @param pUserData A user defined context pointer.
*/
// cppcheck-suppress unusedFunction
inline void QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData)
{
m_pTokenReader->SetVarCreator(a_pFactory, pUserData);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Get the default symbols used for the built in operators.
* @sa c_DefaultOprt
*/
inline const QStringList &QmuParserBase::GetOprtDef()
{
return c_DefaultOprt;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of functions, variables, constants.
*/
inline void QmuParserBase::DefineNameChars(const QString &a_szCharset)
{
m_sNameChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of binary operators and postfix operators.
*/
inline void QmuParserBase::DefineOprtChars(const QString &a_szCharset)
{
m_sOprtChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of infix operators.
*/
inline void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset)
{
m_sInfixOprtChars = a_szCharset;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing the used variables only.
*/
inline const varmap_type &QmuParserBase::GetVar() const
{
return m_VarDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing all parser constants.
*/
inline const valmap_type &QmuParserBase::GetConst() const
{
return m_ConstDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return prototypes of all parser functions.
* @return #m_FunDef
* @sa FunProt
* @throw nothrow
*
* The return type is a map of the public type #funmap_type containing the prototype definitions for all numerical
* parser functions. String functions are not part of this map. The Prototype definition is encapsulated in objects
* of the class FunProt one per parser function each associated with function names via a map construct.
*/
inline const funmap_type &QmuParserBase::GetFunDef() const Q_DECL_NOEXCEPT
{
return m_FunDef;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Retrieve the formula.
*/
inline const QString& QmuParserBase::GetExpr() const
{
return m_pTokenReader->GetExpr();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Query status of built in variables.
* @return #m_bBuiltInOp; true if built in operators are enabled.
* @throw nothrow
*/
inline bool QmuParserBase::HasBuiltInOprt() const Q_DECL_NOEXCEPT
{
return m_bBuiltInOp;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the number of results on the calculation stack.
*
* If the expression contains comma seperated subexpressions (i.e. "sin(y), x+y"). There mey be more than one return
* value. This function returns the number of available results.
*/
// cppcheck-suppress unusedFunction
inline int QmuParserBase::GetNumResults() const
{
return m_nFinalResultIdx;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Calculate the result.
*
* A note on const correctness:
* I consider it important that Calc is a const function.
* Due to caching operations Calc changes only the state of internal variables with one exception
* m_UsedVar this is reset during string parsing and accessible from the outside. Instead of making
* Calc non const GetUsedVar is non const because it explicitely calls Eval() forcing this update.
*
* @pre A formula must be set.
* @pre Variables must have been set (if needed)
*
* @sa #m_pParseFormula
* @return The evaluation result
* @throw ParseException if no Formula is set or in case of any other error related to the formula.
*/
inline qreal QmuParserBase::Eval() const
{
return (this->*m_pParseFormula)();
}
} // namespace qmu
#endif

View File

@ -73,12 +73,6 @@ QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteC
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserByteCode::EnableOptimizer(bool bStat)
{
m_bEnableOptimizer = bStat;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Copy state of another object to this.
@ -659,22 +653,6 @@ const SToken* QmuParserByteCode::GetBase() const
}
}
//---------------------------------------------------------------------------------------------------------------------
std::size_t QmuParserByteCode::GetMaxStackSize() const
{
return m_iMaxStackSize+1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the number of entries in the bytecode.
*/
// cppcheck-suppress unusedFunction
std::size_t QmuParserByteCode::GetSize() const
{
return m_vRPN.size();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Delete the bytecode.

View File

@ -120,5 +120,28 @@ private:
void ConstantFolding(ECmdCode a_Oprt);
};
//---------------------------------------------------------------------------------------------------------------------
inline void QmuParserByteCode::EnableOptimizer(bool bStat)
{
m_bEnableOptimizer = bStat;
}
//---------------------------------------------------------------------------------------------------------------------
inline std::size_t QmuParserByteCode::GetMaxStackSize() const
{
return m_iMaxStackSize+1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the number of entries in the bytecode.
*/
// cppcheck-suppress unusedFunction
inline std::size_t QmuParserByteCode::GetSize() const
{
return m_vRPN.size();
}
} // namespace qmu
#endif

View File

@ -321,87 +321,4 @@ QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref )
m_eOprtAsct = ref.m_eOprtAsct;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Clone this instance and return a pointer to the new instance.
*/
QmuParserCallback* QmuParserCallback::Clone() const
{
return new QmuParserCallback ( *this );
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return true if the function is conservative.
*
* Conservative functions return always the same result for the same argument.
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
bool QmuParserCallback::IsOptimizable() const Q_DECL_NOEXCEPT
{
return m_bAllowOpti;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Get the callback address for the parser function.
*
* The type of the address is void. It needs to be recasted according to the argument number to the right type.
*
* @throw nothrow
* @return #pFun
*/
void* QmuParserCallback::GetAddr() const Q_DECL_NOEXCEPT
{
return m_pFun;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the callback code.
*/
ECmdCode QmuParserCallback::GetCode() const
{
return m_iCode;
}
//---------------------------------------------------------------------------------------------------------------------
ETypeCode QmuParserCallback::GetType() const
{
return m_iType;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the operator precedence.
* @throw nothrown
*
* Only valid if the callback token is an operator token (binary or infix).
*/
int QmuParserCallback::GetPri() const Q_DECL_NOEXCEPT
{
return m_iPri;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the operators associativity.
* @throw nothrown
*
* Only valid if the callback token is a binary operator token.
*/
EOprtAssociativity QmuParserCallback::GetAssociativity() const Q_DECL_NOEXCEPT
{
return m_eOprtAsct;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the number of function Arguments.
*/
int QmuParserCallback::GetArgc() const
{
return m_iArgc;
}
} // namespace qmu

View File

@ -109,6 +109,90 @@ private:
*/
typedef std::map<QString, QmuParserCallback> funmap_type;
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Clone this instance and return a pointer to the new instance.
*/
inline QmuParserCallback* QmuParserCallback::Clone() const
{
return new QmuParserCallback ( *this );
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return true if the function is conservative.
*
* Conservative functions return always the same result for the same argument.
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
inline bool QmuParserCallback::IsOptimizable() const Q_DECL_NOEXCEPT
{
return m_bAllowOpti;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Get the callback address for the parser function.
*
* The type of the address is void. It needs to be recasted according to the argument number to the right type.
*
* @throw nothrow
* @return #pFun
*/
inline void* QmuParserCallback::GetAddr() const Q_DECL_NOEXCEPT
{
return m_pFun;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the callback code.
*/
inline ECmdCode QmuParserCallback::GetCode() const
{
return m_iCode;
}
//---------------------------------------------------------------------------------------------------------------------
inline ETypeCode QmuParserCallback::GetType() const
{
return m_iType;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the operator precedence.
* @throw nothrown
*
* Only valid if the callback token is an operator token (binary or infix).
*/
inline int QmuParserCallback::GetPri() const Q_DECL_NOEXCEPT
{
return m_iPri;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the operators associativity.
* @throw nothrown
*
* Only valid if the callback token is a binary operator token.
*/
inline EOprtAssociativity QmuParserCallback::GetAssociativity() const Q_DECL_NOEXCEPT
{
return m_eOprtAsct;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the number of function Arguments.
*/
inline int QmuParserCallback::GetArgc() const
{
return m_iArgc;
}
} // namespace qmu
#endif

View File

@ -28,19 +28,6 @@ namespace qmu
{
const QmuParserErrorMsg QmuParserErrorMsg::m_Instance;
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
const QmuParserErrorMsg& QmuParserErrorMsg::Instance()
{
return m_Instance;
}
//---------------------------------------------------------------------------------------------------------------------
QString QmuParserErrorMsg::operator[] ( unsigned a_iIdx ) const
{
return ( a_iIdx < static_cast<unsigned>( m_vErrMsg.size() ) ) ? m_vErrMsg[a_iIdx] : QString();
}
//---------------------------------------------------------------------------------------------------------------------
QmuParserErrorMsg::~QmuParserErrorMsg()
{}
@ -185,7 +172,9 @@ QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &
}
//---------------------------------------------------------------------------------------------------------------------
/** @brief Copy constructor. */
/**
* @brief Copy constructor.
*/
QmuParserError::QmuParserError ( const QmuParserError &a_Obj )
: QException(), m_sMsg ( a_Obj.m_sMsg ), m_sExpr ( a_Obj.m_sExpr ), m_sTok ( a_Obj.m_sTok ),
m_iPos ( a_Obj.m_iPos ), m_iErrc ( a_Obj.m_iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() )
@ -250,60 +239,4 @@ void QmuParserError::Reset()
m_iErrc = ecUNDEFINED;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set the expression related to this error.
*/
void QmuParserError::SetFormula ( const QString &a_strFormula )
{
m_sExpr = a_strFormula;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief gets the expression related tp this error.
*/
const QString& QmuParserError::GetExpr() const
{
return m_sExpr;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the message string for this error.
*/
const QString& QmuParserError::GetMsg() const
{
return m_sMsg;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the formula position related to the error.
*
* If the error is not related to a distinct position this will return -1
*/
int QmuParserError::GetPos() const
{
return m_iPos;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return string related with this token (if available).
*/
const QString& QmuParserError::GetToken() const
{
return m_sTok;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the error code.
*/
EErrorCodes QmuParserError::GetCode() const
{
return m_iErrc;
}
} // namespace qmu

View File

@ -109,6 +109,19 @@ private:
static const self_type m_Instance; ///< The instance pointer
};
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
inline const QmuParserErrorMsg& QmuParserErrorMsg::Instance()
{
return m_Instance;
}
//---------------------------------------------------------------------------------------------------------------------
inline QString QmuParserErrorMsg::operator[] ( unsigned a_iIdx ) const
{
return ( a_iIdx < static_cast<unsigned>( m_vErrMsg.size() ) ) ? m_vErrMsg[a_iIdx] : QString();
}
//---------------------------------------------------------------------------
/** @brief Error class of the parser.
@author Ingo Berg
@ -134,15 +147,7 @@ public:
int GetPos() const;
const QString& GetToken() const;
EErrorCodes GetCode() const;
/**
* @brief raise method raise for exception
*/
virtual void raise() const;
/**
* @brief clone clone exception
* @return new exception
*/
virtual QmuParserError *clone() const;
private:
QString m_sMsg; ///< The message string
@ -158,16 +163,81 @@ private:
void Reset();
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief raise method raise for exception
*/
inline void QmuParserError::raise() const
{
throw *this;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief clone clone exception
* @return new exception
*/
inline QmuParserError *QmuParserError::clone() const
{
return new QmuParserError(*this);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set the expression related to this error.
*/
inline void QmuParserError::SetFormula ( const QString &a_strFormula )
{
m_sExpr = a_strFormula;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief gets the expression related tp this error.
*/
inline const QString& QmuParserError::GetExpr() const
{
return m_sExpr;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the message string for this error.
*/
inline const QString& QmuParserError::GetMsg() const
{
return m_sMsg;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the formula position related to the error.
*
* If the error is not related to a distinct position this will return -1
*/
inline int QmuParserError::GetPos() const
{
return m_iPos;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return string related with this token (if available).
*/
inline const QString& QmuParserError::GetToken() const
{
return m_sTok;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the error code.
*/
inline EErrorCodes QmuParserError::GetCode() const
{
return m_iErrc;
}
} // namespace qmu
#endif

View File

@ -169,39 +169,6 @@ void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserDa
m_pFactoryData = pUserData;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the current position of the token reader in the formula string.
*
* @return #m_iPos
* @throw nothrow
*/
int QmuParserTokenReader::GetPos() const Q_DECL_NOEXCEPT
{
return m_iPos;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a reference to the formula.
*
* @return #m_strFormula
* @throw nothrow
*/
const QString& QmuParserTokenReader::GetExpr() const Q_DECL_NOEXCEPT
{
return m_strFormula;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing the used variables only.
*/
varmap_type& QmuParserTokenReader::GetUsedVar()
{
return m_UsedVar;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Initialize the token Reader.
@ -215,20 +182,6 @@ void QmuParserTokenReader::SetFormula ( const QString &a_strFormula )
ReInit();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set Flag that contronls behaviour in case of undefined variables beeing found.
*
* If true, the parser does not throw an exception if an undefined variable is found. Otherwise it does. This variable
* is used internally only! It supresses a "undefined variable" exception in GetUsedVar().
* Those function should return a complete list of variables including
* those the are not defined by the time of it's call.
*/
void QmuParserTokenReader::IgnoreUndefVar ( bool bIgnore )
{
m_bIgnoreUndefVar = bIgnore;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Reset the token reader to the start of the formula.
@ -1113,16 +1066,4 @@ void Q_NORETURN QmuParserTokenReader::Error ( EErrorCodes a_iErrc, int a_iPos, c
{
m_pParser->Error ( a_iErrc, a_iPos, a_sTok );
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetArgSep ( char_type cArgSep )
{
m_cArgSep = cArgSep;
}
//---------------------------------------------------------------------------------------------------------------------
QChar QmuParserTokenReader::GetArgSep() const
{
return m_cArgSep;
}
} // namespace qmu

View File

@ -134,6 +134,65 @@ private:
token_type m_lastTok;
QChar m_cArgSep; ///< The character used for separating function arguments
};
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return the current position of the token reader in the formula string.
*
* @return #m_iPos
* @throw nothrow
*/
inline int QmuParserTokenReader::GetPos() const Q_DECL_NOEXCEPT
{
return m_iPos;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a reference to the formula.
*
* @return #m_strFormula
* @throw nothrow
*/
inline const QString& QmuParserTokenReader::GetExpr() const Q_DECL_NOEXCEPT
{
return m_strFormula;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Return a map containing the used variables only.
*/
inline varmap_type& QmuParserTokenReader::GetUsedVar()
{
return m_UsedVar;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Set Flag that contronls behaviour in case of undefined variables beeing found.
*
* If true, the parser does not throw an exception if an undefined variable is found. Otherwise it does. This variable
* is used internally only! It supresses a "undefined variable" exception in GetUsedVar().
* Those function should return a complete list of variables including
* those the are not defined by the time of it's call.
*/
inline void QmuParserTokenReader::IgnoreUndefVar ( bool bIgnore )
{
m_bIgnoreUndefVar = bIgnore;
}
//---------------------------------------------------------------------------------------------------------------------
inline void QmuParserTokenReader::SetArgSep ( char_type cArgSep )
{
m_cArgSep = cArgSep;
}
//---------------------------------------------------------------------------------------------------------------------
inline QChar QmuParserTokenReader::GetArgSep() const
{
return m_cArgSep;
}
} // namespace qmu
#endif