--HG--
branch : feature
This commit is contained in:
dismine 2014-05-01 14:33:40 +03:00
parent 37ecf9fd86
commit 362638066a
41 changed files with 7158 additions and 7036 deletions

View File

@ -61,7 +61,3 @@ qreal VMeasurement::GetValue(const qreal &size, const qreal &height) const
const qreal k_height = ( height - 176.0 ) / 6.0; const qreal k_height = ( height - 176.0 ) / 6.0;
return base + k_size * ksize + k_height * kheight; return base + k_size * ksize + k_height * kheight;
} }

View File

@ -105,8 +105,8 @@ void DialogDetail::DialogAccepted()
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const NodeDetail::NodeDetails &typeNode, qreal mx, void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const NodeDetail::NodeDetails &typeNode,
qreal my) qreal mx, qreal my)
{ {
QString name; QString name;
switch (typeTool) switch (typeTool)

View File

@ -133,7 +133,8 @@ private:
* @param idDetail id detail * @param idDetail id detail
* @param index index of edge * @param index index of edge
*/ */
void ChoosedDetail(const quint32 &id, const Valentina::Scenes &type, quint32 &idDetail, ptrdiff_t &index); void ChoosedDetail(const quint32 &id, const Valentina::Scenes &type, quint32 &idDetail,
ptrdiff_t &index);
}; };
inline quint32 DialogUnionDetails::getD1() const inline quint32 DialogUnionDetails::getD1() const

View File

@ -70,7 +70,8 @@ void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, c
{ {
QByteArray localMsg = msg.toLocal8Bit(); QByteArray localMsg = msg.toLocal8Bit();
QMessageBox messageBox; QMessageBox messageBox;
switch (type) { switch (type)
{
case QtDebugMsg: case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line,
context.function); context.function);

View File

@ -157,8 +157,8 @@ void MainWindow::ActionNewDraw()
pattern->ClearGObjects(); pattern->ClearGObjects();
//Create single point //Create single point
const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10), "А", 5, const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10),
10)); "А", 5, 10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui); VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui);
sceneDraw->addItem(spoint); sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
@ -261,8 +261,8 @@ void MainWindow::ClosedDialogLine(int result)
void MainWindow::ToolAlongLine(bool checked) void MainWindow::ToolAlongLine(bool checked)
{ {
SetToolButton<DialogAlongLine>(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png", tr("Select point"), SetToolButton<DialogAlongLine>(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png",
&MainWindow::ClosedDialogAlongLine); tr("Select point"), &MainWindow::ClosedDialogAlongLine);
} }
void MainWindow::ClosedDialogAlongLine(int result) void MainWindow::ClosedDialogAlongLine(int result)
@ -360,8 +360,9 @@ void MainWindow::ClosedDialogSplinePath(int result)
void MainWindow::ToolCutSplinePath(bool checked) void MainWindow::ToolCutSplinePath(bool checked)
{ {
SetToolButton<DialogCutSplinePath>(checked, Valentina::CutSplinePathTool, ":/cursor/splinepath_cut_point_cursor.png", SetToolButton<DialogCutSplinePath>(checked, Valentina::CutSplinePathTool,
tr("Select curve path"), &MainWindow::ClosedDialogCutSplinePath); ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"),
&MainWindow::ClosedDialogCutSplinePath);
} }
void MainWindow::ClosedDialogCutSplinePath(int result) void MainWindow::ClosedDialogCutSplinePath(int result)
@ -420,8 +421,9 @@ void MainWindow::ClosedDialogTriangle(int result)
void MainWindow::ToolPointOfIntersection(bool checked) void MainWindow::ToolPointOfIntersection(bool checked)
{ {
SetToolButton<DialogPointOfIntersection>(checked, Valentina::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", SetToolButton<DialogPointOfIntersection>(checked, Valentina::PointOfIntersection,
tr("Select point vertically"), &MainWindow::ClosedDialogPointOfIntersection); ":/cursor/pointofintersect_cursor.png", tr("Select point vertically"),
&MainWindow::ClosedDialogPointOfIntersection);
} }
void MainWindow::ClosedDialogPointOfIntersection(int result) void MainWindow::ClosedDialogPointOfIntersection(int result)
@ -431,8 +433,8 @@ void MainWindow::ClosedDialogPointOfIntersection(int result)
void MainWindow::ToolUnionDetails(bool checked) void MainWindow::ToolUnionDetails(bool checked)
{ {
SetToolButton<DialogUnionDetails>(checked, Valentina::UnionDetails, ":/cursor/union_cursor.png", tr("Select detail"), SetToolButton<DialogUnionDetails>(checked, Valentina::UnionDetails, ":/cursor/union_cursor.png",
&MainWindow::ClosedDialogUnionDetails); tr("Select detail"), &MainWindow::ClosedDialogUnionDetails);
//Must disconnect this signal here. //Must disconnect this signal here.
disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList);
} }

View File

@ -31,9 +31,9 @@
const QString VToolTriangle::ToolType = QStringLiteral("triangle"); const QString VToolTriangle::ToolType = QStringLiteral("triangle");
VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id,
const quint32 &axisP1Id, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId,
const quint32 &secondPointId, const Valentina::Sources &typeCreation, QGraphicsItem *parent) const Valentina::Sources &typeCreation, QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId),
secondPointId(secondPointId) secondPointId(secondPointId)
{ {

View File

@ -48,8 +48,9 @@ public:
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
* @param parent parent object. * @param parent parent object.
*/ */
VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Valentina::Sources &typeCreation, VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); const Valentina::Sources &typeCreation, const quint32 &idTool = 0,
QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
/** /**
* @brief Create help create tool. * @brief Create help create tool.
* @param doc dom document container. * @param doc dom document container.

View File

@ -48,9 +48,8 @@ public:
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
* @param parent parent object. * @param parent parent object.
*/ */
VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Valentina::Sources &typeCreation,
const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *qoParent = nullptr, const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr );
QGraphicsItem * parent = nullptr );
/** /**
* @brief Create help create tool. * @brief Create help create tool.
* @param doc dom document container. * @param doc dom document container.
@ -60,9 +59,8 @@ public:
* @param parse parser file mode. * @param parse parser file mode.
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document::Documents &parse,
const Document::Documents &parse, const Valentina::Sources &typeCreation, const quint32 &idTool = 0, const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
QObject *parent = nullptr);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
/** /**

View File

@ -48,9 +48,8 @@ public:
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
* @param parent parent object. * @param parent parent object.
*/ */
VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Valentina::Sources &typeCreation,
const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *qoParent = nullptr, const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr);
QGraphicsItem * parent = nullptr);
/** /**
* @brief Create help create tool. * @brief Create help create tool.
* @param doc dom document container. * @param doc dom document container.

View File

@ -53,8 +53,8 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu
} }
void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
const Document::Documents &parse, const Valentina::Sources &typeCreation, const quint32 &idTool, const Document::Documents &parse, const Valentina::Sources &typeCreation,
QObject *parent) const quint32 &idTool, QObject *parent)
{ {
VAbstractTool::AddRecord(id, Valentina::NodeSplinePath, doc); VAbstractTool::AddRecord(id, Valentina::NodeSplinePath, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)

View File

@ -60,9 +60,8 @@ public:
* @param parse parser file mode. * @param parse parser file mode.
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document::Documents &parse,
const Document::Documents &parse, const Valentina::Sources &typeCreation, const quint32 &idTool = 0, const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *parent = 0);
QObject *parent = 0);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
/** /**

View File

@ -293,7 +293,8 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
pattern.close(); pattern.close();
fileSchema.close(); fileSchema.close();
VException e(messageHandler.statusMessage()); VException e(messageHandler.statusMessage());
e.AddMoreInformation(tr("Validation error in line %1 column %2").arg(messageHandler.line()).arg(messageHandler.column())); e.AddMoreInformation(tr("Validation error in line %1 column %2").arg(messageHandler.line())
.arg(messageHandler.column()));
throw e; throw e;
} }
pattern.close(); pattern.close();

View File

@ -1049,7 +1049,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse, Valentina::FromFile); VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
Valentina::FromFile);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {

View File

@ -66,7 +66,7 @@ qreal QmuParser::ATanh(qreal v)
{ {
return (0.5 * log((1 + v) / (1 - v))); return (0.5 * log((1 + v) / (1 - v)));
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// Logarithm functions // Logarithm functions
// Logarithm base 2 // Logarithm base 2
@ -93,7 +93,7 @@ qreal QmuParser::Log10(qreal v)
return log10(v); return log10(v);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// misc // misc
qreal QmuParser::Abs(qreal v) qreal QmuParser::Abs(qreal v)
{ {
@ -110,7 +110,7 @@ qreal QmuParser::Sign(qreal v)
return ((v<0) ? -1 : (v>0) ? 1 : 0); return ((v<0) ? -1 : (v>0) ? 1 : 0);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Callback for the unary minus operator. * @brief Callback for the unary minus operator.
* @param v The value to negate * @param v The value to negate
@ -121,7 +121,7 @@ qreal QmuParser::UnaryMinus(qreal v)
return -v; return -v;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Callback for adding multiple values. * @brief Callback for adding multiple values.
* @param [in] a_afArg Vector with the function arguments * @param [in] a_afArg Vector with the function arguments
@ -129,16 +129,19 @@ qreal QmuParser::UnaryMinus(qreal v)
*/ */
qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc) qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc)
{ {
if (!a_iArgc) if (a_iArgc == false)
{ {
throw exception_type("too few arguments for function sum."); throw exception_type("too few arguments for function sum.");
} }
qreal fRes=0; qreal fRes=0;
for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; for (int i=0; i<a_iArgc; ++i)
{
fRes += a_afArg[i];
}
return fRes; return fRes;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Callback for averaging multiple values. * @brief Callback for averaging multiple values.
* @param [in] a_afArg Vector with the function arguments * @param [in] a_afArg Vector with the function arguments
@ -146,16 +149,19 @@ qreal QmuParser::Sum(const qreal *a_afArg, int a_iArgc)
*/ */
qreal QmuParser::Avg(const qreal *a_afArg, int a_iArgc) qreal QmuParser::Avg(const qreal *a_afArg, int a_iArgc)
{ {
if (!a_iArgc) if (a_iArgc == false)
{ {
throw exception_type("too few arguments for function sum."); throw exception_type("too few arguments for function sum.");
} }
qreal fRes=0; qreal fRes=0;
for (int i=0; i<a_iArgc; ++i) fRes += a_afArg[i]; for (int i=0; i<a_iArgc; ++i)
{
fRes += a_afArg[i];
}
return fRes/static_cast<qreal>(a_iArgc); return fRes/static_cast<qreal>(a_iArgc);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Callback for determining the minimum value out of a vector. * @brief Callback for determining the minimum value out of a vector.
* @param [in] a_afArg Vector with the function arguments * @param [in] a_afArg Vector with the function arguments
@ -163,7 +169,7 @@ qreal QmuParser::Avg(const qreal *a_afArg, int a_iArgc)
*/ */
qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc) qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc)
{ {
if (!a_iArgc) if (a_iArgc == false)
{ {
throw exception_type("too few arguments for function min."); throw exception_type("too few arguments for function min.");
} }
@ -175,7 +181,7 @@ qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc)
return fRes; return fRes;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Callback for determining the maximum value out of a vector. * @brief Callback for determining the maximum value out of a vector.
* @param [in] a_afArg Vector with the function arguments * @param [in] a_afArg Vector with the function arguments
@ -183,7 +189,7 @@ qreal QmuParser::Min(const qreal *a_afArg, int a_iArgc)
*/ */
qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc) qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc)
{ {
if (!a_iArgc) if (a_iArgc == false)
{ {
throw exception_type("too few arguments for function min."); throw exception_type("too few arguments for function min.");
} }
@ -195,7 +201,7 @@ qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc)
return fRes; return fRes;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Default value recognition callback. * @brief Default value recognition callback.
* @param [in] a_szExpr Pointer to the expression * @param [in] a_szExpr Pointer to the expression
@ -228,7 +234,7 @@ int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal)
return 1; return 1;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor. * @brief Constructor.
* *
@ -244,7 +250,7 @@ QmuParser::QmuParser():QmuParserBase()
InitOprt(); InitOprt();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define the character sets. * @brief Define the character sets.
* @sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars * @sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars
@ -259,7 +265,7 @@ void QmuParser::InitCharSets()
DefineInfixOprtChars( "/+-*^?<>=#!$%&|~'_" ); DefineInfixOprtChars( "/+-*^?<>=#!$%&|~'_" );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize the default functions. * @brief Initialize the default functions.
*/ */
@ -300,7 +306,7 @@ void QmuParser::InitFun()
DefineFun("max", Max); DefineFun("max", Max);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize constants. * @brief Initialize constants.
* *
@ -313,7 +319,7 @@ void QmuParser::InitConst()
DefineConst("_e", (qreal)M_E); DefineConst("_e", (qreal)M_E);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize operators. * @brief Initialize operators.
* *
@ -324,7 +330,7 @@ void QmuParser::InitOprt()
DefineInfixOprt("-", UnaryMinus); DefineInfixOprt("-", UnaryMinus);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd)
{ {
Q_UNUSED(pExpr); Q_UNUSED(pExpr);
@ -352,7 +358,7 @@ void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd)
*/ */
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Numerically differentiate with regard to a variable. * @brief Numerically differentiate with regard to a variable.
* @param [in] a_Var Pointer to the differentiation variable. * @param [in] a_Var Pointer to the differentiation variable.

View File

@ -51,7 +51,7 @@ const QStringList QmuParserBase::c_DefaultOprt = QStringList() << "<=" << ">=" <
<< "+" << "-" << "*" << "/" << "^" << "&&" << "+" << "-" << "*" << "/" << "^" << "&&"
<< "||" << "=" << "(" << ")" << "?" << ":"; << "||" << "=" << "(" << ")" << "?" << ":";
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor. * @brief Constructor.
* @param a_szFormula the formula to interpret. * @param a_szFormula the formula to interpret.
@ -66,7 +66,7 @@ QmuParserBase::QmuParserBase()
InitTokenReader(); InitTokenReader();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy constructor. * @brief Copy constructor.
* *
@ -82,11 +82,11 @@ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser)
Assign(a_Parser); Assign(a_Parser);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserBase::~QmuParserBase() QmuParserBase::~QmuParserBase()
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Assignement operator. * @brief Assignement operator.
* *
@ -101,7 +101,7 @@ QmuParserBase& QmuParserBase::operator=(const QmuParserBase &a_Parser)
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy state of a parser object to this. * @brief Copy state of a parser object to this.
* *
@ -144,7 +144,7 @@ void QmuParserBase::Assign(const QmuParserBase &a_Parser)
m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; m_sInfixOprtChars = a_Parser.m_sInfixOprtChars;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set the decimal separator. * @brief Set the decimal separator.
* @param cDecSep Decimal separator as a character value. * @param cDecSep Decimal separator as a character value.
@ -159,7 +159,7 @@ void QmuParserBase::SetDecSep(char_type cDecSep)
s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep));
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Sets the thousands operator. * @brief Sets the thousands operator.
* @param cThousandsSep The thousands separator as a character * @param cThousandsSep The thousands separator as a character
@ -174,7 +174,7 @@ void QmuParserBase::SetThousandsSep(char_type cThousandsSep)
s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep)); s_locale = std::locale(std::locale("C"), new change_dec_sep<char_type>(cDecSep, cThousandsSep));
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Resets the locale. * @brief Resets the locale.
* *
@ -186,7 +186,7 @@ void QmuParserBase::ResetLocale()
SetArgSep(','); SetArgSep(',');
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize the token reader. * @brief Initialize the token reader.
* *
@ -200,7 +200,7 @@ void QmuParserBase::InitTokenReader()
m_pTokenReader.reset(new token_reader_type(this)); m_pTokenReader.reset(new token_reader_type(this));
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Reset parser to string parsing mode and clear internal buffers. * @brief Reset parser to string parsing mode and clear internal buffers.
* *
@ -216,7 +216,7 @@ void QmuParserBase::ReInit() const
m_nIfElseCounter = 0; m_nIfElseCounter = 0;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserBase::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd) void QmuParserBase::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd)
{ {
Q_UNUSED(pExpr); Q_UNUSED(pExpr);
@ -224,7 +224,7 @@ void QmuParserBase::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd)
Q_UNUSED(nEnd); Q_UNUSED(nEnd);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Returns the version of muparser. * @brief Returns the version of muparser.
* @param eInfo A flag indicating whether the full version info should be returned or not. * @param eInfo A flag indicating whether the full version info should be returned or not.
@ -276,7 +276,7 @@ QString QmuParserBase::GetVersion(EParserVersionInfo eInfo) const
return versionInfo; return versionInfo;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a value parsing function. * @brief Add a value parsing function.
* *
@ -288,7 +288,7 @@ void QmuParserBase::AddValIdent(identfun_type a_pCallback)
m_pTokenReader->AddValIdent(a_pCallback); m_pTokenReader->AddValIdent(a_pCallback);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set a function that can create variable pointer for unknown expression variables. * @brief Set a function that can create variable pointer for unknown expression variables.
* @param a_pFactory A pointer to the variable factory. * @param a_pFactory A pointer to the variable factory.
@ -299,7 +299,7 @@ void QmuParserBase::SetVarFactory(facfun_type a_pFactory, void *pUserData)
m_pTokenReader->SetVarCreator(a_pFactory, pUserData); m_pTokenReader->SetVarCreator(a_pFactory, pUserData);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a function or operator callback to the parser. * @brief Add a function or operator callback to the parser.
*/ */
@ -339,7 +339,7 @@ void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallbac
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a name contains invalid characters. * @brief Check if a name contains invalid characters.
* *
@ -355,7 +355,7 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a
const std::string a_sNameStd = a_sName.toStdString(); const std::string a_sNameStd = a_sName.toStdString();
const std::string a_szCharSetStd = a_szCharSet.toStdString(); const std::string a_szCharSetStd = a_szCharSet.toStdString();
#endif #endif
if ( !a_sNameStd.length() || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) || 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')) (a_sNameStd.at(0)>='0' && a_sNameStd.at(0)<='9'))
{ {
switch (a_Callback.GetCode()) switch (a_Callback.GetCode())
@ -475,7 +475,7 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a name contains invalid characters. * @brief Check if a name contains invalid characters.
* *
@ -490,14 +490,14 @@ void QmuParserBase::CheckName(const QString &a_sName, const QString &a_szCharSet
std::string a_sNameStd = a_sName.toStdString(); std::string a_sNameStd = a_sName.toStdString();
std::string a_szCharSetStd = a_szCharSet.toStdString(); std::string a_szCharSetStd = a_szCharSet.toStdString();
#endif #endif
if ( !a_sNameStd.length() || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) || if ( a_sNameStd.length() == false || (a_sNameStd.find_first_not_of(a_szCharSetStd)!=string_type::npos) ||
(a_sNameStd[0]>='0' && a_sNameStd[0]<='9')) (a_sNameStd[0]>='0' && a_sNameStd[0]<='9'))
{ {
Error(ecINVALID_NAME); Error(ecINVALID_NAME);
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set the formula. * @brief Set the formula.
* @param a_strFormula Formula as string_type * @param a_strFormula Formula as string_type
@ -524,7 +524,7 @@ void QmuParserBase::SetExpr(const QString &a_sExpr)
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Get the default symbols used for the built in operators. * @brief Get the default symbols used for the built in operators.
* @sa c_DefaultOprt * @sa c_DefaultOprt
@ -534,7 +534,7 @@ const QStringList &QmuParserBase::GetOprtDef() const
return c_DefaultOprt; return c_DefaultOprt;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define the set of valid characters to be used in names of functions, variables, constants. * @brief Define the set of valid characters to be used in names of functions, variables, constants.
*/ */
@ -543,7 +543,7 @@ void QmuParserBase::DefineNameChars(const QString &a_szCharset)
m_sNameChars = a_szCharset; m_sNameChars = a_szCharset;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define the set of valid characters to be used in names of binary operators and postfix operators. * @brief Define the set of valid characters to be used in names of binary operators and postfix operators.
*/ */
@ -552,7 +552,7 @@ void QmuParserBase::DefineOprtChars(const QString &a_szCharset)
m_sOprtChars = a_szCharset; m_sOprtChars = a_szCharset;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define the set of valid characters to be used in names of infix operators. * @brief Define the set of valid characters to be used in names of infix operators.
*/ */
@ -561,7 +561,7 @@ void QmuParserBase::DefineInfixOprtChars(const QString &a_szCharset)
m_sInfixOprtChars = a_szCharset; m_sInfixOprtChars = a_szCharset;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Virtual function that defines the characters allowed in name identifiers. * @brief Virtual function that defines the characters allowed in name identifiers.
* @sa #ValidOprtChars, #ValidPrefixOprtChars * @sa #ValidOprtChars, #ValidPrefixOprtChars
@ -572,7 +572,7 @@ const QString& QmuParserBase::ValidNameChars() const
return m_sNameChars; return m_sNameChars;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Virtual function that defines the characters allowed in operator definitions. * @brief Virtual function that defines the characters allowed in operator definitions.
* @sa #ValidNameChars, #ValidPrefixOprtChars * @sa #ValidNameChars, #ValidPrefixOprtChars
@ -583,7 +583,7 @@ const QString &QmuParserBase::ValidOprtChars() const
return m_sOprtChars; return m_sOprtChars;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Virtual function that defines the characters allowed in infix operator definitions. * @brief Virtual function that defines the characters allowed in infix operator definitions.
* @sa #ValidNameChars, #ValidOprtChars * @sa #ValidNameChars, #ValidOprtChars
@ -594,7 +594,7 @@ const QString &QmuParserBase::ValidInfixOprtChars() const
return m_sInfixOprtChars; return m_sInfixOprtChars;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a user defined operator. * @brief Add a user defined operator.
* @post Will reset the Parser to string parsing mode. * @post Will reset the Parser to string parsing mode.
@ -605,7 +605,7 @@ void QmuParserBase::DefinePostfixOprt(const QString &a_sName, fun_type1 a_pFun,
ValidOprtChars() ); ValidOprtChars() );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize user defined functions. * @brief Initialize user defined functions.
* *
@ -619,7 +619,7 @@ void QmuParserBase::Init()
InitOprt(); InitOprt();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a user defined operator. * @brief Add a user defined operator.
* @post Will reset the Parser to string parsing mode. * @post Will reset the Parser to string parsing mode.
@ -635,7 +635,7 @@ void QmuParserBase::DefineInfixOprt(const QString &a_sName, fun_type1 a_pFun, in
ValidInfixOprtChars() ); ValidInfixOprtChars() );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define a binary operator. * @brief Define a binary operator.
* @param [in] a_sName The identifier of the operator. * @param [in] a_sName The identifier of the operator.
@ -662,7 +662,7 @@ void QmuParserBase::DefineOprt( const QString &a_sName, fun_type2 a_pFun, unsign
ValidOprtChars() ); ValidOprtChars() );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Define a new string constant. * @brief Define a new string constant.
* @param [in] a_strName The name of the constant. * @param [in] a_strName The name of the constant.
@ -684,7 +684,7 @@ void QmuParserBase::DefineStrConst(const QString &a_strName, const QString &a_st
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a user defined variable. * @brief Add a user defined variable.
* @param [in] a_sName the variable name * @param [in] a_sName the variable name
@ -710,7 +710,7 @@ void QmuParserBase::DefineVar(const QString &a_sName, qreal *a_pVar)
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a user defined constant. * @brief Add a user defined constant.
* @param [in] a_sName The name of the constant. * @param [in] a_sName The name of the constant.
@ -725,7 +725,7 @@ void QmuParserBase::DefineConst(const QString &a_sName, qreal a_fVal)
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Get operator priority. * @brief Get operator priority.
* @throw ParserException if a_Oprt is no operator code * @throw ParserException if a_Oprt is no operator code
@ -821,7 +821,7 @@ int QmuParserBase::GetOprtPrecedence(const token_type &a_Tok) const
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Get operator priority. * @brief Get operator priority.
* @throw ParserException if a_Oprt is no operator code * @throw ParserException if a_Oprt is no operator code
@ -916,7 +916,7 @@ EOprtAssociativity QmuParserBase::GetOprtAssociativity(const token_type &a_Tok)
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return a map containing the used variables only. * @brief Return a map containing the used variables only.
*/ */
@ -941,7 +941,7 @@ const varmap_type& QmuParserBase::GetUsedVar() const
return m_pTokenReader->GetUsedVar(); return m_pTokenReader->GetUsedVar();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return a map containing the used variables only. * @brief Return a map containing the used variables only.
*/ */
@ -950,7 +950,7 @@ const varmap_type& QmuParserBase::GetVar() const
return m_VarDef; return m_VarDef;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return a map containing all parser constants. * @brief Return a map containing all parser constants.
*/ */
@ -959,7 +959,7 @@ const valmap_type& QmuParserBase::GetConst() const
return m_ConstDef; return m_ConstDef;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return prototypes of all parser functions. * @brief Return prototypes of all parser functions.
* @return #m_FunDef * @return #m_FunDef
@ -975,7 +975,7 @@ const funmap_type& QmuParserBase::GetFunDef() const
return m_FunDef; return m_FunDef;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Retrieve the formula. * @brief Retrieve the formula.
*/ */
@ -984,7 +984,7 @@ const QString& QmuParserBase::GetExpr() const
return m_pTokenReader->GetExpr(); return m_pTokenReader->GetExpr();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Execute a function that takes a single string argument. * @brief Execute a function that takes a single string argument.
* @param a_FunTok Function token. * @param a_FunTok Function token.
@ -1039,7 +1039,7 @@ QmuParserBase::token_type QmuParserBase::ApplyStrFunc(const token_type &a_FunTok
return valTok; return valTok;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Apply a function token. * @brief Apply a function token.
* @param iArgCount Number of Arguments actually gathered used only for multiarg functions. * @param iArgCount Number of Arguments actually gathered used only for multiarg functions.
@ -1229,7 +1229,7 @@ void QmuParserBase::ApplyFunc( QStack<token_type> &a_stOpt, QStack<token_type> &
a_stVal.push(token); a_stVal.push(token);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserBase::ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const void QmuParserBase::ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const
{ {
// Check if there is an if Else clause to be calculated // Check if there is an if Else clause to be calculated
@ -1259,7 +1259,7 @@ void QmuParserBase::ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type>
} // while pending if-else-clause found } // while pending if-else-clause found
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Performs the necessary steps to write code for the execution of binary operators into the bytecode. * @brief Performs the necessary steps to write code for the execution of binary operators into the bytecode.
*/ */
@ -1300,7 +1300,7 @@ void QmuParserBase::ApplyBinOprt(QStack<token_type> &a_stOpt, QStack<token_type>
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Apply a binary operator. * @brief Apply a binary operator.
* @param a_stOpt The operator stack * @param a_stOpt The operator stack
@ -1405,7 +1405,7 @@ void QmuParserBase::ApplyRemainingOprt(QStack<token_type> &stOpt, QStack<token_t
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Parse the command code. * @brief Parse the command code.
* @sa ParseString(...) * @sa ParseString(...)
@ -1418,7 +1418,7 @@ qreal QmuParserBase::ParseCmdCode() const
return ParseCmdCodeBulk(0, 0); return ParseCmdCodeBulk(0, 0);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Evaluate the RPN. * @brief Evaluate the RPN.
* @param nOffset The offset added to variable addresses (for bulk mode) * @param nOffset The offset added to variable addresses (for bulk mode)
@ -1769,10 +1769,10 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
return Stack[m_nFinalResultIdx]; return Stack[m_nFinalResultIdx];
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserBase::CreateRPN() const void QmuParserBase::CreateRPN() const
{ {
if (!m_pTokenReader->GetExpr().length()) if (m_pTokenReader->GetExpr().length() == false)
{ {
Error(ecUNEXPECTED_EOF, 0); Error(ecUNEXPECTED_EOF, 0);
} }
@ -2027,7 +2027,7 @@ void QmuParserBase::CreateRPN() const
m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads); m_vStackBuffer.resize(m_vRPN.GetMaxStackSize() * s_MaxNumOpenMPThreads);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief One of the two main parse functions. * @brief One of the two main parse functions.
* @sa ParseCmdCode(...) * @sa ParseCmdCode(...)
@ -2051,7 +2051,7 @@ qreal QmuParserBase::ParseString() const
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Create an error containing the parse error position. * @brief Create an error containing the parse error position.
* *
@ -2067,7 +2067,7 @@ void Q_NORETURN QmuParserBase::Error(EErrorCodes a_iErrc, int a_iPos, const QStr
throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); throw exception_type(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear all user defined variables. * @brief Clear all user defined variables.
* @throw nothrow * @throw nothrow
@ -2080,7 +2080,7 @@ void QmuParserBase::ClearVar()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Remove a variable from internal storage. * @brief Remove a variable from internal storage.
* @throw nothrow * @throw nothrow
@ -2097,7 +2097,7 @@ void QmuParserBase::RemoveVar(const QString &a_strVarName)
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear all functions. * @brief Clear all functions.
* @post Resets the parser to string parsing mode. * @post Resets the parser to string parsing mode.
@ -2109,7 +2109,7 @@ void QmuParserBase::ClearFun()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear all user defined constants. * @brief Clear all user defined constants.
* *
@ -2124,7 +2124,7 @@ void QmuParserBase::ClearConst()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear all user defined postfix operators. * @brief Clear all user defined postfix operators.
* @post Resets the parser to string parsing mode. * @post Resets the parser to string parsing mode.
@ -2136,7 +2136,7 @@ void QmuParserBase::ClearPostfixOprt()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear all user defined binary operators. * @brief Clear all user defined binary operators.
* @post Resets the parser to string parsing mode. * @post Resets the parser to string parsing mode.
@ -2148,7 +2148,7 @@ void QmuParserBase::ClearOprt()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clear the user defined Prefix operators. * @brief Clear the user defined Prefix operators.
* @post Resets the parser to string parser mode. * @post Resets the parser to string parser mode.
@ -2160,7 +2160,7 @@ void QmuParserBase::ClearInfixOprt()
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Enable or disable the formula optimization feature. * @brief Enable or disable the formula optimization feature.
* @post Resets the parser to string parser mode. * @post Resets the parser to string parser mode.
@ -2172,7 +2172,7 @@ void QmuParserBase::EnableOptimizer(bool a_bIsOn)
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Enable the dumping of bytecode amd stack content on the console. * @brief Enable the dumping of bytecode amd stack content on the console.
* @param bDumpCmd Flag to enable dumping of the current bytecode to the console. * @param bDumpCmd Flag to enable dumping of the current bytecode to the console.
@ -2186,7 +2186,7 @@ void QmuParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack)
QmuParserBase::g_DbgDumpStack = bDumpStack; QmuParserBase::g_DbgDumpStack = bDumpStack;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Enable or disable the built in binary operators. * @brief Enable or disable the built in binary operators.
* @throw nothrow * @throw nothrow
@ -2202,7 +2202,7 @@ void QmuParserBase::EnableBuiltInOprt(bool a_bIsOn)
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Query status of built in variables. * @brief Query status of built in variables.
* @return #m_bBuiltInOp; true if built in operators are enabled. * @return #m_bBuiltInOp; true if built in operators are enabled.
@ -2213,7 +2213,7 @@ bool QmuParserBase::HasBuiltInOprt() const
return m_bBuiltInOp; return m_bBuiltInOp;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Get the argument separator character. * @brief Get the argument separator character.
*/ */
@ -2222,7 +2222,7 @@ QChar QmuParserBase::GetArgSep() const
return m_pTokenReader->GetArgSep(); return m_pTokenReader->GetArgSep();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set argument separator. * @brief Set argument separator.
* @param cArgSep the argument separator character. * @param cArgSep the argument separator character.
@ -2232,7 +2232,7 @@ void QmuParserBase::SetArgSep(char_type cArgSep)
m_pTokenReader->SetArgSep(cArgSep); m_pTokenReader->SetArgSep(cArgSep);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Dump stack content. * @brief Dump stack content.
* *
@ -2244,7 +2244,7 @@ void QmuParserBase::StackDump(const QStack<token_type> &a_stVal, const QStack<to
stVal(a_stVal); stVal(a_stVal);
qDebug() << "\nValue stack:\n"; qDebug() << "\nValue stack:\n";
while ( !stVal.empty() ) while ( stVal.empty() == false )
{ {
token_type val = stVal.pop(); token_type val = stVal.pop();
if (val.GetType()==tpSTR) if (val.GetType()==tpSTR)
@ -2258,7 +2258,7 @@ void QmuParserBase::StackDump(const QStack<token_type> &a_stVal, const QStack<to
} }
qDebug() << "\nOperator stack:\n"; qDebug() << "\nOperator stack:\n";
while ( !stOprt.empty() ) while ( stOprt.empty() == false )
{ {
if (stOprt.top().GetCode()<=cmASSIGN) if (stOprt.top().GetCode()<=cmASSIGN)
{ {
@ -2386,7 +2386,7 @@ void QmuParserBase::StackDump(const QStack<token_type> &a_stVal, const QStack<to
qDebug() << dec; qDebug() << dec;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** @brief Evaluate an expression containing comma seperated subexpressions /** @brief Evaluate an expression containing comma seperated subexpressions
* @param [out] nStackSize The total number of results available * @param [out] nStackSize The total number of results available
* @return Pointer to the array containing all expression results * @return Pointer to the array containing all expression results
@ -2403,7 +2403,7 @@ qreal* QmuParserBase::Eval(int &nStackSize) const
return &m_vStackBuffer[1]; return &m_vStackBuffer[1];
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the number of results on the calculation stack. * @brief Return the number of results on the calculation stack.
* *
@ -2415,7 +2415,7 @@ int QmuParserBase::GetNumResults() const
return m_nFinalResultIdx; return m_nFinalResultIdx;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Calculate the result. * @brief Calculate the result.
* *
@ -2437,7 +2437,7 @@ qreal QmuParserBase::Eval() const
return (this->*m_pParseFormula)(); return (this->*m_pParseFormula)();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserBase::Eval(qreal *results, int nBulkSize) void QmuParserBase::Eval(qreal *results, int nBulkSize)
{ {
CreateRPN(); CreateRPN();
@ -2451,7 +2451,7 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize)
int *pIdx = new int[nBulkSize]; int *pIdx = new int[nBulkSize];
#endif #endif
int nMaxThreads = std::min(omp_get_max_threads(), s_MaxNumOpenMPThreads); int nMaxThreads = qMin(omp_get_max_threads(), s_MaxNumOpenMPThreads);
int nThreadID, ct=0; int nThreadID, ct=0;
omp_set_num_threads(nMaxThreads); omp_set_num_threads(nMaxThreads);

View File

@ -259,4 +259,3 @@ private:
} // namespace qmu } // namespace qmu
#endif #endif

View File

@ -35,7 +35,7 @@
namespace qmu namespace qmu
{ {
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Bytecode default constructor. * @brief Bytecode default constructor.
*/ */
@ -45,7 +45,7 @@ QmuParserByteCode::QmuParserByteCode()
m_vRPN.reserve(50); m_vRPN.reserve(50);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy constructor. * @brief Copy constructor.
* *
@ -58,7 +58,7 @@ QmuParserByteCode::QmuParserByteCode(const QmuParserByteCode &a_ByteCode)
Assign(a_ByteCode); Assign(a_ByteCode);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Assignment operator. * @brief Assignment operator.
* *
@ -70,13 +70,13 @@ QmuParserByteCode& QmuParserByteCode::operator=(const QmuParserByteCode &a_ByteC
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserByteCode::EnableOptimizer(bool bStat) void QmuParserByteCode::EnableOptimizer(bool bStat)
{ {
m_bEnableOptimizer = bStat; m_bEnableOptimizer = bStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy state of another object to this. * @brief Copy state of another object to this.
* *
@ -94,7 +94,7 @@ void QmuParserByteCode::Assign(const QmuParserByteCode &a_ByteCode)
m_iMaxStackSize = a_ByteCode.m_iMaxStackSize; m_iMaxStackSize = a_ByteCode.m_iMaxStackSize;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a Variable pointer to bytecode. * @brief Add a Variable pointer to bytecode.
* @param a_pVar Pointer to be added. * @param a_pVar Pointer to be added.
@ -114,7 +114,7 @@ void QmuParserByteCode::AddVar(qreal *a_pVar)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a Variable pointer to bytecode. * @brief Add a Variable pointer to bytecode.
* *
@ -142,7 +142,7 @@ void QmuParserByteCode::AddVal(qreal a_fVal)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt)
{ {
std::size_t sz = m_vRPN.size(); std::size_t sz = m_vRPN.size();
@ -282,7 +282,7 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt)
} // switch opcode } // switch opcode
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add an operator identifier to bytecode. * @brief Add an operator identifier to bytecode.
* *
@ -526,7 +526,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt)
} }
// If optimization can't be applied just write the value // If optimization can't be applied just write the value
if (!bOptimized) if (bOptimized == false)
{ {
--m_iStackPos; --m_iStackPos;
SToken tok; SToken tok;
@ -535,7 +535,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt)
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt) void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt)
{ {
SToken tok; SToken tok;
@ -543,7 +543,7 @@ void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add an assignement operator * @brief Add an assignement operator
* *
@ -565,7 +565,7 @@ void QmuParserByteCode::AddAssignOp(qreal *a_pVar)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add function to bytecode. * @brief Add function to bytecode.
* *
@ -592,7 +592,7 @@ void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add a bulk function to bytecode. * @brief Add a bulk function to bytecode.
* *
@ -611,7 +611,7 @@ void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc)
m_vRPN.push_back(tok); m_vRPN.push_back(tok);
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add Strung function entry to the parser bytecode. * @brief Add Strung function entry to the parser bytecode.
* @throw nothrow * @throw nothrow
@ -633,7 +633,7 @@ void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iI
m_iMaxStackSize = qMax(m_iMaxStackSize, static_cast<size_t>(m_iStackPos)); m_iMaxStackSize = qMax(m_iMaxStackSize, static_cast<size_t>(m_iStackPos));
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Add end marker to bytecode. * @brief Add end marker to bytecode.
* *
@ -770,7 +770,7 @@ void QmuParserByteCode::Finalize()
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const SToken* QmuParserByteCode::GetBase() const const SToken* QmuParserByteCode::GetBase() const
{ {
if (m_vRPN.size()==0) if (m_vRPN.size()==0)
@ -783,13 +783,13 @@ const SToken* QmuParserByteCode::GetBase() const
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
std::size_t QmuParserByteCode::GetMaxStackSize() const std::size_t QmuParserByteCode::GetMaxStackSize() const
{ {
return m_iMaxStackSize+1; return m_iMaxStackSize+1;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Returns the number of entries in the bytecode. * @brief Returns the number of entries in the bytecode.
*/ */
@ -798,7 +798,7 @@ std::size_t QmuParserByteCode::GetSize() const
return m_vRPN.size(); return m_vRPN.size();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Delete the bytecode. * @brief Delete the bytecode.
* *
@ -814,13 +814,13 @@ void QmuParserByteCode::clear()
m_iMaxStackSize = 0; m_iMaxStackSize = 0;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Dump bytecode (for debugging only!). * @brief Dump bytecode (for debugging only!).
*/ */
void QmuParserByteCode::AsciiDump() void QmuParserByteCode::AsciiDump()
{ {
if (!m_vRPN.size()) if (m_vRPN.size() == false)
{ {
qDebug() << "No bytecode available\n"; qDebug() << "No bytecode available\n";
return; return;

View File

@ -39,7 +39,7 @@ struct SToken
ECmdCode Cmd; ECmdCode Cmd;
int StackPos; int StackPos;
union union //
{ {
struct //SValData struct //SValData
{ {
@ -122,5 +122,3 @@ public:
}; };
} // namespace qmu } // namespace qmu
#endif #endif

View File

@ -29,7 +29,7 @@
namespace qmu namespace qmu
{ {
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
//Supressing specific warnings on gcc/g++ http://www.mr-edd.co.uk/blog/supressing_gcc_warnings //Supressing specific warnings on gcc/g++ http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
@ -39,7 +39,7 @@ QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -49,7 +49,7 @@ QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor for constructing funcstion callbacks taking two arguments. * @brief Constructor for constructing funcstion callbacks taking two arguments.
* @throw nothrow * @throw nothrow
@ -62,7 +62,7 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor for constructing binary operator callbacks. * @brief Constructor for constructing binary operator callbacks.
* @param a_pFun Pointer to a static function taking two arguments * @param a_pFun Pointer to a static function taking two arguments
@ -80,7 +80,7 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -90,7 +90,7 @@ QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -100,7 +100,7 @@ QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -109,7 +109,7 @@ QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -118,7 +118,7 @@ QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -127,7 +127,7 @@ QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -136,7 +136,7 @@ QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -145,7 +145,7 @@ QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -154,7 +154,7 @@ QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -163,7 +163,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -172,7 +172,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor for constructing funcstion callbacks taking two arguments. * @brief Constructor for constructing funcstion callbacks taking two arguments.
* @throw nothrow * @throw nothrow
@ -185,7 +185,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -194,7 +194,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -203,7 +203,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -212,7 +212,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -221,7 +221,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -230,7 +230,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -239,7 +239,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -248,7 +248,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -257,7 +257,7 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -266,7 +266,7 @@ QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -275,7 +275,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -284,7 +284,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#ifdef __GNUC__ #ifdef __GNUC__
__extension__ __extension__
#endif #endif
@ -293,7 +293,7 @@ QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti ) m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Default constructor. * @brief Default constructor.
* @throw nothrow * @throw nothrow
@ -303,7 +303,7 @@ QmuParserCallback::QmuParserCallback()
m_bAllowOpti ( 0 ) m_bAllowOpti ( 0 )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy constructor. * @brief Copy constructor.
* @throw nothrow * @throw nothrow
@ -321,7 +321,7 @@ QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref )
m_eOprtAsct = ref.m_eOprtAsct; m_eOprtAsct = ref.m_eOprtAsct;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Clone this instance and return a pointer to the new instance. * @brief Clone this instance and return a pointer to the new instance.
*/ */
@ -330,7 +330,7 @@ QmuParserCallback* QmuParserCallback::Clone() const
return new QmuParserCallback ( *this ); return new QmuParserCallback ( *this );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return tru if the function is conservative. * @brief Return tru if the function is conservative.
* *
@ -342,7 +342,7 @@ bool QmuParserCallback::IsOptimizable() const
return m_bAllowOpti; return m_bAllowOpti;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Get the callback address for the parser function. * @brief Get the callback address for the parser function.
* *
@ -356,7 +356,7 @@ void* QmuParserCallback::GetAddr() const
return m_pFun; return m_pFun;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the callback code. * @brief Return the callback code.
*/ */
@ -365,13 +365,13 @@ ECmdCode QmuParserCallback::GetCode() const
return m_iCode; return m_iCode;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ETypeCode QmuParserCallback::GetType() const ETypeCode QmuParserCallback::GetType() const
{ {
return m_iType; return m_iType;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the operator precedence. * @brief Return the operator precedence.
* @throw nothrown * @throw nothrown
@ -383,7 +383,7 @@ int QmuParserCallback::GetPri() const
return m_iPri; return m_iPri;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the operators associativity. * @brief Return the operators associativity.
* @throw nothrown * @throw nothrown
@ -395,7 +395,7 @@ EOprtAssociativity QmuParserCallback::GetAssociativity() const
return m_eOprtAsct; return m_eOprtAsct;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Returns the number of function Arguments. * @brief Returns the number of function Arguments.
*/ */

View File

@ -103,7 +103,7 @@ private:
bool m_bAllowOpti; ///< Flag indication optimizeability bool m_bAllowOpti; ///< Flag indication optimizeability
}; };
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Container for Callback objects. * @brief Container for Callback objects.
*/ */
@ -112,4 +112,3 @@ typedef std::map<QString, QmuParserCallback> funmap_type;
} // namespace qmu } // namespace qmu
#endif #endif

View File

@ -272,4 +272,3 @@ typedef qreal* ( *facfun_type ) ( const QString &, void* );
} // end of namespace } // end of namespace
#endif #endif

View File

@ -28,23 +28,23 @@ namespace qmu
{ {
const QmuParserErrorMsg QmuParserErrorMsg::m_Instance; const QmuParserErrorMsg QmuParserErrorMsg::m_Instance;
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const QmuParserErrorMsg& QmuParserErrorMsg::Instance() const QmuParserErrorMsg& QmuParserErrorMsg::Instance()
{ {
return m_Instance; return m_Instance;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString QmuParserErrorMsg::operator[] ( unsigned a_iIdx ) const QString QmuParserErrorMsg::operator[] ( unsigned a_iIdx ) const
{ {
return ( a_iIdx < static_cast<unsigned>( m_vErrMsg.size() ) ) ? m_vErrMsg[a_iIdx] : QString(); return ( a_iIdx < static_cast<unsigned>( m_vErrMsg.size() ) ) ? m_vErrMsg[a_iIdx] : QString();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserErrorMsg::~QmuParserErrorMsg() QmuParserErrorMsg::~QmuParserErrorMsg()
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserErrorMsg::QmuParserErrorMsg() QmuParserErrorMsg::QmuParserErrorMsg()
: m_vErrMsg ( 0 ) : m_vErrMsg ( 0 )
{ {
@ -90,7 +90,7 @@ QmuParserErrorMsg::QmuParserErrorMsg()
#if defined(_DEBUG) #if defined(_DEBUG)
for ( int i = 0; i < ecCOUNT; ++i ) for ( int i = 0; i < ecCOUNT; ++i )
{ {
if ( !m_vErrMsg[i].length() ) if ( m_vErrMsg[i].length() == false)
{ {
assert ( false ); assert ( false );
} }
@ -98,11 +98,11 @@ QmuParserErrorMsg::QmuParserErrorMsg()
#endif #endif
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// //
// QParserError class // QParserError class
// //
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Default constructor. * @brief Default constructor.
@ -113,7 +113,7 @@ QmuParserError::QmuParserError()
{ {
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief This Constructor is used for internal exceptions only. * @brief This Constructor is used for internal exceptions only.
* *
@ -128,7 +128,7 @@ QmuParserError::QmuParserError ( EErrorCodes a_iErrc )
ReplaceSubString ( m_strMsg, "$TOK$", m_strTok ); ReplaceSubString ( m_strMsg, "$TOK$", m_strTok );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Construct an error from a message text. * @brief Construct an error from a message text.
*/ */
@ -137,7 +137,7 @@ QmuParserError::QmuParserError ( const QString &sMsg )
m_ErrMsg ( QmuParserErrorMsg::Instance() ) m_ErrMsg ( QmuParserErrorMsg::Instance() )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Construct an error object. * @brief Construct an error object.
* @param [in] a_iErrc the error code. * @param [in] a_iErrc the error code.
@ -157,7 +157,7 @@ QmuParserError::QmuParserError ( EErrorCodes iErrc,
ReplaceSubString ( m_strMsg, "$TOK$", m_strTok ); ReplaceSubString ( m_strMsg, "$TOK$", m_strTok );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Construct an error object. * @brief Construct an error object.
* @param [in] iErrc the error code. * @param [in] iErrc the error code.
@ -173,7 +173,7 @@ QmuParserError::QmuParserError ( EErrorCodes iErrc, int iPos, const QString &sTo
ReplaceSubString ( m_strMsg, "$TOK$", m_strTok ); ReplaceSubString ( m_strMsg, "$TOK$", m_strTok );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** @brief Construct an error object. /** @brief Construct an error object.
* @param [in] szMsg The error message text. * @param [in] szMsg The error message text.
* @param [in] iPos the position related to the error. * @param [in] iPos the position related to the error.
@ -187,7 +187,7 @@ QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &
ReplaceSubString ( m_strMsg, "$TOK$", m_strTok ); ReplaceSubString ( m_strMsg, "$TOK$", m_strTok );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** @brief Copy constructor. */ /** @brief Copy constructor. */
QmuParserError::QmuParserError ( const QmuParserError &a_Obj ) QmuParserError::QmuParserError ( const QmuParserError &a_Obj )
: m_strMsg ( a_Obj.m_strMsg ), m_strFormula ( a_Obj.m_strFormula ), m_strTok ( a_Obj.m_strTok ), : m_strMsg ( a_Obj.m_strMsg ), m_strFormula ( a_Obj.m_strFormula ), m_strTok ( a_Obj.m_strTok ),
@ -195,7 +195,7 @@ QmuParserError::QmuParserError ( const QmuParserError &a_Obj )
{ {
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** @brief Assignment operator. */ /** @brief Assignment operator. */
QmuParserError& QmuParserError::operator= ( const QmuParserError &a_Obj ) QmuParserError& QmuParserError::operator= ( const QmuParserError &a_Obj )
{ {
@ -212,11 +212,11 @@ QmuParserError& QmuParserError::operator= ( const QmuParserError &a_Obj )
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserError::~QmuParserError() QmuParserError::~QmuParserError()
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Replace all ocuurences of a substring with another string. * @brief Replace all ocuurences of a substring with another string.
* @param strFind The string that shall be replaced. * @param strFind The string that shall be replaced.
@ -233,7 +233,9 @@ void QmuParserError::ReplaceSubString ( QString &strSource, const QString &strFi
strResult.append ( strSource.mid ( iPos, iNext - iPos ) ); strResult.append ( strSource.mid ( iPos, iNext - iPos ) );
if ( iNext == -1 ) if ( iNext == -1 )
{
break; break;
}
strResult.append ( strReplaceWith ); strResult.append ( strReplaceWith );
iPos = iNext + strFind.length(); iPos = iNext + strFind.length();
@ -242,7 +244,7 @@ void QmuParserError::ReplaceSubString ( QString &strSource, const QString &strFi
strSource.swap ( strResult ); strSource.swap ( strResult );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Reset the erro object. * @brief Reset the erro object.
*/ */
@ -255,7 +257,7 @@ void QmuParserError::Reset()
m_iErrc = ecUNDEFINED; m_iErrc = ecUNDEFINED;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set the expression related to this error. * @brief Set the expression related to this error.
*/ */
@ -264,7 +266,7 @@ void QmuParserError::SetFormula ( const QString &a_strFormula )
m_strFormula = a_strFormula; m_strFormula = a_strFormula;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief gets the expression related tp this error. * @brief gets the expression related tp this error.
*/ */
@ -273,7 +275,7 @@ const QString& QmuParserError::GetExpr() const
return m_strFormula; return m_strFormula;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Returns the message string for this error. * @brief Returns the message string for this error.
*/ */
@ -282,7 +284,7 @@ const QString& QmuParserError::GetMsg() const
return m_strMsg; return m_strMsg;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the formula position related to the error. * @brief Return the formula position related to the error.
* *
@ -293,7 +295,7 @@ std::size_t QmuParserError::GetPos() const
return m_iPos; return m_iPos;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return string related with this token (if available). * @brief Return string related with this token (if available).
*/ */
@ -302,7 +304,7 @@ const QString& QmuParserError::GetToken() const
return m_strTok; return m_strTok;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the error code. * @brief Return the error code.
*/ */

View File

@ -155,4 +155,3 @@ private:
} // namespace qmu } // namespace qmu
#endif #endif

View File

@ -55,5 +55,3 @@
#endif #endif
#endif // include guard #endif // include guard

View File

@ -41,7 +41,7 @@ namespace Test
{ {
int QmuParserTester::c_iCount = 0; int QmuParserTester::c_iCount = 0;
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserTester::QmuParserTester() QmuParserTester::QmuParserTester()
: m_vTestFun() : m_vTestFun()
{ {
@ -61,7 +61,7 @@ QmuParserTester::QmuParserTester()
QmuParserTester::c_iCount = 0; QmuParserTester::c_iCount = 0;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal ) int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal )
{ {
if ( a_szExpr[1] == 0 || ( a_szExpr[0] != '0' || a_szExpr[1] != 'x' ) ) if ( a_szExpr[1] == 0 || ( a_szExpr[0] != '0' || a_szExpr[1] != 'x' ) )
@ -92,7 +92,7 @@ int QmuParserTester::IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_f
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestInterface() int QmuParserTester::TestInterface()
{ {
int iStat = 0; int iStat = 0;
@ -138,7 +138,7 @@ int QmuParserTester::TestInterface()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestStrArg() int QmuParserTester::TestStrArg()
{ {
int iStat = 0; int iStat = 0;
@ -167,7 +167,7 @@ int QmuParserTester::TestStrArg()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestBinOprt() int QmuParserTester::TestBinOprt()
{ {
int iStat = 0; int iStat = 0;
@ -242,7 +242,7 @@ int QmuParserTester::TestBinOprt()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** @brief Check muParser name restriction enforcement. */ /** @brief Check muParser name restriction enforcement. */
int QmuParserTester::TestNames() int QmuParserTester::TestNames()
{ {
@ -355,7 +355,7 @@ int QmuParserTester::TestNames()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestSyntax() int QmuParserTester::TestSyntax()
{ {
int iStat = 0; int iStat = 0;
@ -408,7 +408,7 @@ int QmuParserTester::TestSyntax()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestVarConst() int QmuParserTester::TestVarConst()
{ {
int iStat = 0; int iStat = 0;
@ -541,7 +541,7 @@ int QmuParserTester::TestVarConst()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestMultiArg() int QmuParserTester::TestMultiArg()
{ {
int iStat = 0; int iStat = 0;
@ -640,7 +640,7 @@ int QmuParserTester::TestMultiArg()
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestInfixOprt() int QmuParserTester::TestInfixOprt()
{ {
int iStat ( 0 ); int iStat ( 0 );
@ -709,7 +709,7 @@ int QmuParserTester::TestInfixOprt()
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestPostFix() int QmuParserTester::TestPostFix()
{ {
int iStat = 0; int iStat = 0;
@ -764,7 +764,7 @@ int QmuParserTester::TestPostFix()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestExpression() int QmuParserTester::TestExpression()
{ {
int iStat = 0; int iStat = 0;
@ -849,9 +849,7 @@ int QmuParserTester::TestExpression()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestIfThenElse() int QmuParserTester::TestIfThenElse()
{ {
int iStat = 0; int iStat = 0;
@ -961,7 +959,7 @@ int QmuParserTester::TestIfThenElse()
return iStat; return iStat;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::TestException() int QmuParserTester::TestException()
{ {
int iStat = 0; int iStat = 0;
@ -1060,13 +1058,13 @@ int QmuParserTester::TestException()
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTester::AddTest ( testfun_type a_pFun ) void QmuParserTester::AddTest ( testfun_type a_pFun )
{ {
m_vTestFun.push_back ( a_pFun ); m_vTestFun.push_back ( a_pFun );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTester::Run() void QmuParserTester::Run()
{ {
int iStat = 0; int iStat = 0;
@ -1108,7 +1106,7 @@ void QmuParserTester::Run()
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int QmuParserTester::ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail ) int QmuParserTester::ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail )
{ {
QmuParserTester::c_iCount++; QmuParserTester::c_iCount++;
@ -1157,7 +1155,7 @@ int QmuParserTester::ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail
return bRet; return bRet;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Evaluate a tet expression. * @brief Evaluate a tet expression.
* *
@ -1213,7 +1211,7 @@ int QmuParserTester::EqnTestWithVarChange ( const QString &a_str, double a_fVar1
return 0; return 0;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Evaluate a tet expression. * @brief Evaluate a tet expression.
* *
@ -1358,7 +1356,7 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass
} }
} }
iRet = ( ( bCloseEnough && a_fPass ) || ( !bCloseEnough && !a_fPass ) ) ? 0 : 1; iRet = ( ( bCloseEnough && a_fPass ) || ( bCloseEnough == false && a_fPass == false) ) ? 0 : 1;
if ( iRet == 1 ) if ( iRet == 1 )
@ -1402,14 +1400,14 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass
return iRet; return iRet;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Internal error in test class Test is going to be aborted. * @brief Internal error in test class Test is going to be aborted.
*/ */
void Q_NORETURN QmuParserTester::Abort() const void Q_NORETURN QmuParserTester::Abort() const
{ {
qDebug() << "Test failed (internal error in test class)"; qDebug() << "Test failed (internal error in test class)";
while ( !getchar() ); while ( getchar() == false);
exit ( -1 ); exit ( -1 );
} }
} // namespace test } // namespace test

View File

@ -41,7 +41,7 @@ namespace qmu
*/ */
namespace Test namespace Test
{ {
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Test cases for unit testing. * @brief Test cases for unit testing.
* *
@ -183,7 +183,7 @@ private:
static qreal FirstArg ( const qreal* a_afArg, int a_iArgc ) static qreal FirstArg ( const qreal* a_afArg, int a_iArgc )
{ {
if ( !a_iArgc ) if ( a_iArgc == false)
{ {
throw qmu::QmuParser::exception_type ( "too few arguments for function FirstArg." ); throw qmu::QmuParser::exception_type ( "too few arguments for function FirstArg." );
} }
@ -193,7 +193,7 @@ private:
static qreal LastArg ( const qreal* a_afArg, int a_iArgc ) static qreal LastArg ( const qreal* a_afArg, int a_iArgc )
{ {
if ( !a_iArgc ) if ( a_iArgc == false)
{ {
throw qmu::QmuParser::exception_type ( "too few arguments for function LastArg." ); throw qmu::QmuParser::exception_type ( "too few arguments for function LastArg." );
} }
@ -203,7 +203,7 @@ private:
static qreal Sum ( const qreal* a_afArg, int a_iArgc ) static qreal Sum ( const qreal* a_afArg, int a_iArgc )
{ {
if ( !a_iArgc ) if ( a_iArgc == false)
{ {
throw qmu::QmuParser::exception_type ( "too few arguments for function sum." ); throw qmu::QmuParser::exception_type ( "too few arguments for function sum." );
} }
@ -298,5 +298,3 @@ private:
} // namespace qmu } // namespace qmu
#endif #endif

View File

@ -237,7 +237,9 @@ public:
void SetIdx ( int a_iIdx ) void SetIdx ( int a_iIdx )
{ {
if ( m_iCode != cmSTRING || a_iIdx < 0 ) if ( m_iCode != cmSTRING || a_iIdx < 0 )
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
m_iIdx = a_iIdx; m_iIdx = a_iIdx;
} }
@ -254,7 +256,9 @@ public:
int GetIdx() const int GetIdx() const
{ {
if ( m_iIdx < 0 || m_iCode != cmSTRING ) if ( m_iIdx < 0 || m_iCode != cmSTRING )
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
return m_iIdx; return m_iIdx;
} }
@ -294,11 +298,15 @@ public:
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int GetPri() const int GetPri() const
{ {
if ( !m_pCallback.get() ) if ( m_pCallback.get() == false)
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
if ( m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX ) if ( m_pCallback->GetCode() != cmOPRT_BIN && m_pCallback->GetCode() != cmOPRT_INFIX )
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
return m_pCallback->GetPri(); return m_pCallback->GetPri();
} }
@ -307,7 +315,9 @@ public:
EOprtAssociativity GetAssociativity() const EOprtAssociativity GetAssociativity() const
{ {
if ( m_pCallback.get() == NULL || m_pCallback->GetCode() != cmOPRT_BIN ) if ( m_pCallback.get() == NULL || m_pCallback->GetCode() != cmOPRT_BIN )
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
return m_pCallback->GetAssociativity(); return m_pCallback->GetAssociativity();
} }
@ -482,8 +492,10 @@ public:
{ {
assert ( m_pCallback.get() ); assert ( m_pCallback.get() );
if ( !m_pCallback->GetAddr() ) if ( m_pCallback->GetAddr() == false)
{
throw QmuParserError ( ecINTERNAL_ERROR ); throw QmuParserError ( ecINTERNAL_ERROR );
}
return m_pCallback->GetArgc(); return m_pCallback->GetArgc();
} }

View File

@ -36,7 +36,7 @@ namespace qmu
// Forward declaration // Forward declaration
class QmuParserBase; class QmuParserBase;
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Copy constructor. * @brief Copy constructor.
* *
@ -54,7 +54,7 @@ QmuParserTokenReader::QmuParserTokenReader ( const QmuParserTokenReader &a_Reade
m_cArgSep( a_Reader.m_cArgSep ) m_cArgSep( a_Reader.m_cArgSep )
{} {}
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Assignement operator. * @brief Assignement operator.
* *
@ -73,7 +73,7 @@ QmuParserTokenReader& QmuParserTokenReader::operator= ( const QmuParserTokenRead
return *this; return *this;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Assign state of a token reader to this token reader. * @brief Assign state of a token reader to this token reader.
* *
@ -103,7 +103,7 @@ void QmuParserTokenReader::Assign ( const QmuParserTokenReader &a_Reader )
m_cArgSep = a_Reader.m_cArgSep; m_cArgSep = a_Reader.m_cArgSep;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Constructor. * @brief Constructor.
* *
@ -123,7 +123,7 @@ QmuParserTokenReader::QmuParserTokenReader ( QmuParserBase *a_pParent )
SetParent ( m_pParser ); SetParent ( m_pParser );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Create instance of a QParserTokenReader identical with this and return its pointer. * @brief Create instance of a QParserTokenReader identical with this and return its pointer.
* *
@ -139,14 +139,14 @@ QmuParserTokenReader* QmuParserTokenReader::Clone ( QmuParserBase *a_pParent ) c
return ptr.release(); return ptr.release();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok ) QmuParserTokenReader::token_type& QmuParserTokenReader::SaveBeforeReturn ( const token_type &tok )
{ {
m_lastTok = tok; m_lastTok = tok;
return m_lastTok; return m_lastTok;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback ) void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback )
{ {
// Use push_front is used to give user defined callbacks a higher priority than // Use push_front is used to give user defined callbacks a higher priority than
@ -158,14 +158,14 @@ void QmuParserTokenReader::AddValIdent ( identfun_type a_pCallback )
m_vIdentFun.push_front ( a_pCallback ); m_vIdentFun.push_front ( a_pCallback );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData ) void QmuParserTokenReader::SetVarCreator ( facfun_type a_pFactory, void *pUserData )
{ {
m_pFactory = a_pFactory; m_pFactory = a_pFactory;
m_pFactoryData = pUserData; m_pFactoryData = pUserData;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return the current position of the token reader in the formula string. * @brief Return the current position of the token reader in the formula string.
* *
@ -177,7 +177,7 @@ int QmuParserTokenReader::GetPos() const
return m_iPos; return m_iPos;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return a reference to the formula. * @brief Return a reference to the formula.
* *
@ -189,7 +189,7 @@ const QString& QmuParserTokenReader::GetExpr() const
return m_strFormula; return m_strFormula;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Return a map containing the used variables only. * @brief Return a map containing the used variables only.
*/ */
@ -198,7 +198,7 @@ varmap_type& QmuParserTokenReader::GetUsedVar()
return m_UsedVar; return m_UsedVar;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Initialize the token Reader. * @brief Initialize the token Reader.
* *
@ -211,7 +211,7 @@ void QmuParserTokenReader::SetFormula ( const QString &a_strFormula )
ReInit(); ReInit();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Set Flag that contronls behaviour in case of undefined variables beeing found. * @brief Set Flag that contronls behaviour in case of undefined variables beeing found.
* *
@ -225,7 +225,7 @@ void QmuParserTokenReader::IgnoreUndefVar ( bool bIgnore )
m_bIgnoreUndefVar = bIgnore; m_bIgnoreUndefVar = bIgnore;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Reset the token reader to the start of the formula. * @brief Reset the token reader to the start of the formula.
* *
@ -243,7 +243,7 @@ void QmuParserTokenReader::ReInit()
m_lastTok = token_type(); m_lastTok = token_type();
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Read the next token from the string. * @brief Read the next token from the string.
*/ */
@ -264,17 +264,50 @@ QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken()
++m_iPos; ++m_iPos;
} }
if ( IsEOF ( tok ) ) return SaveBeforeReturn ( tok ); // Check for end of formula if ( IsEOF ( tok ) )
if ( IsOprt ( tok ) ) return SaveBeforeReturn ( tok ); // Check for user defined binary operator {
if ( IsFunTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for function token return SaveBeforeReturn ( tok ); // Check for end of formula
if ( IsBuiltIn ( tok ) ) return SaveBeforeReturn ( tok ); // Check built in operators / tokens }
if ( IsArgSep ( tok ) ) return SaveBeforeReturn ( tok ); // Check for function argument separators if ( IsOprt ( tok ) )
if ( IsValTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for values / constant tokens {
if ( IsVarTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for variable tokens return SaveBeforeReturn ( tok ); // Check for user defined binary operator
if ( IsStrVarTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for string variables }
if ( IsString ( tok ) ) return SaveBeforeReturn ( tok ); // Check for String tokens if ( IsFunTok ( tok ) )
if ( IsInfixOpTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for unary operators {
if ( IsPostOpTok ( tok ) ) return SaveBeforeReturn ( tok ); // Check for unary operators return SaveBeforeReturn ( tok ); // Check for function token
}
if ( IsBuiltIn ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check built in operators / tokens
}
if ( IsArgSep ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for function argument separators
}
if ( IsValTok ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for values / constant tokens
}
if ( IsVarTok ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for variable tokens
}
if ( IsStrVarTok ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for string variables
}
if ( IsString ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for String tokens
}
if ( IsInfixOpTok ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for unary operators
}
if ( IsPostOpTok ( tok ) )
{
return SaveBeforeReturn ( tok ); // Check for unary operators
}
// Check String for undefined variable token. Done only if a // Check String for undefined variable token. Done only if a
// flag is set indicating to ignore undefined variables. // flag is set indicating to ignore undefined variables.
@ -303,7 +336,7 @@ QmuParserTokenReader::token_type QmuParserTokenReader::ReadNextToken()
return token_type(); // never reached return token_type(); // never reached
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent ) void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
{ {
m_pParser = a_pParent; m_pParser = a_pParent;
@ -316,7 +349,7 @@ void QmuParserTokenReader::SetParent ( QmuParserBase *a_pParent )
m_pConstDef = &a_pParent->m_ConstDef; m_pConstDef = &a_pParent->m_ConstDef;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Extract all characters that belong to a certain charset. * @brief Extract all characters that belong to a certain charset.
* *
@ -347,16 +380,18 @@ int QmuParserTokenReader::ExtractToken ( const QString &a_szCharSet, QString &a_
if ( a_iPos != iEnd ) if ( a_iPos != iEnd )
{ {
#if defined(_UNICODE) #if defined(_UNICODE)
a_sTok = QString().fromStdWString ( std::wstring ( m_strFormulaStd.begin() + a_iPos, m_strFormulaStd.begin() + iEnd ) ); a_sTok = QString().fromStdWString ( std::wstring ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#else #else
a_sTok = QString().fromStdString ( std::string ( m_strFormulaStd.begin() + a_iPos, m_strFormulaStd.begin() + iEnd ) ); a_sTok = QString().fromStdString ( std::string ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#endif #endif
} }
return iEnd; return iEnd;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check Expression for the presence of a binary operator token. * @brief Check Expression for the presence of a binary operator token.
* *
@ -386,7 +421,8 @@ int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) c
a_sTok = QString().fromStdWString ( string_type ( m_strFormulaStd.begin() + a_iPos, a_sTok = QString().fromStdWString ( string_type ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) ); m_strFormulaStd.begin() + iEnd ) );
#else #else
a_sTok = QString().fromStdString ( string_type ( m_strFormulaStd.begin() + a_iPos, m_strFormulaStd.begin() + iEnd ) ); a_sTok = QString().fromStdString ( string_type ( m_strFormulaStd.begin() + a_iPos,
m_strFormulaStd.begin() + iEnd ) );
#endif #endif
return iEnd; return iEnd;
} }
@ -398,7 +434,7 @@ int QmuParserTokenReader::ExtractOperatorToken ( QString &a_sTok, int a_iPos ) c
} }
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a built in operator or other token can be found * @brief Check if a built in operator or other token can be found
* @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token.
@ -439,16 +475,23 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
// The assignement operator need special treatment // The assignement operator need special treatment
if ( i == cmASSIGN && m_iSynFlags & noASSIGN ) if ( i == cmASSIGN && m_iSynFlags & noASSIGN )
{
Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) );
}
if ( !m_pParser->HasBuiltInOprt() ) continue; if ( m_pParser->HasBuiltInOprt() == false)
{
continue;
}
if ( m_iSynFlags & noOPT ) if ( m_iSynFlags & noOPT )
{ {
// Maybe its an infix operator not an operator // Maybe its an infix operator not an operator
// Both operator types can share characters in // Both operator types can share characters in
// their identifiers // their identifiers
if ( IsInfixOpTok ( a_Tok ) ) if ( IsInfixOpTok ( a_Tok ) )
{
return true; return true;
}
Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_OPERATOR, m_iPos, pOprtDef.at ( i ) );
} }
@ -459,36 +502,50 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
case cmBO: case cmBO:
if ( m_iSynFlags & noBO ) if ( m_iSynFlags & noBO )
{
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
}
if ( m_lastTok.GetCode() == cmFUNC ) if ( m_lastTok.GetCode() == cmFUNC )
{
m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; m_iSynFlags = noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE;
}
else else
{
m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE; m_iSynFlags = noBC | noOPT | noEND | noARG_SEP | noPOSTOP | noASSIGN | noIF | noELSE;
}
++m_iBrackets; ++m_iBrackets;
break; break;
case cmBC: case cmBC:
if ( m_iSynFlags & noBC ) if ( m_iSynFlags & noBC )
{
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
}
m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN; m_iSynFlags = noBO | noVAR | noVAL | noFUN | noINFIXOP | noSTR | noASSIGN;
if ( --m_iBrackets < 0 ) if ( --m_iBrackets < 0 )
{
Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_PARENS, m_iPos, pOprtDef.at ( i ) );
}
break; break;
case cmELSE: case cmELSE:
if ( m_iSynFlags & noELSE ) if ( m_iSynFlags & noELSE )
{
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
}
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
break; break;
case cmIF: case cmIF:
if ( m_iSynFlags & noIF ) if ( m_iSynFlags & noIF )
{
Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) ); Error ( ecUNEXPECTED_CONDITIONAL, m_iPos, pOprtDef.at ( i ) );
}
m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE; m_iSynFlags = noBC | noPOSTOP | noEND | noOPT | noIF | noELSE;
break; break;
@ -506,7 +563,7 @@ bool QmuParserTokenReader::IsBuiltIn ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok ) bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok )
{ {
if ( m_strFormula.at ( m_iPos ) == m_cArgSep ) if ( m_strFormula.at ( m_iPos ) == m_cArgSep )
@ -530,7 +587,7 @@ bool QmuParserTokenReader::IsArgSep ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check for End of Formula. * @brief Check for End of Formula.
* *
@ -548,13 +605,17 @@ bool QmuParserTokenReader::IsEOF ( token_type &a_Tok )
#endif #endif
// check for EOF // check for EOF
if ( !szFormula[m_iPos] /*|| szFormula[m_iPos] == '\n'*/ ) if ( szFormula[m_iPos] == false /*|| szFormula[m_iPos] == '\n'*/ )
{ {
if ( m_iSynFlags & noEND ) if ( m_iSynFlags & noEND )
{
Error ( ecUNEXPECTED_EOF, m_iPos ); Error ( ecUNEXPECTED_EOF, m_iPos );
}
if ( m_iBrackets > 0 ) if ( m_iBrackets > 0 )
{
Error ( ecMISSING_PARENS, m_iPos, ")" ); Error ( ecMISSING_PARENS, m_iPos, ")" );
}
m_iSynFlags = 0; m_iSynFlags = 0;
a_Tok.Set ( cmEND ); a_Tok.Set ( cmEND );
@ -564,7 +625,7 @@ bool QmuParserTokenReader::IsEOF ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a string position contains a unary infix operator. * @brief Check if a string position contains a unary infix operator.
* @return true if a function token has been found false otherwise. * @return true if a function token has been found false otherwise.
@ -574,20 +635,26 @@ bool QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok )
QString sTok; QString sTok;
int iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos ); int iEnd = ExtractToken ( m_pParser->ValidInfixOprtChars(), sTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
// iteraterate over all postfix operator strings // iteraterate over all postfix operator strings
funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin(); funmap_type::const_reverse_iterator it = m_pInfixOprtDef->rbegin();
for ( ; it != m_pInfixOprtDef->rend(); ++it ) for ( ; it != m_pInfixOprtDef->rend(); ++it )
{ {
if ( sTok.indexOf ( it->first ) != 0 ) if ( sTok.indexOf ( it->first ) != 0 )
{
continue; continue;
}
a_Tok.Set ( it->second, it->first ); a_Tok.Set ( it->second, it->first );
m_iPos += static_cast<int>(it->first.length()); m_iPos += static_cast<int>(it->first.length());
if ( m_iSynFlags & noINFIXOP ) if ( m_iSynFlags & noINFIXOP )
{
Error ( ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString() ); Error ( ecUNEXPECTED_OPERATOR, m_iPos, a_Tok.GetAsString() );
}
m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN; m_iSynFlags = noPOSTOP | noINFIXOP | noOPT | noBC | noSTR | noASSIGN;
return true; return true;
@ -607,7 +674,7 @@ bool QmuParserTokenReader::IsInfixOpTok ( token_type &a_Tok )
*/ */
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check whether the token at a given position is a function token. * @brief Check whether the token at a given position is a function token.
* @param a_Tok [out] If a value token is found it will be placed here. * @param a_Tok [out] If a value token is found it will be placed here.
@ -620,27 +687,35 @@ bool QmuParserTokenReader::IsFunTok ( token_type &a_Tok )
QString strTok; QString strTok;
int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
funmap_type::const_iterator item = m_pFunDef->find ( strTok ); funmap_type::const_iterator item = m_pFunDef->find ( strTok );
if ( item == m_pFunDef->end() ) if ( item == m_pFunDef->end() )
{
return false; return false;
}
// Check if the next sign is an opening bracket // Check if the next sign is an opening bracket
if ( m_strFormula.at ( iEnd ) != '(' ) if ( m_strFormula.at ( iEnd ) != '(' )
{
return false; return false;
}
a_Tok.Set ( item->second, strTok ); a_Tok.Set ( item->second, strTok );
m_iPos = iEnd; m_iPos = iEnd;
if ( m_iSynFlags & noFUN ) if ( m_iSynFlags & noFUN )
{
Error ( ecUNEXPECTED_FUN, m_iPos - static_cast<int>(a_Tok.GetAsString().length()), a_Tok.GetAsString() ); Error ( ecUNEXPECTED_FUN, m_iPos - static_cast<int>(a_Tok.GetAsString().length()), a_Tok.GetAsString() );
}
m_iSynFlags = noANY ^ noBO; m_iSynFlags = noANY ^ noBO;
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a string position contains a binary operator. * @brief Check if a string position contains a binary operator.
* @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token. * @param a_Tok [out] Operator token if one is found. This can either be a binary operator or an infix operator token.
@ -652,7 +727,9 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok )
int iEnd = ExtractOperatorToken ( strTok, m_iPos ); int iEnd = ExtractOperatorToken ( strTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
// Check if the operator is a built in operator, if so ignore it here // Check if the operator is a built in operator, if so ignore it here
const QStringList pOprtDef = m_pParser->GetOprtDef(); const QStringList pOprtDef = m_pParser->GetOprtDef();
@ -661,8 +738,10 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok )
++constIterator ) ++constIterator )
{ {
if ( ( *constIterator ) == strTok ) if ( ( *constIterator ) == strTok )
{
return false; return false;
} }
}
// Note: // Note:
// All tokens in oprt_bin_maptype are have been sorted by their length // All tokens in oprt_bin_maptype are have been sorted by their length
@ -686,7 +765,9 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok )
// operator, not a binary operator. Both operator types // operator, not a binary operator. Both operator types
// can share characters in their identifiers. // can share characters in their identifiers.
if ( IsInfixOpTok ( a_Tok ) ) if ( IsInfixOpTok ( a_Tok ) )
{
return true; return true;
}
else else
{ {
// nope, no infix operator // nope, no infix operator
@ -705,7 +786,7 @@ bool QmuParserTokenReader::IsOprt ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check if a string position contains a unary post value operator. * @brief Check if a string position contains a unary post value operator.
*/ */
@ -719,7 +800,9 @@ bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok )
// http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979 // http://sourceforge.net/tracker/index.php?func=detail&aid=3343891&group_id=137191&atid=737979
// //
if ( m_iSynFlags & noPOSTOP ) if ( m_iSynFlags & noPOSTOP )
{
return false; return false;
}
// </ibg> // </ibg>
// Tricky problem with equations like "3m+5": // Tricky problem with equations like "3m+5":
@ -734,14 +817,18 @@ bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok )
QString sTok; QString sTok;
int iEnd = ExtractToken ( m_pParser->ValidOprtChars(), sTok, m_iPos ); int iEnd = ExtractToken ( m_pParser->ValidOprtChars(), sTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
// iteraterate over all postfix operator strings // iteraterate over all postfix operator strings
funmap_type::const_reverse_iterator it = m_pPostOprtDef->rbegin(); funmap_type::const_reverse_iterator it = m_pPostOprtDef->rbegin();
for ( ; it != m_pPostOprtDef->rend(); ++it ) for ( ; it != m_pPostOprtDef->rend(); ++it )
{ {
if ( sTok.indexOf ( it->first ) != 0 ) if ( sTok.indexOf ( it->first ) != 0 )
{
continue; continue;
}
a_Tok.Set ( it->second, sTok ); a_Tok.Set ( it->second, sTok );
m_iPos += it->first.length(); m_iPos += it->first.length();
@ -753,7 +840,7 @@ bool QmuParserTokenReader::IsPostOpTok ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check whether the token at a given position is a value token. * @brief Check whether the token at a given position is a value token.
* *
@ -783,7 +870,9 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok )
a_Tok.SetVal ( item->second, strTok ); a_Tok.SetVal ( item->second, strTok );
if ( m_iSynFlags & noVAL ) if ( m_iSynFlags & noVAL )
{
Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok ); Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok );
}
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
return true; return true;
@ -800,7 +889,9 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok )
{ {
strTok = m_strFormula.mid ( iStart, m_iPos ); strTok = m_strFormula.mid ( iStart, m_iPos );
if ( m_iSynFlags & noVAL ) if ( m_iSynFlags & noVAL )
{
Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok ); Error ( ecUNEXPECTED_VAL, m_iPos - strTok.length(), strTok );
}
a_Tok.SetVal ( fVal, strTok ); a_Tok.SetVal ( fVal, strTok );
m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN; m_iSynFlags = noVAL | noVAR | noFUN | noBO | noINFIXOP | noSTR | noASSIGN;
@ -811,7 +902,7 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok )
return false; return false;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check wheter a token at a given position is a variable token. * @brief Check wheter a token at a given position is a variable token.
* @param a_Tok [out] If a variable token has been found it will be placed here. * @param a_Tok [out] If a variable token has been found it will be placed here.
@ -819,20 +910,28 @@ bool QmuParserTokenReader::IsValTok ( token_type &a_Tok )
*/ */
bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok ) bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok )
{ {
if ( !m_pVarDef->size() ) if ( m_pVarDef->size() == false)
{
return false; return false;
}
QString strTok; QString strTok;
int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
varmap_type::const_iterator item = m_pVarDef->find ( strTok ); varmap_type::const_iterator item = m_pVarDef->find ( strTok );
if ( item == m_pVarDef->end() ) if ( item == m_pVarDef->end() )
{
return false; return false;
}
if ( m_iSynFlags & noVAR ) if ( m_iSynFlags & noVAR )
{
Error ( ecUNEXPECTED_VAR, m_iPos, strTok ); Error ( ecUNEXPECTED_VAR, m_iPos, strTok );
}
m_pParser->OnDetectVar ( m_strFormula, m_iPos, iEnd ); m_pParser->OnDetectVar ( m_strFormula, m_iPos, iEnd );
@ -847,27 +946,37 @@ bool QmuParserTokenReader::IsVarTok ( token_type &a_Tok )
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok ) bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok )
{ {
if ( !m_pStrVarDef || !m_pStrVarDef->size() ) if ( m_pStrVarDef == false || m_pStrVarDef->size() == false)
{
return false; return false;
}
QString strTok; QString strTok;
int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos ); int iEnd = ExtractToken ( m_pParser->ValidNameChars(), strTok, m_iPos );
if ( iEnd == m_iPos ) if ( iEnd == m_iPos )
{
return false; return false;
}
strmap_type::const_iterator item = m_pStrVarDef->find ( strTok ); strmap_type::const_iterator item = m_pStrVarDef->find ( strTok );
if ( item == m_pStrVarDef->end() ) if ( item == m_pStrVarDef->end() )
{
return false; return false;
}
if ( m_iSynFlags & noSTR ) if ( m_iSynFlags & noSTR )
{
Error ( ecUNEXPECTED_VAR, m_iPos, strTok ); Error ( ecUNEXPECTED_VAR, m_iPos, strTok );
}
m_iPos = iEnd; m_iPos = iEnd;
if ( !m_pParser->m_vStringVarBuf.size() ) if ( m_pParser->m_vStringVarBuf.size() == false)
{
Error ( ecINTERNAL_ERROR ); Error ( ecINTERNAL_ERROR );
}
a_Tok.SetString ( m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() ); a_Tok.SetString ( m_pParser->m_vStringVarBuf[item->second], m_pParser->m_vStringVarBuf.size() );
@ -876,7 +985,7 @@ bool QmuParserTokenReader::IsStrVarTok ( token_type &a_Tok )
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check wheter a token at a given position is an undefined variable. * @brief Check wheter a token at a given position is an undefined variable.
* *
@ -931,7 +1040,7 @@ bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok )
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Check wheter a token at a given position is a string. * @brief Check wheter a token at a given position is a string.
* @param a_Tok [out] If a variable token has been found it will be placed here. * @param a_Tok [out] If a variable token has been found it will be placed here.
@ -942,7 +1051,9 @@ bool QmuParserTokenReader::IsUndefVarTok ( token_type &a_Tok )
bool QmuParserTokenReader::IsString ( token_type &a_Tok ) bool QmuParserTokenReader::IsString ( token_type &a_Tok )
{ {
if ( m_strFormula[m_iPos] != '"' ) if ( m_strFormula[m_iPos] != '"' )
{
return false; return false;
}
QString strBuf ( m_strFormula[m_iPos + 1] ); QString strBuf ( m_strFormula[m_iPos + 1] );
int iEnd ( 0 ), iSkip ( 0 ); int iEnd ( 0 ), iSkip ( 0 );
@ -950,18 +1061,25 @@ bool QmuParserTokenReader::IsString ( token_type &a_Tok )
// parser over escaped '\"' end replace them with '"' // parser over escaped '\"' end replace them with '"'
for ( iEnd = strBuf.indexOf ( "\"" ); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf ( "\"", iEnd ) ) for ( iEnd = strBuf.indexOf ( "\"" ); iEnd != 0 && iEnd != -1; iEnd = strBuf.indexOf ( "\"", iEnd ) )
{ {
if ( strBuf[iEnd - 1] != '\\' ) break; if ( strBuf[iEnd - 1] != '\\' )
{
break;
}
strBuf.replace ( iEnd - 1, 2, "\"" ); strBuf.replace ( iEnd - 1, 2, "\"" );
iSkip++; iSkip++;
} }
if ( iEnd == -1 ) if ( iEnd == -1 )
{
Error ( ecUNTERMINATED_STRING, m_iPos, "\"" ); Error ( ecUNTERMINATED_STRING, m_iPos, "\"" );
}
QString strTok = strBuf.mid ( 0, iEnd ); QString strTok = strBuf.mid ( 0, iEnd );
if ( m_iSynFlags & noSTR ) if ( m_iSynFlags & noSTR )
{
Error ( ecUNEXPECTED_STR, m_iPos, strTok ); Error ( ecUNEXPECTED_STR, m_iPos, strTok );
}
m_pParser->m_vStringBuf.push_back ( strTok ); // Store string in internal buffer m_pParser->m_vStringBuf.push_back ( strTok ); // Store string in internal buffer
a_Tok.SetString ( strTok, m_pParser->m_vStringBuf.size() ); a_Tok.SetString ( strTok, m_pParser->m_vStringBuf.size() );
@ -972,7 +1090,7 @@ bool QmuParserTokenReader::IsString ( token_type &a_Tok )
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief Create an error containing the parse error position. * @brief Create an error containing the parse error position.
* *
@ -988,16 +1106,15 @@ void QmuParserTokenReader::Error ( EErrorCodes a_iErrc, int a_iPos, const QStri
m_pParser->Error ( a_iErrc, a_iPos, a_sTok ); m_pParser->Error ( a_iErrc, a_iPos, a_sTok );
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void QmuParserTokenReader::SetArgSep ( char_type cArgSep ) void QmuParserTokenReader::SetArgSep ( char_type cArgSep )
{ {
m_cArgSep = cArgSep; m_cArgSep = cArgSep;
} }
//---------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QChar QmuParserTokenReader::GetArgSep() const QChar QmuParserTokenReader::GetArgSep() const
{ {
return m_cArgSep; return m_cArgSep;
} }
} // namespace qmu } // namespace qmu

View File

@ -74,12 +74,12 @@ namespace qmu
token_type ReadNextToken(); token_type ReadNextToken();
private: private:
/**
/** @brief Syntax codes. * @brief Syntax codes.
*
The syntax codes control the syntax check done during the first time parsing of * The syntax codes control the syntax check done during the first time parsing of
the expression string. They are flags that indicate which tokens are allowed next * the expression string. They are flags that indicate which tokens are allowed next
if certain tokens are identified. * if certain tokens are identified.
*/ */
enum ESynCodes enum ESynCodes
{ {
@ -152,5 +152,3 @@ namespace qmu
} // namespace qmu } // namespace qmu
#endif #endif