Factory function for creating new parser variables. New methods what return

tokens and numbers.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-22 15:11:14 +03:00
parent 1bbee62a79
commit ccde48e3bf
16 changed files with 271 additions and 259 deletions

View file

@ -30,6 +30,8 @@
#include <QDebug>
#include "../widgets/vapplication.h"
int Calculator::iVal = -1;
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Calculator class constructor.
@ -60,11 +62,14 @@ Calculator::Calculator(const VContainer *data)
DefinePostfixOprt(cm_Oprt, CmUnit);
DefinePostfixOprt(mm_Oprt, MmUnit);
DefinePostfixOprt(in_Oprt, InchUnit);
SetVarFactory(AddVariable, this);
}
Calculator::~Calculator()
{
delete [] vVarVal;
Calculator::iVal = -1;
}
//---------------------------------------------------------------------------------------------------------------------
@ -267,3 +272,35 @@ qreal Calculator::InchUnit(qreal val)
return unit;
}
//---------------------------------------------------------------------------
// Factory function for creating new parser variables
// This could as well be a function performing database queries.
qreal* Calculator::AddVariable(const QString &a_szName, void *a_pUserData)
{
// I don't want dynamic allocation here, so i used this static buffer
// If you want dynamic allocation you must allocate all variables dynamically
// in order to delete them later on. Or you find other ways to keep track of
// variables that have been created implicitely.
static qreal afValBuf[100];
++iVal;
Q_UNUSED(a_szName)
Q_UNUSED(a_pUserData)
// qDebug() << "Generating new variable \""
// << a_szName << "\" (slots left: "
// << 99-iVal << ")"
// << " User data pointer is:"
// << QString::number(a_pUserData, 16);
afValBuf[iVal] = 0;
if (iVal>=99)
{
throw qmu::QmuParserError( "Variable buffer overflow." );
}
else
{
return &afValBuf[iVal];
}
}

View file

@ -39,14 +39,16 @@ class Calculator:public QmuParser
public:
explicit Calculator(const VContainer *data);
~Calculator();
qreal EvalFormula(const QString &formula);
qreal EvalFormula(const QString &formula);
private:
Q_DISABLE_COPY(Calculator)
qreal *vVarVal;
void InitVariables(const VContainer *data);
static qreal CmUnit(qreal val);
static qreal MmUnit(qreal val);
static qreal InchUnit(qreal val);
static int iVal;
void InitVariables(const VContainer *data);
static qreal CmUnit(qreal val);
static qreal MmUnit(qreal val);
static qreal InchUnit(qreal val);
static qreal* AddVariable(const QString &a_szName, void *a_pUserData);
};
#endif // CALCULATOR_H

View file

@ -202,11 +202,7 @@ int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal)
{
qreal fVal(0);
#if defined(_UNICODE)
std::wstring a_szExprStd = a_szExpr.toStdWString();
#else
std::string a_szExprStd = a_szExpr.toStdString();
#endif
std::wstring a_szExprStd = a_szExpr.toStdWString();
stringstream_type stream(a_szExprStd);
stream.seekg(0); // todo: check if this really is necessary
stream.imbue(QmuParser::s_locale);

View file

@ -74,7 +74,7 @@ namespace qmu
static qreal Sign(qreal);
// Prefix operators
// !!! Unary Minus is a MUST if you want to use negative signs !!!
static qreal UnaryMinus(qreal v) Q_DECL_NOEXCEPT;
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
@ -88,7 +88,7 @@ namespace qmu
* @param v The value to negate
* @return -v
*/
inline qreal QmuParser::UnaryMinus(qreal v) Q_DECL_NOEXCEPT
inline qreal QmuParser::UnaryMinus(qreal v)
{
return -v;
}

View file

@ -64,7 +64,7 @@ QmuParserBase::QmuParserBase()
:m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(),
m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(),
m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(),
m_nFinalResultIdx(0)
m_nFinalResultIdx(0), m_Tokens(QMap<int, QString>()), m_Numbers(QMap<int, QString>())
{
InitTokenReader();
}
@ -79,7 +79,7 @@ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser)
:m_pParseFormula(&QmuParserBase::ParseString), m_vRPN(), m_vStringBuf(), m_vStringVarBuf(), m_pTokenReader(),
m_FunDef(), m_PostOprtDef(), m_InfixOprtDef(), m_OprtDef(), m_ConstDef(), m_StrVarDef(), m_VarDef(),
m_bBuiltInOp(true), m_sNameChars(), m_sOprtChars(), m_sInfixOprtChars(), m_nIfElseCounter(0), m_vStackBuffer(),
m_nFinalResultIdx(0)
m_nFinalResultIdx(0), m_Tokens(QMap<int, QString>()), m_Numbers(QMap<int, QString>())
{
m_pTokenReader.reset(new token_reader_type(this));
Assign(a_Parser);
@ -98,7 +98,7 @@ QmuParserBase::~QmuParserBase()
* @return *this
* @throw nothrow
*/
QmuParserBase& QmuParserBase::operator=(const QmuParserBase &a_Parser) Q_DECL_NOEXCEPT
QmuParserBase& QmuParserBase::operator=(const QmuParserBase &a_Parser)
{
Assign(a_Parser);
return *this;
@ -199,13 +199,15 @@ void QmuParserBase::ResetLocale()
* Clear bytecode, reset the token reader.
* @throw nothrow
*/
void QmuParserBase::ReInit() const Q_DECL_NOEXCEPT
void QmuParserBase::ReInit() const
{
m_pParseFormula = &QmuParserBase::ParseString;
m_vStringBuf.clear();
m_vRPN.clear();
m_pTokenReader->ReInit();
m_nIfElseCounter = 0;
m_Tokens.clear();
m_Numbers.clear();
}
//---------------------------------------------------------------------------------------------------------------------
@ -318,13 +320,9 @@ void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallbac
void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback,
const QString &a_szCharSet) const
{
#if defined(_UNICODE)
const std::wstring a_sNameStd = a_sName.toStdWString();
const std::wstring a_szCharSetStd = a_szCharSet.toStdWString();
#else
const std::string a_sNameStd = a_sName.toStdString();
const std::string a_szCharSetStd = a_szCharSet.toStdString();
#endif
if ( a_sNameStd.length() == false || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) ||
(a_sNameStd.at(0)>='0' && a_sNameStd.at(0)<='9'))
{
@ -385,13 +383,9 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a
*/
void QmuParserBase::CheckName(const QString &a_sName, const QString &a_szCharSet) const
{
#if defined(_UNICODE)
std::wstring a_sNameStd = a_sName.toStdWString();
std::wstring a_szCharSetStd = a_szCharSet.toStdWString();
#else
std::string a_sNameStd = a_sName.toStdString();
std::string a_szCharSetStd = a_szCharSet.toStdString();
#endif
if ( a_sNameStd.length() == false || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) ||
(a_sNameStd[0]>='0' && a_sNameStd[0]<='9'))
{
@ -1494,14 +1488,17 @@ void QmuParserBase::CreateRPN() const
opt.SetIdx(m_vStringBuf.size()); // Assign buffer index to token
stVal.push(opt);
m_vStringBuf.push_back(opt.GetAsString()); // Store string in internal buffer
m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString());
break;
case cmVAR:
stVal.push(opt);
m_vRPN.AddVar( static_cast<qreal*>(opt.GetVar()) );
m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString());
break;
case cmVAL:
stVal.push(opt);
m_vRPN.AddVal( opt.GetVal() );
m_Numbers.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString());
break;
case cmELSE:
m_nIfElseCounter--;
@ -1643,10 +1640,12 @@ void QmuParserBase::CreateRPN() const
case cmFUNC_BULK:
case cmFUNC_STR:
stOpt.push(opt);
m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString());
break;
case cmOPRT_POSTFIX:
stOpt.push(opt);
ApplyFunc(stOpt, stVal, 1); // this is the postfix operator
m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString());
break;
case cmENDIF:
case cmVARPOW2:
@ -1753,7 +1752,7 @@ void Q_NORETURN QmuParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const QStr
* Resets the parser to string parsing mode by calling #ReInit.
*/
// cppcheck-suppress unusedFunction
void QmuParserBase::ClearVar() Q_DECL_NOEXCEPT
void QmuParserBase::ClearVar()
{
m_VarDef.clear();
ReInit();
@ -1766,7 +1765,7 @@ void QmuParserBase::ClearVar() Q_DECL_NOEXCEPT
*
* Removes a variable if it exists. If the Variable does not exist nothing will be done.
*/
void QmuParserBase::RemoveVar(const QString &a_strVarName) Q_DECL_NOEXCEPT
void QmuParserBase::RemoveVar(const QString &a_strVarName)
{
varmap_type::iterator item = m_VarDef.find(a_strVarName);
if (item!=m_VarDef.end())
@ -1783,7 +1782,7 @@ void QmuParserBase::RemoveVar(const QString &a_strVarName) Q_DECL_NOEXCEPT
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
void QmuParserBase::ClearFun() Q_DECL_NOEXCEPT
void QmuParserBase::ClearFun()
{
m_FunDef.clear();
ReInit();
@ -1797,7 +1796,7 @@ void QmuParserBase::ClearFun() Q_DECL_NOEXCEPT
* @post Resets the parser to string parsing mode.
* @throw nothrow
*/
void QmuParserBase::ClearConst() Q_DECL_NOEXCEPT
void QmuParserBase::ClearConst()
{
m_ConstDef.clear();
m_StrVarDef.clear();
@ -1810,7 +1809,7 @@ void QmuParserBase::ClearConst() Q_DECL_NOEXCEPT
* @post Resets the parser to string parsing mode.
* @throw nothrow
*/
void QmuParserBase::ClearPostfixOprt() Q_DECL_NOEXCEPT
void QmuParserBase::ClearPostfixOprt()
{
m_PostOprtDef.clear();
ReInit();
@ -1823,7 +1822,7 @@ void QmuParserBase::ClearPostfixOprt() Q_DECL_NOEXCEPT
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
void QmuParserBase::ClearOprt() Q_DECL_NOEXCEPT
void QmuParserBase::ClearOprt()
{
m_OprtDef.clear();
ReInit();
@ -1836,7 +1835,7 @@ void QmuParserBase::ClearOprt() Q_DECL_NOEXCEPT
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
void QmuParserBase::ClearInfixOprt() Q_DECL_NOEXCEPT
void QmuParserBase::ClearInfixOprt()
{
m_InfixOprtDef.clear();
ReInit();
@ -1848,7 +1847,7 @@ void QmuParserBase::ClearInfixOprt() Q_DECL_NOEXCEPT
* @post Resets the parser to string parser mode.
* @throw nothrow
*/
void QmuParserBase::EnableOptimizer(bool a_bIsOn) Q_DECL_NOEXCEPT
void QmuParserBase::EnableOptimizer(bool a_bIsOn)
{
m_vRPN.EnableOptimizer(a_bIsOn);
ReInit();
@ -1879,7 +1878,7 @@ void QmuParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack)
* manually one by one. It is not possible to disable built in operators selectively. This function will Reinitialize
* the parser by calling ReInit().
*/
void QmuParserBase::EnableBuiltInOprt(bool a_bIsOn) Q_DECL_NOEXCEPT
void QmuParserBase::EnableBuiltInOprt(bool a_bIsOn)
{
m_bBuiltInOp = a_bIsOn;
ReInit();

View file

@ -58,22 +58,22 @@ class QMUPARSERSHARED_EXPORT QmuParserBase
public:
QmuParserBase();
QmuParserBase(const QmuParserBase &a_Parser);
QmuParserBase& operator=(const QmuParserBase &a_Parser) Q_DECL_NOEXCEPT;
QmuParserBase& operator=(const QmuParserBase &a_Parser);
virtual ~QmuParserBase();
static void EnableDebugDump(bool bDumpCmd, bool bDumpStack);
qreal Eval() const;
qreal* Eval(int &nStackSize) const;
void Eval(qreal *results, int nBulkSize) const;
int GetNumResults() const Q_DECL_NOEXCEPT;
int GetNumResults() const;
void SetExpr(const QString &a_sExpr);
void SetVarFactory(facfun_type a_pFactory, void *pUserData = nullptr);
void SetDecSep(char_type cDecSep);
void SetThousandsSep(char_type cThousandsSep = 0);
void ResetLocale();
void EnableOptimizer(bool a_bIsOn=true) Q_DECL_NOEXCEPT;
void EnableBuiltInOprt(bool a_bIsOn=true) Q_DECL_NOEXCEPT;
bool HasBuiltInOprt() const Q_DECL_NOEXCEPT;
void EnableOptimizer(bool a_bIsOn=true);
void EnableBuiltInOprt(bool a_bIsOn=true);
bool HasBuiltInOprt() const;
void AddValIdent(identfun_type a_pCallback);
void DefineOprt(const QString &a_strName, fun_type2 a_pFun, unsigned a_iPri=0,
EOprtAssociativity a_eAssociativity = oaLEFT, bool a_bAllowOpt = false);
@ -84,23 +84,25 @@ public:
void DefineInfixOprt(const QString &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX,
bool a_bAllowOpt=true);
// Clear user defined variables, constants or functions
void ClearVar() Q_DECL_NOEXCEPT;
void ClearFun() Q_DECL_NOEXCEPT;
void ClearConst() Q_DECL_NOEXCEPT;
void ClearInfixOprt() Q_DECL_NOEXCEPT;
void ClearPostfixOprt() Q_DECL_NOEXCEPT;
void ClearOprt() Q_DECL_NOEXCEPT;
void RemoveVar(const QString &a_strVarName) Q_DECL_NOEXCEPT;
void ClearVar();
void ClearFun();
void ClearConst();
void ClearInfixOprt();
void ClearPostfixOprt();
void ClearOprt();
void RemoveVar(const QString &a_strVarName);
const varmap_type& GetUsedVar() const;
const varmap_type& GetVar() const Q_DECL_NOEXCEPT;
const valmap_type& GetConst() const Q_DECL_NOEXCEPT;
const varmap_type& GetVar() const;
const valmap_type& GetConst() const;
const QString& GetExpr() const;
const funmap_type& GetFunDef() const Q_DECL_NOEXCEPT;
const funmap_type& GetFunDef() const;
static QString GetVersion(EParserVersionInfo eInfo = pviFULL);
static const QStringList& GetOprtDef() Q_DECL_NOEXCEPT;
void DefineNameChars(const QString &a_szCharset) Q_DECL_NOEXCEPT;
void DefineOprtChars(const QString &a_szCharset) Q_DECL_NOEXCEPT;
void DefineInfixOprtChars(const QString &a_szCharset) Q_DECL_NOEXCEPT;
static const QStringList& GetOprtDef();
QMap<int, QString> GetTokens() const;
QMap<int, QString> GetNumbers() const;
void DefineNameChars(const QString &a_szCharset);
void DefineOprtChars(const QString &a_szCharset);
void DefineInfixOprtChars(const QString &a_szCharset);
const QString& ValidNameChars() const;
const QString& ValidOprtChars() const;
const QString& ValidInfixOprtChars() const;
@ -232,10 +234,12 @@ private:
// items merely used for caching state information
mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine
mutable int m_nFinalResultIdx;
mutable QMap<int, QString> m_Tokens;///< Keep all tokens that we can translate
mutable QMap<int, QString> m_Numbers;///< Keep all numbers what exist in formula
void Assign(const QmuParserBase &a_Parser);
void InitTokenReader();
void ReInit() const Q_DECL_NOEXCEPT;
void ReInit() const;
void AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback,
funmap_type &a_Storage, const QString &a_szCharSet );
void ApplyRemainingOprt(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
@ -297,16 +301,26 @@ inline void QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData
* @brief Get the default symbols used for the built in operators.
* @sa c_DefaultOprt
*/
inline const QStringList &QmuParserBase::GetOprtDef() Q_DECL_NOEXCEPT
inline const QStringList &QmuParserBase::GetOprtDef()
{
return c_DefaultOprt;
}
inline QMap<int, QString> QmuParserBase::GetTokens() const
{
return m_Tokens;
}
inline QMap<int, QString> QmuParserBase::GetNumbers() const
{
return m_Numbers;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Define the set of valid characters to be used in names of functions, variables, constants.
*/
inline void QmuParserBase::DefineNameChars(const QString &a_szCharset) Q_DECL_NOEXCEPT
inline void QmuParserBase::DefineNameChars(const QString &a_szCharset)
{
m_sNameChars = a_szCharset;
}
@ -315,7 +329,7 @@ inline void QmuParserBase::DefineNameChars(const QString &a_szCharset) Q_DECL_NO
/**
* @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) Q_DECL_NOEXCEPT
inline void QmuParserBase::DefineOprtChars(const QString &a_szCharset)
{
m_sOprtChars = a_szCharset;
}
@ -324,7 +338,7 @@ inline void QmuParserBase::DefineOprtChars(const QString &a_szCharset) Q_DECL_NO
/**
* @brief Define the set of valid characters to be used in names of infix operators.
*/
inline void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset) Q_DECL_NOEXCEPT
inline void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset)
{
m_sInfixOprtChars = a_szCharset;
}
@ -333,7 +347,7 @@ inline void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset) Q_DE
/**
* @brief Return a map containing the used variables only.
*/
inline const varmap_type &QmuParserBase::GetVar() const Q_DECL_NOEXCEPT
inline const varmap_type &QmuParserBase::GetVar() const
{
return m_VarDef;
}
@ -342,7 +356,7 @@ inline const varmap_type &QmuParserBase::GetVar() const Q_DECL_NOEXCEPT
/**
* @brief Return a map containing all parser constants.
*/
inline const valmap_type &QmuParserBase::GetConst() const Q_DECL_NOEXCEPT
inline const valmap_type &QmuParserBase::GetConst() const
{
return m_ConstDef;
}
@ -358,7 +372,7 @@ inline const valmap_type &QmuParserBase::GetConst() const Q_DECL_NOEXCEPT
* 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
inline const funmap_type &QmuParserBase::GetFunDef() const
{
return m_FunDef;
}
@ -378,7 +392,7 @@ inline const QString& QmuParserBase::GetExpr() const
* @return #m_bBuiltInOp; true if built in operators are enabled.
* @throw nothrow
*/
inline bool QmuParserBase::HasBuiltInOprt() const Q_DECL_NOEXCEPT
inline bool QmuParserBase::HasBuiltInOprt() const
{
return m_bBuiltInOp;
}
@ -391,7 +405,7 @@ inline bool QmuParserBase::HasBuiltInOprt() const Q_DECL_NOEXCEPT
* value. This function returns the number of available results.
*/
// cppcheck-suppress unusedFunction
inline int QmuParserBase::GetNumResults() const Q_DECL_NOEXCEPT
inline int QmuParserBase::GetNumResults() const
{
return m_nFinalResultIdx;
}

View file

@ -40,7 +40,7 @@ namespace qmu
* @brief Bytecode default constructor.
*/
// cppcheck-suppress uninitMemberVar
QmuParserByteCode::QmuParserByteCode() Q_DECL_NOEXCEPT
QmuParserByteCode::QmuParserByteCode()
:m_iStackPos(0), m_iMaxStackSize(0), m_vRPN(), m_bEnableOptimizer(true)
{
m_vRPN.reserve(50);
@ -53,7 +53,7 @@ QmuParserByteCode::QmuParserByteCode() Q_DECL_NOEXCEPT
* Implemented in Terms of Assign(const QParserByteCode &a_ByteCode)
*/
// cppcheck-suppress uninitMemberVar
QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT
QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode)
:m_iStackPos(a_ByteCode.m_iStackPos), m_iMaxStackSize(a_ByteCode.m_iMaxStackSize), m_vRPN(a_ByteCode.m_vRPN),
m_bEnableOptimizer(true)
{
@ -67,7 +67,7 @@ QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode) Q_DECL
* Implemented in Terms of Assign(const QParserByteCode &a_ByteCode)
*/
// cppcheck-suppress operatorEqVarError
QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT
QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteCode)
{
Assign(a_ByteCode);
return *this;
@ -79,7 +79,7 @@ QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteC
*
* @throw nowthrow
*/
void QmuParserByteCode::Assign(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT
void QmuParserByteCode::Assign(const QmuParserByteCode &a_ByteCode)
{
if (this==&a_ByteCode)
{
@ -98,7 +98,7 @@ void QmuParserByteCode::Assign(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXC
* @param a_pVar Pointer to be added.
* @throw nothrow
*/
void QmuParserByteCode::AddVar(qreal *a_pVar) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddVar(qreal *a_pVar)
{
++m_iStackPos;
m_iMaxStackSize = qMax(m_iMaxStackSize, static_cast<size_t>(m_iStackPos));
@ -126,7 +126,7 @@ void QmuParserByteCode::AddVar(qreal *a_pVar) Q_DECL_NOEXCEPT
* @param a_pVal Value to be added.
* @throw nothrow
*/
void QmuParserByteCode::AddVal(qreal a_fVal) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddVal(qreal a_fVal)
{
++m_iStackPos;
m_iMaxStackSize = qMax(m_iMaxStackSize, static_cast<size_t>(m_iStackPos));
@ -472,7 +472,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt)
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt)
{
SToken tok;
tok.Cmd = a_Oprt;
@ -491,7 +491,7 @@ void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt) Q_DECL_NOEXCEPT
*
* @sa ParserToken::ECmdCode
*/
void QmuParserByteCode::AddAssignOp(qreal *a_pVar) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddAssignOp(qreal *a_pVar)
{
--m_iStackPos;
@ -508,7 +508,7 @@ void QmuParserByteCode::AddAssignOp(qreal *a_pVar) Q_DECL_NOEXCEPT
* @param a_iArgc Number of arguments, negative numbers indicate multiarg functions.
* @param a_pFun Pointer to function callback.
*/
void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc)
{
if (a_iArgc>=0)
{
@ -535,7 +535,7 @@ void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_NOEX
* @param a_iArgc Number of arguments, negative numbers indicate multiarg functions.
* @param a_pFun Pointer to function callback.
*/
void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc)
{
m_iStackPos = m_iStackPos - a_iArgc + 1;
m_iMaxStackSize = qMax(m_iMaxStackSize, static_cast<size_t>(m_iStackPos));
@ -555,7 +555,7 @@ void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_
* A string function entry consists of the stack position of the return value, followed by a cmSTRFUNC code, the
* function pointer and an index into the string buffer maintained by the parser.
*/
void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx) Q_DECL_NOEXCEPT
void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx)
{
m_iStackPos = m_iStackPos - a_iArgc + 1;
@ -575,7 +575,7 @@ void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iI
*
* @throw nothrow
*/
void QmuParserByteCode::Finalize() Q_DECL_NOEXCEPT
void QmuParserByteCode::Finalize()
{
SToken tok;
tok.Cmd = cmEND;
@ -662,7 +662,7 @@ const SToken* QmuParserByteCode::GetBase() const
* The name of this function is a violation of my own coding guidelines but this way it's more in line with the STL
* functions thus more intuitive.
*/
void QmuParserByteCode::clear() Q_DECL_NOEXCEPT
void QmuParserByteCode::clear()
{
m_vRPN.clear();
m_iStackPos = 0;

View file

@ -81,23 +81,23 @@ struct SToken
class QmuParserByteCode
{
public:
QmuParserByteCode() Q_DECL_NOEXCEPT;
QmuParserByteCode(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT;
QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT;
void Assign(const QmuParserByteCode &a_ByteCode) Q_DECL_NOEXCEPT;
void AddVar(qreal *a_pVar) Q_DECL_NOEXCEPT;
void AddVal(qreal a_fVal) Q_DECL_NOEXCEPT;
QmuParserByteCode();
QmuParserByteCode(const QmuParserByteCode &a_ByteCode);
QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode);
void Assign(const QmuParserByteCode &a_ByteCode);
void AddVar(qreal *a_pVar);
void AddVal(qreal a_fVal);
void AddOp(ECmdCode a_Oprt);
void AddIfElse(ECmdCode a_Oprt) Q_DECL_NOEXCEPT;
void AddAssignOp(qreal *a_pVar) Q_DECL_NOEXCEPT;
void AddFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_NOEXCEPT;
void AddBulkFun(generic_fun_type a_pFun, int a_iArgc) Q_DECL_NOEXCEPT;
void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx) Q_DECL_NOEXCEPT;
void EnableOptimizer(bool bStat) Q_DECL_NOEXCEPT;
void Finalize() Q_DECL_NOEXCEPT;
void clear() Q_DECL_NOEXCEPT;
std::size_t GetMaxStackSize() const Q_DECL_NOEXCEPT;
std::size_t GetSize() const Q_DECL_NOEXCEPT;
void AddIfElse(ECmdCode a_Oprt);
void AddAssignOp(qreal *a_pVar);
void AddFun(generic_fun_type a_pFun, int a_iArgc);
void AddBulkFun(generic_fun_type a_pFun, int a_iArgc);
void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx);
void EnableOptimizer(bool bStat);
void Finalize();
void clear();
std::size_t GetMaxStackSize() const;
std::size_t GetSize() const;
const SToken* GetBase() const;
void AsciiDump();
private:
@ -122,13 +122,13 @@ private:
};
//---------------------------------------------------------------------------------------------------------------------
inline void QmuParserByteCode::EnableOptimizer(bool bStat) Q_DECL_NOEXCEPT
inline void QmuParserByteCode::EnableOptimizer(bool bStat)
{
m_bEnableOptimizer = bStat;
}
//---------------------------------------------------------------------------------------------------------------------
inline std::size_t QmuParserByteCode::GetMaxStackSize() const Q_DECL_NOEXCEPT
inline std::size_t QmuParserByteCode::GetMaxStackSize() const
{
return m_iMaxStackSize+1;
}
@ -138,7 +138,7 @@ inline std::size_t QmuParserByteCode::GetMaxStackSize() const Q_DECL_NOEXCEPT
* @brief Returns the number of entries in the bytecode.
*/
// cppcheck-suppress unusedFunction
inline std::size_t QmuParserByteCode::GetSize() const Q_DECL_NOEXCEPT
inline std::size_t QmuParserByteCode::GetSize() const
{
return m_vRPN.size();
}

View file

@ -34,7 +34,7 @@ namespace qmu
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -44,7 +44,6 @@ QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti ) Q_D
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode )
Q_DECL_NOEXCEPT
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ),
m_iCode ( a_iCode ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -57,7 +56,7 @@ Q_DECL_NOEXCEPT
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -75,7 +74,7 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti ) Q_D
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec,
EOprtAssociativity a_eOprtAsct ) Q_DECL_NOEXCEPT
EOprtAssociativity a_eOprtAsct )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ),
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -84,7 +83,7 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -94,7 +93,7 @@ QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -104,7 +103,7 @@ QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -113,7 +112,7 @@ QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -122,7 +121,7 @@ QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -131,7 +130,7 @@ QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -140,7 +139,7 @@ QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -149,7 +148,7 @@ QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti ) Q_D
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -158,7 +157,7 @@ QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti ) Q_
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -167,7 +166,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -180,7 +179,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -189,7 +188,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -198,7 +197,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -207,7 +206,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -216,7 +215,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -225,7 +224,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -234,7 +233,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -243,7 +242,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -252,7 +251,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -261,7 +260,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -270,7 +269,7 @@ QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -279,7 +278,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -288,7 +287,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
#ifdef __GNUC__
__extension__
#endif
QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{}
@ -298,7 +297,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
* @brief Default constructor.
* @throw nothrow
*/
QmuParserCallback::QmuParserCallback() Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback()
: m_pFun ( 0 ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ),
m_bAllowOpti ( 0 )
{}
@ -308,7 +307,7 @@ QmuParserCallback::QmuParserCallback() Q_DECL_NOEXCEPT
* @brief Copy constructor.
* @throw nothrow
*/
QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref ) Q_DECL_NOEXCEPT
QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref )
: m_pFun ( ref.m_pFun ), m_iArgc ( ref.m_iArgc ), m_iPri ( ref.m_iPri ), m_eOprtAsct ( ref.m_eOprtAsct ),
m_iCode ( ref.m_iCode ), m_iType ( ref.m_iType ), m_bAllowOpti ( ref.m_bAllowOpti )
{

View file

@ -46,47 +46,47 @@ namespace qmu
class QmuParserCallback
{
public:
QmuParserCallback(fun_type0 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type0 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC);
QmuParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity)
Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type2 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type3 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type4 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type5 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type6 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type7 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type8 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type9 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(fun_type10 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
;
QmuParserCallback(fun_type2 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type3 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type4 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type5 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type6 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type7 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type8 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type9 a_pFun, bool a_bAllowOpti);
QmuParserCallback(fun_type10 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti);
QmuParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti);
QmuParserCallback(multfun_type a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti) Q_DECL_NOEXCEPT;
QmuParserCallback() Q_DECL_NOEXCEPT;
QmuParserCallback(const QmuParserCallback &a_Fun) Q_DECL_NOEXCEPT;
QmuParserCallback(multfun_type a_pFun, bool a_bAllowOpti);
QmuParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti);
QmuParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti);
QmuParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti);
QmuParserCallback();
QmuParserCallback(const QmuParserCallback &a_Fun);
QmuParserCallback* Clone() const;
bool IsOptimizable() const Q_DECL_NOEXCEPT;
void* GetAddr() const Q_DECL_NOEXCEPT;
ECmdCode GetCode() const Q_DECL_NOEXCEPT;
ETypeCode GetType() const Q_DECL_NOEXCEPT;
int GetPri() const Q_DECL_NOEXCEPT;
EOprtAssociativity GetAssociativity() const Q_DECL_NOEXCEPT;
int GetArgc() const Q_DECL_NOEXCEPT;
bool IsOptimizable() const;
void* GetAddr() const;
ECmdCode GetCode() const;
ETypeCode GetType() const;
int GetPri() const;
EOprtAssociativity GetAssociativity() const;
int GetArgc() const;
private:
void *m_pFun; ///< Pointer to the callback function, casted to void
@ -127,7 +127,7 @@ inline QmuParserCallback* QmuParserCallback::Clone() const
* @throw nothrow
*/
// cppcheck-suppress unusedFunction
inline bool QmuParserCallback::IsOptimizable() const Q_DECL_NOEXCEPT
inline bool QmuParserCallback::IsOptimizable() const
{
return m_bAllowOpti;
}
@ -141,7 +141,7 @@ inline bool QmuParserCallback::IsOptimizable() const Q_DECL_NOEXCEPT
* @throw nothrow
* @return #pFun
*/
inline void* QmuParserCallback::GetAddr() const Q_DECL_NOEXCEPT
inline void* QmuParserCallback::GetAddr() const
{
return m_pFun;
}
@ -150,13 +150,13 @@ inline void* QmuParserCallback::GetAddr() const Q_DECL_NOEXCEPT
/**
* @brief Return the callback code.
*/
inline ECmdCode QmuParserCallback::GetCode() const Q_DECL_NOEXCEPT
inline ECmdCode QmuParserCallback::GetCode() const
{
return m_iCode;
}
//---------------------------------------------------------------------------------------------------------------------
inline ETypeCode QmuParserCallback::GetType() const Q_DECL_NOEXCEPT
inline ETypeCode QmuParserCallback::GetType() const
{
return m_iType;
}
@ -168,7 +168,7 @@ inline ETypeCode QmuParserCallback::GetType() const Q_DECL_NOEXCEPT
*
* Only valid if the callback token is an operator token (binary or infix).
*/
inline int QmuParserCallback::GetPri() const Q_DECL_NOEXCEPT
inline int QmuParserCallback::GetPri() const
{
return m_iPri;
}
@ -180,7 +180,7 @@ inline int QmuParserCallback::GetPri() const Q_DECL_NOEXCEPT
*
* Only valid if the callback token is a binary operator token.
*/
inline EOprtAssociativity QmuParserCallback::GetAssociativity() const Q_DECL_NOEXCEPT
inline EOprtAssociativity QmuParserCallback::GetAssociativity() const
{
return m_eOprtAsct;
}
@ -189,7 +189,7 @@ inline EOprtAssociativity QmuParserCallback::GetAssociativity() const Q_DECL_NOE
/**
* @brief Returns the number of function Arguments.
*/
inline int QmuParserCallback::GetArgc() const Q_DECL_NOEXCEPT
inline int QmuParserCallback::GetArgc() const
{
return m_iArgc;
}

View file

@ -46,13 +46,8 @@
*/
//#define QMUP_USE_OPENMP
#if defined(_UNICODE)
/** @brief Definition of the basic parser string type. */
#define QMUP_STRING_TYPE std::wstring
#else
/** @brief Definition of the basic parser string type. */
#define QMUP_STRING_TYPE std::string
#endif
/** @brief Definition of the basic parser string type. */
#define QMUP_STRING_TYPE std::wstring
namespace qmu
{

View file

@ -100,7 +100,7 @@ public:
QmuParserErrorMsg();
~QmuParserErrorMsg();
static const QmuParserErrorMsg& Instance() Q_DECL_NOEXCEPT;
static const QmuParserErrorMsg& Instance();
QString operator[] ( unsigned a_iIdx ) const;
private:
@ -111,7 +111,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
inline const QmuParserErrorMsg& QmuParserErrorMsg::Instance() Q_DECL_NOEXCEPT
inline const QmuParserErrorMsg& QmuParserErrorMsg::Instance()
{
return m_Instance;
}
@ -141,12 +141,12 @@ public:
QmuParserError& operator= ( const QmuParserError &a_Obj );
virtual ~QmuParserError() noexcept (true){}
void SetFormula ( const QString &a_strFormula ) Q_DECL_NOEXCEPT;
const QString& GetExpr() const Q_DECL_NOEXCEPT;
const QString& GetMsg() const Q_DECL_NOEXCEPT;
int GetPos() const Q_DECL_NOEXCEPT;
const QString& GetToken() const Q_DECL_NOEXCEPT;
EErrorCodes GetCode() const Q_DECL_NOEXCEPT;
void SetFormula ( const QString &a_strFormula );
const QString& GetExpr() const;
const QString& GetMsg() const;
int GetPos() const;
const QString& GetToken() const;
EErrorCodes GetCode() const;
virtual void raise() const;
virtual QmuParserError *clone() const;
private:
@ -186,7 +186,7 @@ inline QmuParserError *QmuParserError::clone() const
/**
* @brief Set the expression related to this error.
*/
inline void QmuParserError::SetFormula ( const QString &a_strFormula ) Q_DECL_NOEXCEPT
inline void QmuParserError::SetFormula ( const QString &a_strFormula )
{
m_sExpr = a_strFormula;
}
@ -195,7 +195,7 @@ inline void QmuParserError::SetFormula ( const QString &a_strFormula ) Q_DECL_NO
/**
* @brief gets the expression related tp this error.
*/
inline const QString& QmuParserError::GetExpr() const Q_DECL_NOEXCEPT
inline const QString& QmuParserError::GetExpr() const
{
return m_sExpr;
}
@ -204,7 +204,7 @@ inline const QString& QmuParserError::GetExpr() const Q_DECL_NOEXCEPT
/**
* @brief Returns the message string for this error.
*/
inline const QString& QmuParserError::GetMsg() const Q_DECL_NOEXCEPT
inline const QString& QmuParserError::GetMsg() const
{
return m_sMsg;
}
@ -215,7 +215,7 @@ inline const QString& QmuParserError::GetMsg() const Q_DECL_NOEXCEPT
*
* If the error is not related to a distinct position this will return -1
*/
inline int QmuParserError::GetPos() const Q_DECL_NOEXCEPT
inline int QmuParserError::GetPos() const
{
return m_iPos;
}
@ -224,7 +224,7 @@ inline int QmuParserError::GetPos() const Q_DECL_NOEXCEPT
/**
* @brief Return string related with this token (if available).
*/
inline const QString& QmuParserError::GetToken() const Q_DECL_NOEXCEPT
inline const QString& QmuParserError::GetToken() const
{
return m_sTok;
}
@ -233,7 +233,7 @@ inline const QString& QmuParserError::GetToken() const Q_DECL_NOEXCEPT
/**
* @brief Return the error code.
*/
inline EErrorCodes QmuParserError::GetCode() const Q_DECL_NOEXCEPT
inline EErrorCodes QmuParserError::GetCode() const
{
return m_iErrc;
}

View file

@ -69,11 +69,7 @@ int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_f
unsigned iVal ( 0 );
#if defined(_UNICODE)
std::wstring a_szExprStd = a_szExpr.mid(2).toStdWString();
#else
std::string a_szExprStd = a_szExpr.mid(2).toStdString();
#endif
// New code based on streams for UNICODE compliance:
stringstream_type::pos_type nPos(0);

View file

@ -270,7 +270,7 @@ public:
* @return #m_iType
* @throw nothrow
*/
ECmdCode GetCode() const Q_DECL_NOEXCEPT
ECmdCode GetCode() const
{
if ( m_pCallback.get() )
{
@ -442,7 +442,7 @@ public:
* @throw nothrow
* @sa m_strTok
*/
const TString& GetAsString() const Q_DECL_NOEXCEPT
const TString& GetAsString() const
{
return m_strTok;
}

View file

@ -43,7 +43,7 @@ class QmuParserBase;
* @sa Assign
* @throw nothrow
*/
QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reader ) Q_DECL_NOEXCEPT
QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reader )
:m_pParser( a_Reader.m_pParser ), m_strFormula( a_Reader.m_strFormula ), m_iPos( a_Reader.m_iPos ),
m_iSynFlags( a_Reader.m_iSynFlags ), m_bIgnoreUndefVar( a_Reader.m_bIgnoreUndefVar ),
m_pFunDef( a_Reader.m_pFunDef ), m_pPostOprtDef( a_Reader.m_pPostOprtDef ),
@ -63,7 +63,7 @@ QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reade
* @param a_Reader Object to copy to this token reader.
* @throw nothrow
*/
QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader ) Q_DECL_NOEXCEPT
QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenReader &a_Reader )
{
if ( &a_Reader != this )
{
@ -80,7 +80,7 @@ QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenRead
* @param a_Reader Object from which the state should be copied.
* @throw nothrow
*/
void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader ) Q_DECL_NOEXCEPT
void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader )
{
m_pParser = a_Reader.m_pParser;
m_strFormula = a_Reader.m_strFormula;
@ -116,7 +116,7 @@ void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader ) Q_DEC
* @post #m_pParser==a_pParser
* @param a_pParent Parent parser object of the token reader.
*/
QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent ) Q_DECL_NOEXCEPT
QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent )
: m_pParser ( a_pParent ), m_strFormula(), m_iPos ( 0 ), m_iSynFlags ( 0 ), m_bIgnoreUndefVar ( false ),
m_pFunDef ( nullptr ), m_pPostOprtDef ( nullptr ), m_pInfixOprtDef ( nullptr ), m_pOprtDef ( nullptr ),
m_pConstDef ( nullptr ), m_pStrVarDef ( nullptr ), m_pVarDef ( nullptr ), m_pFactory ( nullptr ),
@ -136,7 +136,7 @@ QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent ) Q_DECL_N
* @return A new QParserTokenReader object.
* @throw nothrow
*/
QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const Q_DECL_NOEXCEPT
QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) const
{
std::unique_ptr<QmuParserTokenReader> ptr ( new QmuParserTokenReader ( *this ) );
ptr->SetParent ( a_pParent );
@ -144,7 +144,7 @@ QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) c
}
//---------------------------------------------------------------------------------------------------------------------
QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) Q_DECL_NOEXCEPT
QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok )
{
m_lastTok = tok;
return m_lastTok;
@ -163,7 +163,7 @@ void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback )
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData ) Q_DECL_NOEXCEPT
void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData )
{
m_pFactory = a_pFactory;
m_pFactoryData = pUserData;
@ -176,7 +176,7 @@ void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserDa
* Sets the formula position index to zero and set Syntax flags to default for initial formula parsing.
* @pre [assert] triggered if a_szFormula==0
*/
void QmuParserTokenReader::SetFormula ( const QString &a_strFormula ) Q_DECL_NOEXCEPT
void QmuParserTokenReader::SetFormula ( const QString &a_strFormula )
{
m_strFormula = a_strFormula;
ReInit();
@ -191,7 +191,7 @@ void QmuParserTokenReader::SetFormula ( const QString &a_strFormula ) Q_DECL_NOE
* @throw nothrow
* @sa ESynCodes
*/
void QmuParserTokenReader::ReInit() Q_DECL_NOEXCEPT
void QmuParserTokenReader::ReInit()
{
m_iPos = 0;
m_iSynFlags = sfSTART_OF_LINE;
@ -289,7 +289,7 @@ QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken()
}
//---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) Q_DECL_NOEXCEPT
void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
{
m_pParser = a_pParent;
m_pFunDef = &a_pParent->m_FunDef;
@ -311,15 +311,10 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) Q_DECL_NOEXCEP
* @return The Position of the first character not listed in a_szCharSet.
* @throw nothrow
*/
int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const Q_DECL_NOEXCEPT
int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_sTok, int a_iPos ) const
{
#if defined(_UNICODE)
const std::wstring m_strFormulaStd = m_strFormula.toStdWString();
const std::wstring a_szCharSetStd = a_szCharSet.toStdWString();
#else
const std::string m_strFormulaStd = m_strFormula.toStdString();
const std::string a_szCharSetStd = a_szCharSet.toStdString();
#endif
int iEnd = static_cast<int>(m_strFormulaStd.find_first_not_of ( a_szCharSetStd, a_iPos ));
@ -331,13 +326,8 @@ int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_
// Assign token string if there was something found
if ( a_iPos != iEnd )
{
#if defined(_UNICODE)
a_sTok = QString().fromStdWString ( std::wstring ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#else
a_sTok = QString().fromStdString ( std::string ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#endif
}
return iEnd;
@ -353,13 +343,9 @@ int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_
*/
int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) const
{
#if defined(_UNICODE)
const std::wstring m_strFormulaStd = m_strFormula.toStdWString();
const std::wstring oprtCharsStd = m_pParser->ValidInfixOprtChars().toStdWString();
#else
const std::string m_strFormulaStd = m_strFormula.toStdString();
const std::string oprtCharsStd = m_pParser->ValidInfixOprtChars().toStdString();
#endif
int iEnd = static_cast<int>( m_strFormulaStd.find_first_not_of ( oprtCharsStd, a_iPos ) );
if ( iEnd == static_cast<int>( string_type::npos ) )
{
@ -369,13 +355,8 @@ int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) c
// Assign token string if there was something found
if ( a_iPos != iEnd )
{
#if defined(_UNICODE)
a_sTok = QString().fromStdWString ( string_type ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#else
a_sTok = QString().fromStdString ( string_type ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#endif
return iEnd;
}
else
@ -549,12 +530,6 @@ bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok )
*/
bool QmuParserTokenReader::IsEOF ( token_type &a_Tok )
{
//#if defined(_UNICODE)
// const char_type* szFormula = m_strFormula.toStdWString().c_str();
//#else
// const char_type* szFormula = m_strFormula.toStdString().c_str();
//#endif
// check for EOF
if ( m_strFormula.data()[m_iPos] == false /*|| szFormula[m_iPos] == '\n'*/ )
{
@ -848,8 +823,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok )
if ( ( *item ) ( m_strFormula.mid ( m_iPos ), &m_iPos, &fVal ) == 1 )
{
// 2013-11-27 Issue 2: https://code.google.com/p/muparser/issues/detail?id=2
//strTok = m_strFormula.mid ( iStart, m_iPos-iStart );
strTok = m_strFormula.mid ( iStart, m_iPos );
strTok = m_strFormula.mid ( iStart, m_iPos-iStart );
if ( m_iSynFlags & noVAL )
{
Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok );
@ -955,7 +929,7 @@ bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok )
* @return true if a variable token has been found.
* @throw nothrow
*/
bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok ) Q_DECL_NOEXCEPT
bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok )
{
QString strTok;
int iEnd ( ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ) );

View file

@ -45,19 +45,19 @@ class QmuParserTokenReader
private:
typedef QmuParserToken<qreal, QString> token_type;
public:
QmuParserTokenReader(QmuParserBase *a_pParent) Q_DECL_NOEXCEPT;
QmuParserTokenReader* Clone(QmuParserBase *a_pParent) const Q_DECL_NOEXCEPT;
QmuParserTokenReader(QmuParserBase *a_pParent);
QmuParserTokenReader* Clone(QmuParserBase *a_pParent) const;
void AddValIdent(identfun_type a_pCallback);
void SetVarCreator(facfun_type a_pFactory, void *pUserData) Q_DECL_NOEXCEPT;
void SetFormula(const QString &a_strFormula) Q_DECL_NOEXCEPT;
void SetArgSep(char_type cArgSep) Q_DECL_NOEXCEPT;
int GetPos() const Q_DECL_NOEXCEPT;
const QString& GetExpr() const Q_DECL_NOEXCEPT;
varmap_type& GetUsedVar() Q_DECL_NOEXCEPT;
QChar GetArgSep() const Q_DECL_NOEXCEPT;
void IgnoreUndefVar(bool bIgnore) Q_DECL_NOEXCEPT;
void ReInit() Q_DECL_NOEXCEPT;
void SetVarCreator(facfun_type a_pFactory, void *pUserData);
void SetFormula(const QString &a_strFormula);
void SetArgSep(char_type cArgSep);
int GetPos() const;
const QString& GetExpr() const;
varmap_type& GetUsedVar();
QChar GetArgSep() const;
void IgnoreUndefVar(bool bIgnore);
void ReInit();
token_type ReadNextToken();
private:
@ -88,12 +88,12 @@ private:
noANY = ~0 ///< All of he above flags set
};
QmuParserTokenReader(const QmuParserTokenReader &a_Reader) Q_DECL_NOEXCEPT;
QmuParserTokenReader& operator=(const QmuParserTokenReader &a_Reader) Q_DECL_NOEXCEPT;
void Assign(const QmuParserTokenReader &a_Reader) Q_DECL_NOEXCEPT;
QmuParserTokenReader(const QmuParserTokenReader &a_Reader);
QmuParserTokenReader& operator=(const QmuParserTokenReader &a_Reader);
void Assign(const QmuParserTokenReader &a_Reader);
void SetParent(QmuParserBase *a_pParent) Q_DECL_NOEXCEPT;
int ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const Q_DECL_NOEXCEPT;
void SetParent(QmuParserBase *a_pParent);
int ExtractToken(const QString &a_szCharSet, QString &a_strTok, int a_iPos) const;
int ExtractOperatorToken(QString &a_sTok, int a_iPos) const;
bool IsBuiltIn(token_type &a_Tok);
@ -106,11 +106,11 @@ private:
bool IsValTok(token_type &a_Tok);
bool IsVarTok(token_type &a_Tok);
bool IsStrVarTok(token_type &a_Tok);
bool IsUndefVarTok(token_type &a_Tok) Q_DECL_NOEXCEPT;
bool IsUndefVarTok(token_type &a_Tok);
bool IsString(token_type &a_Tok);
void Q_NORETURN Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_sTok = QString() ) const;
token_type& SaveBeforeReturn(const token_type &tok) Q_DECL_NOEXCEPT;
token_type& SaveBeforeReturn(const token_type &tok);
QmuParserBase *m_pParser;
QString m_strFormula;
@ -142,7 +142,7 @@ private:
* @return #m_iPos
* @throw nothrow
*/
inline int QmuParserTokenReader::GetPos() const Q_DECL_NOEXCEPT
inline int QmuParserTokenReader::GetPos() const
{
return m_iPos;
}
@ -154,7 +154,7 @@ inline int QmuParserTokenReader::GetPos() const Q_DECL_NOEXCEPT
* @return #m_strFormula
* @throw nothrow
*/
inline const QString& QmuParserTokenReader::GetExpr() const Q_DECL_NOEXCEPT
inline const QString& QmuParserTokenReader::GetExpr() const
{
return m_strFormula;
}
@ -163,7 +163,7 @@ inline const QString& QmuParserTokenReader::GetExpr() const Q_DECL_NOEXCEPT
/**
* @brief Return a map containing the used variables only.
*/
inline varmap_type& QmuParserTokenReader::GetUsedVar() Q_DECL_NOEXCEPT
inline varmap_type& QmuParserTokenReader::GetUsedVar()
{
return m_UsedVar;
}
@ -177,19 +177,19 @@ inline varmap_type& QmuParserTokenReader::GetUsedVar() Q_DECL_NOEXCEPT
* 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 ) Q_DECL_NOEXCEPT
inline void QmuParserTokenReader::IgnoreUndefVar ( bool bIgnore )
{
m_bIgnoreUndefVar = bIgnore;
}
//---------------------------------------------------------------------------------------------------------------------
inline void QmuParserTokenReader::SetArgSep ( char_type cArgSep ) Q_DECL_NOEXCEPT
inline void QmuParserTokenReader::SetArgSep ( char_type cArgSep )
{
m_cArgSep = cArgSep;
}
//---------------------------------------------------------------------------------------------------------------------
inline QChar QmuParserTokenReader::GetArgSep() const Q_DECL_NOEXCEPT
inline QChar QmuParserTokenReader::GetArgSep() const
{
return m_cArgSep;
}