Vera++.
--HG-- branch : feature
This commit is contained in:
parent
37ecf9fd86
commit
362638066a
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,23 +37,23 @@
|
||||||
class VMeasurement
|
class VMeasurement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief VStandardTableRow create empty row
|
* @brief VStandardTableRow create empty row
|
||||||
*/
|
*/
|
||||||
VMeasurement();
|
VMeasurement();
|
||||||
/**
|
/**
|
||||||
* @brief VStandardTableRow create row
|
* @brief VStandardTableRow create row
|
||||||
* @param base value in base size and growth
|
* @param base value in base size and growth
|
||||||
* @param ksize increment in sizes
|
* @param ksize increment in sizes
|
||||||
* @param kgrowth increment in growths
|
* @param kgrowth increment in growths
|
||||||
* @param description description of increment
|
* @param description description of increment
|
||||||
*/
|
*/
|
||||||
VMeasurement(const qreal &base, const qreal &ksize, const qreal &kheight,
|
VMeasurement(const qreal &base, const qreal &ksize, const qreal &kheight,
|
||||||
const QString &gui_text = QString(), const QString &number = QString(),
|
const QString &gui_text = QString(), const QString &number = QString(),
|
||||||
const QString &TagName = QString());
|
const QString &TagName = QString());
|
||||||
VMeasurement(const qreal &base, const QString &gui_text = QString(),
|
VMeasurement(const qreal &base, const QString &gui_text = QString(),
|
||||||
const QString &number = QString(), const QString &TagName = QString());
|
const QString &number = QString(), const QString &TagName = QString());
|
||||||
~VMeasurement(){}
|
~VMeasurement(){}
|
||||||
/**
|
/**
|
||||||
* @brief GetBase return value in base size and growth
|
* @brief GetBase return value in base size and growth
|
||||||
* @return value
|
* @return value
|
||||||
|
|
|
@ -54,7 +54,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
m = new VIndividualMeasurements(data);
|
m = new VIndividualMeasurements(data);
|
||||||
m->setContent(filePath);
|
m->setContent(filePath);
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
emit DialogClosed(QDialog::Rejected);
|
emit DialogClosed(QDialog::Rejected);
|
||||||
|
@ -101,8 +101,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
ui->lineEditGivenName->setText(m->GivenName());
|
ui->lineEditGivenName->setText(m->GivenName());
|
||||||
ui->lineEditFamilyName->setText(m->FamilyName());
|
ui->lineEditFamilyName->setText(m->FamilyName());
|
||||||
|
|
||||||
ui->comboBoxSex->addItem(tr("male"),QVariant(m->GenderToStr(VIndividualMeasurements::Male)));
|
ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(VIndividualMeasurements::Male)));
|
||||||
ui->comboBoxSex->addItem(tr("female"),QVariant(m->GenderToStr(VIndividualMeasurements::Female)));
|
ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(VIndividualMeasurements::Female)));
|
||||||
qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex()));
|
qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex()));
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
|
@ -473,7 +473,7 @@ void DialogIncrements::OpenTable()
|
||||||
m1 = new VIndividualMeasurements(data);
|
m1 = new VIndividualMeasurements(data);
|
||||||
m1->setContent(filePath);
|
m1->setContent(filePath);
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
delete m1;
|
delete m1;
|
||||||
|
@ -529,7 +529,7 @@ void DialogIncrements::OpenTable()
|
||||||
doc->SetPath(filePath);
|
doc->SetPath(filePath);
|
||||||
emit haveLiteChange();
|
emit haveLiteChange();
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
delete m1;
|
delete m1;
|
||||||
|
|
|
@ -116,7 +116,7 @@ void DialogIndividualMeasurements::DialogAccepted()
|
||||||
iMeasur.close();
|
iMeasur.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||||
|
@ -214,7 +214,7 @@ void DialogIndividualMeasurements::LoadIndividualTables()
|
||||||
const QString lang = QLocale(m.Language()).nativeLanguageName();
|
const QString lang = QLocale(m.Language()).nativeLanguageName();
|
||||||
ui->comboBoxLang->addItem(lang, QVariant(fi.absoluteFilePath()));
|
ui->comboBoxLang->addItem(lang, QVariant(fi.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||||
continue;
|
continue;
|
||||||
|
@ -249,7 +249,7 @@ void DialogIndividualMeasurements::OpenTable()
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fileName);
|
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fileName);
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
fileName.clear();
|
fileName.clear();
|
||||||
|
|
|
@ -86,7 +86,7 @@ void DialogStandardMeasurements::DialogAccepted()
|
||||||
m.setContent(_tablePath);
|
m.setContent(_tablePath);
|
||||||
qApp->setPatternUnit(m.Unit());
|
qApp->setPatternUnit(m.Unit());
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||||
|
@ -152,7 +152,7 @@ void DialogStandardMeasurements::LoadStandardTables()
|
||||||
m.setContent(fi.absoluteFilePath());
|
m.setContent(fi.absoluteFilePath());
|
||||||
ui->comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath()));
|
ui->comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1360,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
QString path = doc->MPath();
|
QString path = doc->MPath();
|
||||||
|
|
||||||
path = CheckPathToMeasurements(path, qApp->patternType());
|
path = CheckPathToMeasurements(path, qApp->patternType());
|
||||||
if(path.isEmpty())
|
if (path.isEmpty())
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return;
|
||||||
|
@ -1394,7 +1396,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("File error."), this);
|
e.CriticalMessageBox(tr("File error."), this);
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -1440,7 +1442,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
Clear();
|
Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
e.CriticalMessageBox(tr("Error parsing file."), this);
|
e.CriticalMessageBox(tr("Error parsing file."), this);
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -1478,7 +1480,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Pattern::
|
||||||
QMessageBox::StandardButton res = QMessageBox::question(this, "Loading measurements file", text,
|
QMessageBox::StandardButton res = QMessageBox::question(this, "Loading measurements file", text,
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
QMessageBox::Yes);
|
QMessageBox::Yes);
|
||||||
if(res == QMessageBox::No)
|
if (res == QMessageBox::No)
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -1495,7 +1497,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Pattern::
|
||||||
}
|
}
|
||||||
QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
|
QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
|
||||||
|
|
||||||
if(mPath.isEmpty())
|
if (mPath.isEmpty())
|
||||||
{
|
{
|
||||||
return mPath;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,26 +222,26 @@ void TableWindow::saveScene()
|
||||||
suffix << "svg" << "png" << "pdf" << "eps" << "ps";
|
suffix << "svg" << "png" << "pdf" << "eps" << "ps";
|
||||||
switch (suffix.indexOf(fi.suffix()))
|
switch (suffix.indexOf(fi.suffix()))
|
||||||
{
|
{
|
||||||
case 0: //svg
|
case 0: //svg
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
SvgFile(name);
|
SvgFile(name);
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case 1: //png
|
case 1: //png
|
||||||
PngFile(name);
|
PngFile(name);
|
||||||
break;
|
break;
|
||||||
case 2: //pdf
|
case 2: //pdf
|
||||||
PdfFile(name);
|
PdfFile(name);
|
||||||
break;
|
break;
|
||||||
case 3: //eps
|
case 3: //eps
|
||||||
EpsFile(name);
|
EpsFile(name);
|
||||||
break;
|
break;
|
||||||
case 4: //ps
|
case 4: //ps
|
||||||
PsFile(name);
|
PsFile(name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug() << "Bad file suffix"<<Q_FUNC_INFO;
|
qDebug() << "Bad file suffix"<<Q_FUNC_INFO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
|
paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
|
||||||
brush->setColor( QColor( Qt::gray ) );
|
brush->setColor( QColor( Qt::gray ) );
|
||||||
|
|
|
@ -36,7 +36,7 @@ const QString VToolPoint::TagName = QStringLiteral("point");
|
||||||
VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id),
|
VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id),
|
||||||
QGraphicsEllipseItem(parent), radius(DefRadius), namePoint(0), lineName(0)
|
QGraphicsEllipseItem(parent), radius(DefRadius), namePoint(0), lineName(0)
|
||||||
{
|
{
|
||||||
switch(qApp->patternUnit())
|
switch (qApp->patternUnit())
|
||||||
{
|
{
|
||||||
case Valentina::Mm:
|
case Valentina::Mm:
|
||||||
radius = qApp->toPixel(DefRadius);
|
radius = qApp->toPixel(DefRadius);
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -39,18 +39,17 @@ class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief VNodePoint constructor.
|
* @brief VNodePoint constructor.
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
* @param id object id in container.
|
* @param id object id in container.
|
||||||
* @param id object id in containerPoint.
|
* @param id object id in containerPoint.
|
||||||
* @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;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,18 +39,17 @@ class VNodeSpline:public VAbstractNode, public QGraphicsPathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief VNodeSpline constructor.
|
* @brief VNodeSpline constructor.
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
* @param id object id in container.
|
* @param id object id in container.
|
||||||
* @param id object id in containerSpline.
|
* @param id object id in containerSpline.
|
||||||
* @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.
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -481,7 +481,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta
|
||||||
++j;
|
++j;
|
||||||
} while (pointsD2 < d2.RemoveEdge(indexD2).CountNode());
|
} while (pointsD2 < d2.RemoveEdge(indexD2).CountNode());
|
||||||
}
|
}
|
||||||
} while(i < d1.RemoveEdge(indexD1).CountNode());
|
} while (i < d1.RemoveEdge(indexD1).CountNode());
|
||||||
|
|
||||||
newDetail.setName("Detail");
|
newDetail.setName("Detail");
|
||||||
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Valentina::FromTool);
|
VToolDetail::Create(0, newDetail, scene, doc, data, parse, Valentina::FromTool);
|
||||||
|
|
|
@ -174,7 +174,7 @@ QString VApplication::translationsPath() const
|
||||||
|
|
||||||
void VApplication::InitLineWidth()
|
void VApplication::InitLineWidth()
|
||||||
{
|
{
|
||||||
switch(_patternUnit)
|
switch (_patternUnit)
|
||||||
{
|
{
|
||||||
case Valentina::Mm:
|
case Valentina::Mm:
|
||||||
_widthMainLine = DefWidth;
|
_widthMainLine = DefWidth;
|
||||||
|
|
|
@ -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();
|
||||||
|
@ -347,7 +348,7 @@ Valentina::Units VDomDocument::StrToUnits(const QString &unit)
|
||||||
QString VDomDocument::UnitsToStr(const Valentina::Units &unit)
|
QString VDomDocument::UnitsToStr(const Valentina::Units &unit)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
switch(unit)
|
switch (unit)
|
||||||
{
|
{
|
||||||
case Valentina::Mm:
|
case Valentina::Mm:
|
||||||
result = "mm";
|
result = "mm";
|
||||||
|
|
|
@ -460,7 +460,7 @@ Valentina::Units VPattern::MUnit() const
|
||||||
QStringList units;
|
QStringList units;
|
||||||
units << "mm" << "cm" << "inch";
|
units << "mm" << "cm" << "inch";
|
||||||
QString unit = GetParametrString(element, AttrUnit);
|
QString unit = GetParametrString(element, AttrUnit);
|
||||||
switch(units.indexOf(unit))
|
switch (units.indexOf(unit))
|
||||||
{
|
{
|
||||||
case 0:// mm
|
case 0:// mm
|
||||||
return Valentina::Mm;
|
return Valentina::Mm;
|
||||||
|
@ -491,7 +491,7 @@ Pattern::Measurements VPattern::MType() const
|
||||||
QString type = GetParametrString(element, AttrType);
|
QString type = GetParametrString(element, AttrType);
|
||||||
QStringList types;
|
QStringList types;
|
||||||
types << "standard" << "individual";
|
types << "standard" << "individual";
|
||||||
switch(types.indexOf(type))
|
switch (types.indexOf(type))
|
||||||
{
|
{
|
||||||
case 0:// standard
|
case 0:// standard
|
||||||
return Pattern::Standard;
|
return Pattern::Standard;
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,7 @@ void VStandardMeasurements::Measurements()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(qint32 i = 0; i < nodeList.size(); ++i)
|
for (qint32 i = 0; i < nodeList.size(); ++i)
|
||||||
{
|
{
|
||||||
const QDomNode domNode = nodeList.at(i);
|
const QDomNode domNode = nodeList.at(i);
|
||||||
if (domNode.isNull() == false && domNode.isElement())
|
if (domNode.isNull() == false && domNode.isElement())
|
||||||
|
|
|
@ -39,78 +39,78 @@ namespace qmu
|
||||||
// Trigonometric function
|
// Trigonometric function
|
||||||
qreal QmuParser::Sinh(qreal v)
|
qreal QmuParser::Sinh(qreal v)
|
||||||
{
|
{
|
||||||
return sinh(v);
|
return sinh(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::Cosh(qreal v)
|
qreal QmuParser::Cosh(qreal v)
|
||||||
{
|
{
|
||||||
return cosh(v);
|
return cosh(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::Tanh(qreal v)
|
qreal QmuParser::Tanh(qreal v)
|
||||||
{
|
{
|
||||||
return tanh(v);
|
return tanh(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::ASinh(qreal v)
|
qreal QmuParser::ASinh(qreal v)
|
||||||
{
|
{
|
||||||
return log(v + qSqrt(v * v + 1));
|
return log(v + qSqrt(v * v + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::ACosh(qreal v)
|
qreal QmuParser::ACosh(qreal v)
|
||||||
{
|
{
|
||||||
return log(v + qSqrt(v * v - 1));
|
return log(v + qSqrt(v * v - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::ATanh(qreal v)
|
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
|
||||||
qreal QmuParser::Log2(qreal v)
|
qreal QmuParser::Log2(qreal v)
|
||||||
{
|
{
|
||||||
#ifdef MUP_MATH_EXCEPTIONS
|
#ifdef MUP_MATH_EXCEPTIONS
|
||||||
if (v<=0)
|
if (v<=0)
|
||||||
{
|
{
|
||||||
throw QmuParserError(ecDOMAIN_ERROR, "Log2");
|
throw QmuParserError(ecDOMAIN_ERROR, "Log2");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return log(v)/log(2.0);
|
return log(v)/log(2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logarithm base 10
|
// Logarithm base 10
|
||||||
qreal QmuParser::Log10(qreal v)
|
qreal QmuParser::Log10(qreal v)
|
||||||
{
|
{
|
||||||
#ifdef MUP_MATH_EXCEPTIONS
|
#ifdef MUP_MATH_EXCEPTIONS
|
||||||
if (v<=0)
|
if (v<=0)
|
||||||
{
|
{
|
||||||
throw QmuParserError(ecDOMAIN_ERROR, "Log10");
|
throw QmuParserError(ecDOMAIN_ERROR, "Log10");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return log10(v);
|
return log10(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// misc
|
// misc
|
||||||
qreal QmuParser::Abs(qreal v)
|
qreal QmuParser::Abs(qreal v)
|
||||||
{
|
{
|
||||||
return qAbs(v);
|
return qAbs(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::Rint(qreal v)
|
qreal QmuParser::Rint(qreal v)
|
||||||
{
|
{
|
||||||
return qFloor(v + 0.5);
|
return qFloor(v + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QmuParser::Sign(qreal v)
|
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
|
||||||
|
@ -118,10 +118,10 @@ qreal QmuParser::Sign(qreal v)
|
||||||
*/
|
*/
|
||||||
qreal QmuParser::UnaryMinus(qreal v)
|
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)
|
||||||
return fRes;
|
{
|
||||||
|
fRes += a_afArg[i];
|
||||||
|
}
|
||||||
|
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)
|
||||||
return fRes/static_cast<qreal>(a_iArgc);
|
{
|
||||||
|
fRes += a_afArg[i];
|
||||||
|
}
|
||||||
|
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,19 +169,19 @@ 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.");
|
||||||
}
|
}
|
||||||
qreal fRes=a_afArg[0];
|
qreal fRes=a_afArg[0];
|
||||||
for (int i=0; i<a_iArgc; ++i)
|
for (int i=0; i<a_iArgc; ++i)
|
||||||
{
|
{
|
||||||
fRes = qMin(fRes, a_afArg[i]);
|
fRes = qMin(fRes, a_afArg[i]);
|
||||||
}
|
}
|
||||||
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,19 +189,19 @@ 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.");
|
||||||
}
|
}
|
||||||
qreal fRes=a_afArg[0];
|
qreal fRes=a_afArg[0];
|
||||||
for (int i=0; i<a_iArgc; ++i)
|
for (int i=0; i<a_iArgc; ++i)
|
||||||
{
|
{
|
||||||
fRes = qMax(fRes, a_afArg[i]);
|
fRes = qMax(fRes, a_afArg[i]);
|
||||||
}
|
}
|
||||||
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
|
||||||
|
@ -205,30 +211,30 @@ qreal QmuParser::Max(const qreal *a_afArg, int a_iArgc)
|
||||||
*/
|
*/
|
||||||
int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal)
|
int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal)
|
||||||
{
|
{
|
||||||
qreal fVal(0);
|
qreal fVal(0);
|
||||||
|
|
||||||
#if defined(_UNICODE)
|
#if defined(_UNICODE)
|
||||||
std::wstring a_szExprStd = a_szExpr.toStdWString();
|
std::wstring a_szExprStd = a_szExpr.toStdWString();
|
||||||
#else
|
#else
|
||||||
std::string a_szExprStd = a_szExpr.toStdString();
|
std::string a_szExprStd = a_szExpr.toStdString();
|
||||||
#endif
|
#endif
|
||||||
stringstream_type stream(a_szExprStd);
|
stringstream_type stream(a_szExprStd);
|
||||||
stream.seekg(0); // todo: check if this really is necessary
|
stream.seekg(0); // todo: check if this really is necessary
|
||||||
stream.imbue(QmuParser::s_locale);
|
stream.imbue(QmuParser::s_locale);
|
||||||
stream >> fVal;
|
stream >> fVal;
|
||||||
stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading
|
stringstream_type::pos_type iEnd = stream.tellg(); // Position after reading
|
||||||
|
|
||||||
if (iEnd==static_cast<stringstream_type::pos_type>(-1))
|
if (iEnd==static_cast<stringstream_type::pos_type>(-1))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*a_iPos += static_cast<int>(iEnd);
|
*a_iPos += static_cast<int>(iEnd);
|
||||||
*a_fVal = fVal;
|
*a_fVal = fVal;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Constructor.
|
* @brief Constructor.
|
||||||
*
|
*
|
||||||
|
@ -236,15 +242,15 @@ int QmuParser::IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal)
|
||||||
*/
|
*/
|
||||||
QmuParser::QmuParser():QmuParserBase()
|
QmuParser::QmuParser():QmuParserBase()
|
||||||
{
|
{
|
||||||
AddValIdent(IsVal);
|
AddValIdent(IsVal);
|
||||||
|
|
||||||
InitCharSets();
|
InitCharSets();
|
||||||
InitFun();
|
InitFun();
|
||||||
InitConst();
|
InitConst();
|
||||||
InitOprt();
|
InitOprt();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Define the character sets.
|
* @brief Define the character sets.
|
||||||
* @sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars
|
* @sa DefineNameChars, DefineOprtChars, DefineInfixOprtChars
|
||||||
|
@ -254,53 +260,53 @@ QmuParser::QmuParser():QmuParserBase()
|
||||||
*/
|
*/
|
||||||
void QmuParser::InitCharSets()
|
void QmuParser::InitCharSets()
|
||||||
{
|
{
|
||||||
DefineNameChars( "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" );
|
DefineNameChars( "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" );
|
||||||
DefineOprtChars( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}" );
|
DefineOprtChars( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}" );
|
||||||
DefineInfixOprtChars( "/+-*^?<>=#!$%&|~'_" );
|
DefineInfixOprtChars( "/+-*^?<>=#!$%&|~'_" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the default functions.
|
* @brief Initialize the default functions.
|
||||||
*/
|
*/
|
||||||
void QmuParser::InitFun()
|
void QmuParser::InitFun()
|
||||||
{
|
{
|
||||||
// trigonometric functions
|
// trigonometric functions
|
||||||
DefineFun("sin", qSin);
|
DefineFun("sin", qSin);
|
||||||
DefineFun("cos", qCos);
|
DefineFun("cos", qCos);
|
||||||
DefineFun("tan", qTan);
|
DefineFun("tan", qTan);
|
||||||
// arcus functions
|
// arcus functions
|
||||||
DefineFun("asin", qAsin);
|
DefineFun("asin", qAsin);
|
||||||
DefineFun("acos", qAcos);
|
DefineFun("acos", qAcos);
|
||||||
DefineFun("atan", qAtan);
|
DefineFun("atan", qAtan);
|
||||||
DefineFun("atan2", qAtan2);
|
DefineFun("atan2", qAtan2);
|
||||||
// hyperbolic functions
|
// hyperbolic functions
|
||||||
DefineFun("sinh", Sinh);
|
DefineFun("sinh", Sinh);
|
||||||
DefineFun("cosh", Cosh);
|
DefineFun("cosh", Cosh);
|
||||||
DefineFun("tanh", Tanh);
|
DefineFun("tanh", Tanh);
|
||||||
// arcus hyperbolic functions
|
// arcus hyperbolic functions
|
||||||
DefineFun("asinh", ASinh);
|
DefineFun("asinh", ASinh);
|
||||||
DefineFun("acosh", ACosh);
|
DefineFun("acosh", ACosh);
|
||||||
DefineFun("atanh", ATanh);
|
DefineFun("atanh", ATanh);
|
||||||
// Logarithm functions
|
// Logarithm functions
|
||||||
DefineFun("log2", Log2);
|
DefineFun("log2", Log2);
|
||||||
DefineFun("log10", Log10);
|
DefineFun("log10", Log10);
|
||||||
DefineFun("log", Log10);
|
DefineFun("log", Log10);
|
||||||
DefineFun("ln", qLn);
|
DefineFun("ln", qLn);
|
||||||
// misc
|
// misc
|
||||||
DefineFun("exp", qExp);
|
DefineFun("exp", qExp);
|
||||||
DefineFun("sqrt", qSqrt);
|
DefineFun("sqrt", qSqrt);
|
||||||
DefineFun("sign", Sign);
|
DefineFun("sign", Sign);
|
||||||
DefineFun("rint", Rint);
|
DefineFun("rint", Rint);
|
||||||
DefineFun("abs", Abs);
|
DefineFun("abs", Abs);
|
||||||
// Functions with variable number of arguments
|
// Functions with variable number of arguments
|
||||||
DefineFun("sum", Sum);
|
DefineFun("sum", Sum);
|
||||||
DefineFun("avg", Avg);
|
DefineFun("avg", Avg);
|
||||||
DefineFun("min", Min);
|
DefineFun("min", Min);
|
||||||
DefineFun("max", Max);
|
DefineFun("max", Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Initialize constants.
|
* @brief Initialize constants.
|
||||||
*
|
*
|
||||||
|
@ -309,11 +315,11 @@ void QmuParser::InitFun()
|
||||||
*/
|
*/
|
||||||
void QmuParser::InitConst()
|
void QmuParser::InitConst()
|
||||||
{
|
{
|
||||||
DefineConst("_pi", (qreal)M_PI);
|
DefineConst("_pi", (qreal)M_PI);
|
||||||
DefineConst("_e", (qreal)M_E);
|
DefineConst("_e", (qreal)M_E);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Initialize operators.
|
* @brief Initialize operators.
|
||||||
*
|
*
|
||||||
|
@ -321,38 +327,38 @@ void QmuParser::InitConst()
|
||||||
*/
|
*/
|
||||||
void QmuParser::InitOprt()
|
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);
|
||||||
Q_UNUSED(nStart);
|
Q_UNUSED(nStart);
|
||||||
Q_UNUSED(nEnd);
|
Q_UNUSED(nEnd);
|
||||||
// this is just sample code to illustrate modifying variable names on the fly.
|
// this is just sample code to illustrate modifying variable names on the fly.
|
||||||
// I'm not sure anyone really needs such a feature...
|
// I'm not sure anyone really needs such a feature...
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd);
|
string sVar(pExpr->begin()+nStart, pExpr->begin()+nEnd);
|
||||||
string sRepl = std::string("_") + sVar + "_";
|
string sRepl = std::string("_") + sVar + "_";
|
||||||
|
|
||||||
int nOrigVarEnd = nEnd;
|
int nOrigVarEnd = nEnd;
|
||||||
cout << "variable detected!\n";
|
cout << "variable detected!\n";
|
||||||
cout << " Expr: " << *pExpr << "\n";
|
cout << " Expr: " << *pExpr << "\n";
|
||||||
cout << " Start: " << nStart << "\n";
|
cout << " Start: " << nStart << "\n";
|
||||||
cout << " End: " << nEnd << "\n";
|
cout << " End: " << nEnd << "\n";
|
||||||
cout << " Var: \"" << sVar << "\"\n";
|
cout << " Var: \"" << sVar << "\"\n";
|
||||||
cout << " Repl: \"" << sRepl << "\"\n";
|
cout << " Repl: \"" << sRepl << "\"\n";
|
||||||
nEnd = nStart + sRepl.length();
|
nEnd = nStart + sRepl.length();
|
||||||
cout << " End: " << nEnd << "\n";
|
cout << " End: " << nEnd << "\n";
|
||||||
pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl);
|
pExpr->replace(pExpr->begin()+nStart, pExpr->begin()+nOrigVarEnd, sRepl);
|
||||||
cout << " New expr: " << *pExpr << "\n";
|
cout << " New expr: " << *pExpr << "\n";
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @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.
|
||||||
|
@ -368,25 +374,25 @@ void QmuParser::OnDetectVar(const QString &pExpr, int &nStart, int &nEnd)
|
||||||
*/
|
*/
|
||||||
qreal QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const
|
qreal QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const
|
||||||
{
|
{
|
||||||
qreal fRes(0),
|
qreal fRes(0),
|
||||||
fBuf(*a_Var),
|
fBuf(*a_Var),
|
||||||
f[4] = {0,0,0,0},
|
f[4] = {0, 0, 0, 0},
|
||||||
fEpsilon(a_fEpsilon);
|
fEpsilon(a_fEpsilon);
|
||||||
|
|
||||||
// Backwards compatible calculation of epsilon inc case the user doesnt provide
|
// Backwards compatible calculation of epsilon inc case the user doesnt provide
|
||||||
// his own epsilon
|
// his own epsilon
|
||||||
if (qFuzzyCompare(fEpsilon + 1, 1 + 0))
|
if (qFuzzyCompare(fEpsilon + 1, 1 + 0))
|
||||||
{
|
{
|
||||||
fEpsilon = (qFuzzyCompare(a_fPos + 1, 1 + 0)) ? static_cast<qreal>(1e-10) : static_cast<qreal>(1e-7) * a_fPos;
|
fEpsilon = (qFuzzyCompare(a_fPos + 1, 1 + 0)) ? static_cast<qreal>(1e-10) : static_cast<qreal>(1e-7) * a_fPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
*a_Var = a_fPos+2 * fEpsilon; f[0] = Eval();
|
*a_Var = a_fPos+2 * fEpsilon; f[0] = Eval();
|
||||||
*a_Var = a_fPos+1 * fEpsilon; f[1] = Eval();
|
*a_Var = a_fPos+1 * fEpsilon; f[1] = Eval();
|
||||||
*a_Var = a_fPos-1 * fEpsilon; f[2] = Eval();
|
*a_Var = a_fPos-1 * fEpsilon; f[2] = Eval();
|
||||||
*a_Var = a_fPos-2 * fEpsilon; f[3] = Eval();
|
*a_Var = a_fPos-2 * fEpsilon; f[3] = Eval();
|
||||||
*a_Var = fBuf; // restore variable
|
*a_Var = fBuf; // restore variable
|
||||||
|
|
||||||
fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon);
|
fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon);
|
||||||
return fRes;
|
return fRes;
|
||||||
}
|
}
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace qmu
|
||||||
virtual void InitFun();
|
virtual void InitFun();
|
||||||
virtual void InitConst();
|
virtual void InitConst();
|
||||||
virtual void InitOprt();
|
virtual void InitOprt();
|
||||||
virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd);
|
virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd);
|
||||||
qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const;
|
qreal Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon = 0) const;
|
||||||
protected:
|
protected:
|
||||||
static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal);
|
static int IsVal(const QString &a_szExpr, int *a_iPos, qreal *a_fVal);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -53,210 +53,209 @@ namespace qmu
|
||||||
*/
|
*/
|
||||||
class QmuParserBase
|
class QmuParserBase
|
||||||
{
|
{
|
||||||
friend class QmuParserTokenReader;
|
friend class QmuParserTokenReader;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Type of the error class.
|
* @brief Type of the error class.
|
||||||
*
|
*
|
||||||
* Included for backwards compatibility.
|
* Included for backwards compatibility.
|
||||||
*/
|
*/
|
||||||
typedef QmuParserError exception_type;
|
typedef QmuParserError exception_type;
|
||||||
|
|
||||||
QmuParserBase();
|
QmuParserBase();
|
||||||
QmuParserBase(const QmuParserBase &a_Parser);
|
QmuParserBase(const QmuParserBase &a_Parser);
|
||||||
QmuParserBase& operator=(const QmuParserBase &a_Parser);
|
QmuParserBase& operator=(const QmuParserBase &a_Parser);
|
||||||
virtual ~QmuParserBase();
|
virtual ~QmuParserBase();
|
||||||
|
|
||||||
static void EnableDebugDump(bool bDumpCmd, bool bDumpStack);
|
static void EnableDebugDump(bool bDumpCmd, bool bDumpStack);
|
||||||
qreal Eval() const;
|
qreal Eval() const;
|
||||||
qreal* Eval(int &nStackSize) const;
|
qreal* Eval(int &nStackSize) const;
|
||||||
void Eval(qreal *results, int nBulkSize);
|
void Eval(qreal *results, int nBulkSize);
|
||||||
int GetNumResults() const;
|
int GetNumResults() const;
|
||||||
void SetExpr(const QString &a_sExpr);
|
void SetExpr(const QString &a_sExpr);
|
||||||
void SetVarFactory(facfun_type a_pFactory, void *pUserData = NULL);
|
void SetVarFactory(facfun_type a_pFactory, void *pUserData = NULL);
|
||||||
void SetDecSep(char_type cDecSep);
|
void SetDecSep(char_type cDecSep);
|
||||||
void SetThousandsSep(char_type cThousandsSep = 0);
|
void SetThousandsSep(char_type cThousandsSep = 0);
|
||||||
void ResetLocale();
|
void ResetLocale();
|
||||||
void EnableOptimizer(bool a_bIsOn=true);
|
void EnableOptimizer(bool a_bIsOn=true);
|
||||||
void EnableBuiltInOprt(bool a_bIsOn=true);
|
void EnableBuiltInOprt(bool a_bIsOn=true);
|
||||||
bool HasBuiltInOprt() const;
|
bool HasBuiltInOprt() const;
|
||||||
void AddValIdent(identfun_type a_pCallback);
|
void AddValIdent(identfun_type a_pCallback);
|
||||||
void DefineOprt(const QString &a_strName, fun_type2 a_pFun, unsigned a_iPri=0,
|
void DefineOprt(const QString &a_strName, fun_type2 a_pFun, unsigned a_iPri=0,
|
||||||
EOprtAssociativity a_eAssociativity = oaLEFT, bool a_bAllowOpt = false);
|
EOprtAssociativity a_eAssociativity = oaLEFT, bool a_bAllowOpt = false);
|
||||||
void DefineConst(const QString &a_sName, qreal a_fVal);
|
void DefineConst(const QString &a_sName, qreal a_fVal);
|
||||||
void DefineStrConst(const QString &a_sName, const QString &a_strVal);
|
void DefineStrConst(const QString &a_sName, const QString &a_strVal);
|
||||||
void DefineVar(const QString &a_sName, qreal *a_fVar);
|
void DefineVar(const QString &a_sName, qreal *a_fVar);
|
||||||
void DefinePostfixOprt(const QString &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true);
|
void DefinePostfixOprt(const QString &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true);
|
||||||
void DefineInfixOprt(const QString &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX,
|
void DefineInfixOprt(const QString &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX,
|
||||||
bool a_bAllowOpt=true);
|
bool a_bAllowOpt=true);
|
||||||
// Clear user defined variables, constants or functions
|
// Clear user defined variables, constants or functions
|
||||||
void ClearVar();
|
void ClearVar();
|
||||||
void ClearFun();
|
void ClearFun();
|
||||||
void ClearConst();
|
void ClearConst();
|
||||||
void ClearInfixOprt();
|
void ClearInfixOprt();
|
||||||
void ClearPostfixOprt();
|
void ClearPostfixOprt();
|
||||||
void ClearOprt();
|
void ClearOprt();
|
||||||
void RemoveVar(const QString &a_strVarName);
|
void RemoveVar(const QString &a_strVarName);
|
||||||
const varmap_type& GetUsedVar() const;
|
const varmap_type& GetUsedVar() const;
|
||||||
const varmap_type& GetVar() const;
|
const varmap_type& GetVar() const;
|
||||||
const valmap_type& GetConst() const;
|
const valmap_type& GetConst() const;
|
||||||
const QString& GetExpr() const;
|
const QString& GetExpr() const;
|
||||||
const funmap_type& GetFunDef() const;
|
const funmap_type& GetFunDef() const;
|
||||||
QString GetVersion(EParserVersionInfo eInfo = pviFULL) const;
|
QString GetVersion(EParserVersionInfo eInfo = pviFULL) const;
|
||||||
const QStringList& GetOprtDef() const;
|
const QStringList& GetOprtDef() const;
|
||||||
void DefineNameChars(const QString &a_szCharset);
|
void DefineNameChars(const QString &a_szCharset);
|
||||||
void DefineOprtChars(const QString &a_szCharset);
|
void DefineOprtChars(const QString &a_szCharset);
|
||||||
void DefineInfixOprtChars(const QString &a_szCharset);
|
void DefineInfixOprtChars(const QString &a_szCharset);
|
||||||
const QString& ValidNameChars() const;
|
const QString& ValidNameChars() const;
|
||||||
const QString& ValidOprtChars() const;
|
const QString& ValidOprtChars() const;
|
||||||
const QString& ValidInfixOprtChars() const;
|
const QString& ValidInfixOprtChars() const;
|
||||||
void SetArgSep(char_type cArgSep);
|
void SetArgSep(char_type cArgSep);
|
||||||
QChar GetArgSep() const;
|
QChar GetArgSep() const;
|
||||||
void Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_strTok = QString() ) const;
|
void Error(EErrorCodes a_iErrc, int a_iPos = -1, const QString &a_strTok = QString() ) const;
|
||||||
/**
|
/**
|
||||||
* @fn void qmu::QmuParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun,
|
* @fn void qmu::QmuParserBase::DefineFun(const string_type &a_strName, fun_type0 a_pFun,
|
||||||
* bool a_bAllowOpt = true)
|
* bool a_bAllowOpt = true)
|
||||||
* @brief Define a parser function without arguments.
|
* @brief Define a parser function without arguments.
|
||||||
* @param a_strName Name of the function
|
* @param a_strName Name of the function
|
||||||
* @param a_pFun Pointer to the callback function
|
* @param a_pFun Pointer to the callback function
|
||||||
* @param a_bAllowOpt A flag indicating this function may be optimized
|
* @param a_bAllowOpt A flag indicating this function may be optimized
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void DefineFun(const QString &a_strName, T a_pFun, bool a_bAllowOpt = true)
|
void DefineFun(const QString &a_strName, T a_pFun, bool a_bAllowOpt = true)
|
||||||
{
|
{
|
||||||
AddCallback( a_strName, QmuParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars() );
|
AddCallback( a_strName, QmuParserCallback(a_pFun, a_bAllowOpt), m_FunDef, ValidNameChars() );
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
static const QStringList c_DefaultOprt;
|
static const QStringList c_DefaultOprt;
|
||||||
static std::locale s_locale; ///< The locale used by the parser
|
static std::locale s_locale; ///< The locale used by the parser
|
||||||
static bool g_DbgDumpCmdCode;
|
static bool g_DbgDumpCmdCode;
|
||||||
static bool g_DbgDumpStack;
|
static bool g_DbgDumpStack;
|
||||||
void Init();
|
void Init();
|
||||||
virtual void InitCharSets() = 0;
|
virtual void InitCharSets() = 0;
|
||||||
virtual void InitFun() = 0;
|
virtual void InitFun() = 0;
|
||||||
virtual void InitConst() = 0;
|
virtual void InitConst() = 0;
|
||||||
virtual void InitOprt() = 0;
|
virtual void InitOprt() = 0;
|
||||||
virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd);
|
virtual void OnDetectVar(const QString &pExpr, int &nStart, int &nEnd);
|
||||||
/**
|
/**
|
||||||
* @brief A facet class used to change decimal and thousands separator.
|
* @brief A facet class used to change decimal and thousands separator.
|
||||||
*/
|
*/
|
||||||
template<class TChar>
|
template<class TChar>
|
||||||
class change_dec_sep : public std::numpunct<TChar>
|
class change_dec_sep : public std::numpunct<TChar>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3)
|
explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3)
|
||||||
:std::numpunct<TChar>(), m_nGroup(nGroup), m_cDecPoint(cDecSep), m_cThousandsSep(cThousandsSep)
|
:std::numpunct<TChar>(), m_nGroup(nGroup), m_cDecPoint(cDecSep), m_cThousandsSep(cThousandsSep)
|
||||||
{}
|
{}
|
||||||
protected:
|
protected:
|
||||||
virtual char_type do_decimal_point() const
|
virtual char_type do_decimal_point() const
|
||||||
{
|
{
|
||||||
return m_cDecPoint;
|
return m_cDecPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual char_type do_thousands_sep() const
|
virtual char_type do_thousands_sep() const
|
||||||
{
|
{
|
||||||
return m_cThousandsSep;
|
return m_cThousandsSep;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string do_grouping() const
|
virtual std::string do_grouping() const
|
||||||
{
|
{
|
||||||
return std::string(1, m_nGroup);
|
return std::string(1, m_nGroup);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int m_nGroup;
|
int m_nGroup;
|
||||||
char_type m_cDecPoint;
|
char_type m_cDecPoint;
|
||||||
char_type m_cThousandsSep;
|
char_type m_cThousandsSep;
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Typedef for the parse functions.
|
* @brief Typedef for the parse functions.
|
||||||
*
|
*
|
||||||
* The parse function do the actual work. The parser exchanges
|
* The parse function do the actual work. The parser exchanges
|
||||||
* the function pointer to the parser function depending on
|
* the function pointer to the parser function depending on
|
||||||
* which state it is in. (i.e. bytecode parser vs. string parser)
|
* which state it is in. (i.e. bytecode parser vs. string parser)
|
||||||
*/
|
*/
|
||||||
typedef qreal (QmuParserBase::*ParseFunction)() const;
|
typedef qreal (QmuParserBase::*ParseFunction)() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type used for storing an array of values.
|
* @brief Type used for storing an array of values.
|
||||||
*/
|
*/
|
||||||
typedef QVector<qreal> valbuf_type;
|
typedef QVector<qreal> valbuf_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type for a vector of strings.
|
* @brief Type for a vector of strings.
|
||||||
*/
|
*/
|
||||||
typedef QVector<QString> stringbuf_type;
|
typedef QVector<QString> stringbuf_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Typedef for the token reader.
|
* @brief Typedef for the token reader.
|
||||||
*/
|
*/
|
||||||
typedef QmuParserTokenReader token_reader_type;
|
typedef QmuParserTokenReader token_reader_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type used for parser tokens.
|
* @brief Type used for parser tokens.
|
||||||
*/
|
*/
|
||||||
typedef QmuParserToken<qreal, QString> token_type;
|
typedef QmuParserToken<qreal, QString> token_type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Maximum number of threads spawned by OpenMP when using the bulk mode.
|
* @brief Maximum number of threads spawned by OpenMP when using the bulk mode.
|
||||||
*/
|
*/
|
||||||
static const int s_MaxNumOpenMPThreads = 4;
|
static const int s_MaxNumOpenMPThreads = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pointer to the parser function.
|
* @brief Pointer to the parser function.
|
||||||
*
|
*
|
||||||
* Eval() calls the function whose address is stored there.
|
* Eval() calls the function whose address is stored there.
|
||||||
*/
|
*/
|
||||||
mutable ParseFunction m_pParseFormula;
|
mutable ParseFunction m_pParseFormula;
|
||||||
mutable QmuParserByteCode m_vRPN; ///< The Bytecode class.
|
mutable QmuParserByteCode m_vRPN; ///< The Bytecode class.
|
||||||
mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments
|
mutable stringbuf_type m_vStringBuf; ///< String buffer, used for storing string function arguments
|
||||||
stringbuf_type m_vStringVarBuf;
|
stringbuf_type m_vStringVarBuf;
|
||||||
|
|
||||||
std::unique_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
|
std::unique_ptr<token_reader_type> m_pTokenReader; ///< Managed pointer to the token reader object.
|
||||||
|
|
||||||
funmap_type m_FunDef; ///< Map of function names and pointers.
|
funmap_type m_FunDef; ///< Map of function names and pointers.
|
||||||
funmap_type m_PostOprtDef; ///< Postfix operator callbacks
|
funmap_type m_PostOprtDef; ///< Postfix operator callbacks
|
||||||
funmap_type m_InfixOprtDef; ///< unary infix operator.
|
funmap_type m_InfixOprtDef; ///< unary infix operator.
|
||||||
funmap_type m_OprtDef; ///< Binary operator callbacks
|
funmap_type m_OprtDef; ///< Binary operator callbacks
|
||||||
valmap_type m_ConstDef; ///< user constants.
|
valmap_type m_ConstDef; ///< user constants.
|
||||||
strmap_type m_StrVarDef; ///< user defined string constants
|
strmap_type m_StrVarDef; ///< user defined string constants
|
||||||
varmap_type m_VarDef; ///< user defind variables.
|
varmap_type m_VarDef; ///< user defind variables.
|
||||||
|
|
||||||
bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off
|
bool m_bBuiltInOp; ///< Flag that can be used for switching built in operators on and off
|
||||||
|
|
||||||
QString m_sNameChars; ///< Charset for names
|
QString m_sNameChars; ///< Charset for names
|
||||||
QString m_sOprtChars; ///< Charset for postfix/ binary operator tokens
|
QString m_sOprtChars; ///< Charset for postfix/ binary operator tokens
|
||||||
QString m_sInfixOprtChars; ///< Charset for infix operator tokens
|
QString m_sInfixOprtChars; ///< Charset for infix operator tokens
|
||||||
|
|
||||||
mutable int m_nIfElseCounter; ///< Internal counter for keeping track of nested if-then-else clauses
|
mutable int m_nIfElseCounter; ///< Internal counter for keeping track of nested if-then-else clauses
|
||||||
|
|
||||||
// items merely used for caching state information
|
// items merely used for caching state information
|
||||||
mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine
|
mutable valbuf_type m_vStackBuffer; ///< This is merely a buffer used for the stack in the cmd parsing routine
|
||||||
mutable int m_nFinalResultIdx;
|
mutable int m_nFinalResultIdx;
|
||||||
|
|
||||||
void Assign(const QmuParserBase &a_Parser);
|
void Assign(const QmuParserBase &a_Parser);
|
||||||
void InitTokenReader();
|
void InitTokenReader();
|
||||||
void ReInit() const;
|
void ReInit() const;
|
||||||
void AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback,
|
void AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback,
|
||||||
funmap_type &a_Storage, const QString &a_szCharSet );
|
funmap_type &a_Storage, const QString &a_szCharSet );
|
||||||
void ApplyRemainingOprt(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
void ApplyRemainingOprt(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
||||||
void ApplyBinOprt(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
void ApplyBinOprt(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
||||||
void ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
void ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal) const;
|
||||||
void ApplyFunc(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal, int iArgCount) const;
|
void ApplyFunc(QStack<token_type> &a_stOpt, QStack<token_type> &a_stVal, int iArgCount) const;
|
||||||
token_type ApplyStrFunc(const token_type &a_FunTok, const QVector<token_type> &a_vArg) const;
|
token_type ApplyStrFunc(const token_type &a_FunTok, const QVector<token_type> &a_vArg) const;
|
||||||
int GetOprtPrecedence(const token_type &a_Tok) const;
|
int GetOprtPrecedence(const token_type &a_Tok) const;
|
||||||
EOprtAssociativity GetOprtAssociativity(const token_type &a_Tok) const;
|
EOprtAssociativity GetOprtAssociativity(const token_type &a_Tok) const;
|
||||||
void CreateRPN() const;
|
void CreateRPN() const;
|
||||||
qreal ParseString() const;
|
qreal ParseString() const;
|
||||||
qreal ParseCmdCode() const;
|
qreal ParseCmdCode() const;
|
||||||
qreal ParseCmdCodeBulk(int nOffset, int nThreadID) const;
|
qreal ParseCmdCodeBulk(int nOffset, int nThreadID) const;
|
||||||
void CheckName(const QString &a_strName, const QString &a_CharSet) const;
|
void CheckName(const QString &a_strName, const QString &a_CharSet) const;
|
||||||
void CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback,
|
void CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback,
|
||||||
const QString &a_szCharSet) const;
|
const QString &a_szCharSet) const;
|
||||||
void StackDump(const QStack<token_type > &a_stVal, const QStack<token_type > &a_stOprt) const;
|
void StackDump(const QStack<token_type > &a_stVal, const QStack<token_type > &a_stOprt) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,35 +36,35 @@ namespace qmu
|
||||||
{
|
{
|
||||||
struct SToken
|
struct SToken
|
||||||
{
|
{
|
||||||
ECmdCode Cmd;
|
ECmdCode Cmd;
|
||||||
int StackPos;
|
int StackPos;
|
||||||
|
|
||||||
union
|
union //
|
||||||
{
|
{
|
||||||
struct //SValData
|
struct //SValData
|
||||||
{
|
{
|
||||||
qreal *ptr;
|
qreal *ptr;
|
||||||
qreal data;
|
qreal data;
|
||||||
qreal data2;
|
qreal data2;
|
||||||
} Val;
|
} Val;
|
||||||
|
|
||||||
struct //SFunData
|
struct //SFunData
|
||||||
{
|
{
|
||||||
// Note: generic_fun_type is merely a placeholder. The real type could be
|
// Note: generic_fun_type is merely a placeholder. The real type could be
|
||||||
// anything between gun_type1 and fun_type9. I can't use a void
|
// anything between gun_type1 and fun_type9. I can't use a void
|
||||||
// pointer due to constraints in the ANSI standard which allows
|
// pointer due to constraints in the ANSI standard which allows
|
||||||
// data pointers and function pointers to differ in size.
|
// data pointers and function pointers to differ in size.
|
||||||
generic_fun_type ptr;
|
generic_fun_type ptr;
|
||||||
int argc;
|
int argc;
|
||||||
int idx;
|
int idx;
|
||||||
} Fun;
|
} Fun;
|
||||||
|
|
||||||
struct //SOprtData
|
struct //SOprtData
|
||||||
{
|
{
|
||||||
qreal *ptr;
|
qreal *ptr;
|
||||||
int offset;
|
int offset;
|
||||||
} Oprt;
|
} Oprt;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,24 +103,22 @@ public:
|
||||||
QmuParserByteCode();
|
QmuParserByteCode();
|
||||||
QmuParserByteCode(const QmuParserByteCode &a_ByteCode);
|
QmuParserByteCode(const QmuParserByteCode &a_ByteCode);
|
||||||
QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode);
|
QmuParserByteCode& operator=(const QmuParserByteCode &a_ByteCode);
|
||||||
void Assign(const QmuParserByteCode &a_ByteCode);
|
void Assign(const QmuParserByteCode &a_ByteCode);
|
||||||
void AddVar(qreal *a_pVar);
|
void AddVar(qreal *a_pVar);
|
||||||
void AddVal(qreal a_fVal);
|
void AddVal(qreal a_fVal);
|
||||||
void AddOp(ECmdCode a_Oprt);
|
void AddOp(ECmdCode a_Oprt);
|
||||||
void AddIfElse(ECmdCode a_Oprt);
|
void AddIfElse(ECmdCode a_Oprt);
|
||||||
void AddAssignOp(qreal *a_pVar);
|
void AddAssignOp(qreal *a_pVar);
|
||||||
void AddFun(generic_fun_type a_pFun, int a_iArgc);
|
void AddFun(generic_fun_type a_pFun, int a_iArgc);
|
||||||
void AddBulkFun(generic_fun_type a_pFun, int a_iArgc);
|
void AddBulkFun(generic_fun_type a_pFun, int a_iArgc);
|
||||||
void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx);
|
void AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iIdx);
|
||||||
void EnableOptimizer(bool bStat);
|
void EnableOptimizer(bool bStat);
|
||||||
void Finalize();
|
void Finalize();
|
||||||
void clear();
|
void clear();
|
||||||
std::size_t GetMaxStackSize() const;
|
std::size_t GetMaxStackSize() const;
|
||||||
std::size_t GetSize() const;
|
std::size_t GetSize() const;
|
||||||
const SToken* GetBase() const;
|
const SToken* GetBase() const;
|
||||||
void AsciiDump();
|
void AsciiDump();
|
||||||
};
|
};
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,27 +29,27 @@
|
||||||
|
|
||||||
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__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type0 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode )
|
QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( a_iPrec ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( a_iCode ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( a_iCode ), 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
|
||||||
|
@ -58,11 +58,11 @@ QmuParserCallback::QmuParserCallback ( fun_type1 a_pFun, bool a_bAllowOpti, int
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
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
|
||||||
|
@ -75,104 +75,104 @@ QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti )
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec,
|
QmuParserCallback::QmuParserCallback ( fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec,
|
||||||
EOprtAssociativity a_eOprtAsct )
|
EOprtAssociativity a_eOprtAsct )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( a_iPrec ), m_eOprtAsct ( a_eOprtAsct ),
|
||||||
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmOPRT_BIN ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type3 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type4 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type5 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type6 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type7 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type8 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type9 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( fun_type10 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type0 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
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
|
||||||
|
@ -181,156 +181,156 @@ QmuParserCallback::QmuParserCallback ( bulkfun_type1 a_pFun, bool a_bAllowOpti )
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type2 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type3 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 3 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type4 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 4 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type5 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 5 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type6 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 6 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type7 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 7 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type8 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 8 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type9 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 9 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( bulkfun_type10 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 10 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_BULK ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( multfun_type a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( -1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC ), m_iType ( tpDBL ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( strfun_type1 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( strfun_type2 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 1 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__extension__
|
__extension__
|
||||||
#endif
|
#endif
|
||||||
QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
|
QmuParserCallback::QmuParserCallback ( strfun_type3 a_pFun, bool a_bAllowOpti )
|
||||||
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
: m_pFun ( reinterpret_cast<void*> ( a_pFun ) ), m_iArgc ( 2 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ),
|
||||||
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
m_iCode ( cmFUNC_STR ), m_iType ( tpSTR ), m_bAllowOpti ( a_bAllowOpti )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor.
|
* @brief Default constructor.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserCallback::QmuParserCallback()
|
QmuParserCallback::QmuParserCallback()
|
||||||
: m_pFun ( 0 ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ),
|
: m_pFun ( 0 ), m_iArgc ( 0 ), m_iPri ( -1 ), m_eOprtAsct ( oaNONE ), m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ),
|
||||||
m_bAllowOpti ( 0 )
|
m_bAllowOpti ( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Copy constructor.
|
* @brief Copy constructor.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref )
|
QmuParserCallback::QmuParserCallback ( const QmuParserCallback &ref )
|
||||||
: m_pFun ( ref.m_pFun ), m_iArgc ( ref.m_iArgc ), m_iPri ( ref.m_iPri ), m_eOprtAsct ( ref.m_eOprtAsct ),
|
: m_pFun ( ref.m_pFun ), m_iArgc ( ref.m_iArgc ), m_iPri ( ref.m_iPri ), m_eOprtAsct ( ref.m_eOprtAsct ),
|
||||||
m_iCode ( ref.m_iCode ), m_iType ( ref.m_iType ), m_bAllowOpti ( ref.m_bAllowOpti )
|
m_iCode ( ref.m_iCode ), m_iType ( ref.m_iType ), m_bAllowOpti ( ref.m_bAllowOpti )
|
||||||
{
|
{
|
||||||
m_pFun = ref.m_pFun;
|
m_pFun = ref.m_pFun;
|
||||||
m_iArgc = ref.m_iArgc;
|
m_iArgc = ref.m_iArgc;
|
||||||
m_bAllowOpti = ref.m_bAllowOpti;
|
m_bAllowOpti = ref.m_bAllowOpti;
|
||||||
m_iCode = ref.m_iCode;
|
m_iCode = ref.m_iCode;
|
||||||
m_iType = ref.m_iType;
|
m_iType = ref.m_iType;
|
||||||
m_iPri = ref.m_iPri;
|
m_iPri = ref.m_iPri;
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
QmuParserCallback* QmuParserCallback::Clone() const
|
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.
|
||||||
*
|
*
|
||||||
|
@ -339,10 +339,10 @@ QmuParserCallback* QmuParserCallback::Clone() const
|
||||||
*/
|
*/
|
||||||
bool QmuParserCallback::IsOptimizable() const
|
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.
|
||||||
*
|
*
|
||||||
|
@ -353,25 +353,25 @@ bool QmuParserCallback::IsOptimizable() const
|
||||||
*/
|
*/
|
||||||
void* QmuParserCallback::GetAddr() const
|
void* QmuParserCallback::GetAddr() const
|
||||||
{
|
{
|
||||||
return m_pFun;
|
return m_pFun;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the callback code.
|
* @brief Return the callback code.
|
||||||
*/
|
*/
|
||||||
ECmdCode QmuParserCallback::GetCode() const
|
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
|
||||||
|
@ -380,10 +380,10 @@ ETypeCode QmuParserCallback::GetType() const
|
||||||
*/
|
*/
|
||||||
int QmuParserCallback::GetPri() const
|
int QmuParserCallback::GetPri() const
|
||||||
{
|
{
|
||||||
return m_iPri;
|
return m_iPri;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the operators associativity.
|
* @brief Return the operators associativity.
|
||||||
* @throw nothrown
|
* @throw nothrown
|
||||||
|
@ -392,15 +392,15 @@ int QmuParserCallback::GetPri() const
|
||||||
*/
|
*/
|
||||||
EOprtAssociativity QmuParserCallback::GetAssociativity() const
|
EOprtAssociativity QmuParserCallback::GetAssociativity() const
|
||||||
{
|
{
|
||||||
return m_eOprtAsct;
|
return m_eOprtAsct;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Returns the number of function Arguments.
|
* @brief Returns the number of function Arguments.
|
||||||
*/
|
*/
|
||||||
int QmuParserCallback::GetArgc() const
|
int QmuParserCallback::GetArgc() const
|
||||||
{
|
{
|
||||||
return m_iArgc;
|
return m_iArgc;
|
||||||
}
|
}
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -79,22 +79,22 @@ public:
|
||||||
QmuParserCallback(const QmuParserCallback &a_Fun);
|
QmuParserCallback(const QmuParserCallback &a_Fun);
|
||||||
|
|
||||||
QmuParserCallback* Clone() const;
|
QmuParserCallback* Clone() const;
|
||||||
bool IsOptimizable() const;
|
bool IsOptimizable() const;
|
||||||
void* GetAddr() const;
|
void* GetAddr() const;
|
||||||
ECmdCode GetCode() const;
|
ECmdCode GetCode() const;
|
||||||
ETypeCode GetType() const;
|
ETypeCode GetType() const;
|
||||||
int GetPri() const;
|
int GetPri() const;
|
||||||
EOprtAssociativity GetAssociativity() const;
|
EOprtAssociativity GetAssociativity() const;
|
||||||
int GetArgc() const;
|
int GetArgc() const;
|
||||||
private:
|
private:
|
||||||
void *m_pFun; ///< Pointer to the callback function, casted to void
|
void *m_pFun; ///< Pointer to the callback function, casted to void
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Number of numeric function arguments
|
* @brief Number of numeric function arguments
|
||||||
*
|
*
|
||||||
* This number is negative for functions with variable number of arguments. in this cases
|
* This number is negative for functions with variable number of arguments. in this cases
|
||||||
* they represent the actual number of arguments found.
|
* they represent the actual number of arguments found.
|
||||||
*/
|
*/
|
||||||
int m_iArgc;
|
int m_iArgc;
|
||||||
int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
|
int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
|
||||||
EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
|
EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,11 @@
|
||||||
//#define QMUP_USE_OPENMP
|
//#define QMUP_USE_OPENMP
|
||||||
|
|
||||||
#if defined(_UNICODE)
|
#if defined(_UNICODE)
|
||||||
/** @brief Definition of the basic parser string type. */
|
/** @brief Definition of the basic parser string type. */
|
||||||
#define QMUP_STRING_TYPE std::wstring
|
#define QMUP_STRING_TYPE std::wstring
|
||||||
#else
|
#else
|
||||||
/** @brief Definition of the basic parser string type. */
|
/** @brief Definition of the basic parser string type. */
|
||||||
#define QMUP_STRING_TYPE std::string
|
#define QMUP_STRING_TYPE std::string
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace qmu
|
namespace qmu
|
||||||
|
@ -272,4 +272,3 @@ typedef qreal* ( *facfun_type ) ( const QString &, void* );
|
||||||
} // end of namespace
|
} // end of namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -28,116 +28,116 @@ 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 )
|
||||||
{
|
{
|
||||||
m_vErrMsg.resize ( ecCOUNT );
|
m_vErrMsg.resize ( ecCOUNT );
|
||||||
|
|
||||||
m_vErrMsg[ecUNASSIGNABLE_TOKEN] = "Unexpected token \"$TOK$\" found at position $POS$.";
|
m_vErrMsg[ecUNASSIGNABLE_TOKEN] = "Unexpected token \"$TOK$\" found at position $POS$.";
|
||||||
m_vErrMsg[ecINTERNAL_ERROR] = "Internal error";
|
m_vErrMsg[ecINTERNAL_ERROR] = "Internal error";
|
||||||
m_vErrMsg[ecINVALID_NAME] = "Invalid function-, variable- or constant name: \"$TOK$\".";
|
m_vErrMsg[ecINVALID_NAME] = "Invalid function-, variable- or constant name: \"$TOK$\".";
|
||||||
m_vErrMsg[ecINVALID_BINOP_IDENT] = "Invalid binary operator identifier: \"$TOK$\".";
|
m_vErrMsg[ecINVALID_BINOP_IDENT] = "Invalid binary operator identifier: \"$TOK$\".";
|
||||||
m_vErrMsg[ecINVALID_INFIX_IDENT] = "Invalid infix operator identifier: \"$TOK$\".";
|
m_vErrMsg[ecINVALID_INFIX_IDENT] = "Invalid infix operator identifier: \"$TOK$\".";
|
||||||
m_vErrMsg[ecINVALID_POSTFIX_IDENT] = "Invalid postfix operator identifier: \"$TOK$\".";
|
m_vErrMsg[ecINVALID_POSTFIX_IDENT] = "Invalid postfix operator identifier: \"$TOK$\".";
|
||||||
m_vErrMsg[ecINVALID_FUN_PTR] = "Invalid pointer to callback function.";
|
m_vErrMsg[ecINVALID_FUN_PTR] = "Invalid pointer to callback function.";
|
||||||
m_vErrMsg[ecEMPTY_EXPRESSION] = "Expression is empty.";
|
m_vErrMsg[ecEMPTY_EXPRESSION] = "Expression is empty.";
|
||||||
m_vErrMsg[ecINVALID_VAR_PTR] = "Invalid pointer to variable.";
|
m_vErrMsg[ecINVALID_VAR_PTR] = "Invalid pointer to variable.";
|
||||||
m_vErrMsg[ecUNEXPECTED_OPERATOR] = "Unexpected operator \"$TOK$\" found at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_OPERATOR] = "Unexpected operator \"$TOK$\" found at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_EOF] = "Unexpected end of expression at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_EOF] = "Unexpected end of expression at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_ARG_SEP] = "Unexpected argument separator at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_ARG_SEP] = "Unexpected argument separator at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_PARENS] = "Unexpected parenthesis \"$TOK$\" at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_PARENS] = "Unexpected parenthesis \"$TOK$\" at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_FUN] = "Unexpected function \"$TOK$\" at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_FUN] = "Unexpected function \"$TOK$\" at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_VAL] = "Unexpected value \"$TOK$\" found at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_VAL] = "Unexpected value \"$TOK$\" found at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_VAR] = "Unexpected variable \"$TOK$\" found at position $POS$";
|
m_vErrMsg[ecUNEXPECTED_VAR] = "Unexpected variable \"$TOK$\" found at position $POS$";
|
||||||
m_vErrMsg[ecUNEXPECTED_ARG] = "Function arguments used without a function (position: $POS$)";
|
m_vErrMsg[ecUNEXPECTED_ARG] = "Function arguments used without a function (position: $POS$)";
|
||||||
m_vErrMsg[ecMISSING_PARENS] = "Missing parenthesis";
|
m_vErrMsg[ecMISSING_PARENS] = "Missing parenthesis";
|
||||||
m_vErrMsg[ecTOO_MANY_PARAMS] = "Too many parameters for function \"$TOK$\" at expression position $POS$";
|
m_vErrMsg[ecTOO_MANY_PARAMS] = "Too many parameters for function \"$TOK$\" at expression position $POS$";
|
||||||
m_vErrMsg[ecTOO_FEW_PARAMS] = "Too few parameters for function \"$TOK$\" at expression position $POS$";
|
m_vErrMsg[ecTOO_FEW_PARAMS] = "Too few parameters for function \"$TOK$\" at expression position $POS$";
|
||||||
m_vErrMsg[ecDIV_BY_ZERO] = "Divide by zero";
|
m_vErrMsg[ecDIV_BY_ZERO] = "Divide by zero";
|
||||||
m_vErrMsg[ecDOMAIN_ERROR] = "Domain error";
|
m_vErrMsg[ecDOMAIN_ERROR] = "Domain error";
|
||||||
m_vErrMsg[ecNAME_CONFLICT] = "Name conflict";
|
m_vErrMsg[ecNAME_CONFLICT] = "Name conflict";
|
||||||
m_vErrMsg[ecOPT_PRI] = "Invalid value for operator priority (must be greater or equal to zero).";
|
m_vErrMsg[ecOPT_PRI] = "Invalid value for operator priority (must be greater or equal to zero).";
|
||||||
m_vErrMsg[ecBUILTIN_OVERLOAD] = "user defined binary operator \"$TOK$\" conflicts with a built in operator.";
|
m_vErrMsg[ecBUILTIN_OVERLOAD] = "user defined binary operator \"$TOK$\" conflicts with a built in operator.";
|
||||||
m_vErrMsg[ecUNEXPECTED_STR] = "Unexpected string token found at position $POS$.";
|
m_vErrMsg[ecUNEXPECTED_STR] = "Unexpected string token found at position $POS$.";
|
||||||
m_vErrMsg[ecUNTERMINATED_STRING] = "Unterminated string starting at position $POS$.";
|
m_vErrMsg[ecUNTERMINATED_STRING] = "Unterminated string starting at position $POS$.";
|
||||||
m_vErrMsg[ecSTRING_EXPECTED] = "String function called with a non string type of argument.";
|
m_vErrMsg[ecSTRING_EXPECTED] = "String function called with a non string type of argument.";
|
||||||
m_vErrMsg[ecVAL_EXPECTED] = "String value used where a numerical argument is expected.";
|
m_vErrMsg[ecVAL_EXPECTED] = "String value used where a numerical argument is expected.";
|
||||||
m_vErrMsg[ecOPRT_TYPE_CONFLICT] = "No suitable overload for operator \"$TOK$\" at position $POS$.";
|
m_vErrMsg[ecOPRT_TYPE_CONFLICT] = "No suitable overload for operator \"$TOK$\" at position $POS$.";
|
||||||
m_vErrMsg[ecSTR_RESULT] = "Function result is a string.";
|
m_vErrMsg[ecSTR_RESULT] = "Function result is a string.";
|
||||||
m_vErrMsg[ecGENERIC] = "Parser error.";
|
m_vErrMsg[ecGENERIC] = "Parser error.";
|
||||||
m_vErrMsg[ecLOCALE] = "Decimal separator is identic to function argument separator.";
|
m_vErrMsg[ecLOCALE] = "Decimal separator is identic to function argument separator.";
|
||||||
m_vErrMsg[ecUNEXPECTED_CONDITIONAL] = "The \"$TOK$\" operator must be preceeded by a closing bracket.";
|
m_vErrMsg[ecUNEXPECTED_CONDITIONAL] = "The \"$TOK$\" operator must be preceeded by a closing bracket.";
|
||||||
m_vErrMsg[ecMISSING_ELSE_CLAUSE] = "If-then-else operator is missing an else clause";
|
m_vErrMsg[ecMISSING_ELSE_CLAUSE] = "If-then-else operator is missing an else clause";
|
||||||
m_vErrMsg[ecMISPLACED_COLON] = "Misplaced colon at position $POS$";
|
m_vErrMsg[ecMISPLACED_COLON] = "Misplaced colon at position $POS$";
|
||||||
|
|
||||||
#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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// QParserError class
|
// QParserError class
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor.
|
* @brief Default constructor.
|
||||||
*/
|
*/
|
||||||
QmuParserError::QmuParserError()
|
QmuParserError::QmuParserError()
|
||||||
: m_strMsg(), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
|
: m_strMsg(), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
|
||||||
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief This Constructor is used for internal exceptions only.
|
* @brief This Constructor is used for internal exceptions only.
|
||||||
*
|
*
|
||||||
* It does not contain any information but the error code.
|
* It does not contain any information but the error code.
|
||||||
*/
|
*/
|
||||||
QmuParserError::QmuParserError ( EErrorCodes a_iErrc )
|
QmuParserError::QmuParserError ( EErrorCodes a_iErrc )
|
||||||
: m_strMsg(), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( a_iErrc ),
|
: m_strMsg(), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( a_iErrc ),
|
||||||
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
m_strMsg = m_ErrMsg[m_iErrc];
|
m_strMsg = m_ErrMsg[m_iErrc];
|
||||||
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
QmuParserError::QmuParserError ( const QString &sMsg )
|
QmuParserError::QmuParserError ( const QString &sMsg )
|
||||||
: m_strMsg(sMsg), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
|
: m_strMsg(sMsg), m_strFormula(), m_strTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ),
|
||||||
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.
|
||||||
|
@ -149,15 +149,15 @@ QmuParserError::QmuParserError ( EErrorCodes iErrc,
|
||||||
const QString &sTok,
|
const QString &sTok,
|
||||||
const QString &sExpr,
|
const QString &sExpr,
|
||||||
int iPos )
|
int iPos )
|
||||||
: m_strMsg(), m_strFormula ( sExpr ), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ),
|
: m_strMsg(), m_strFormula ( sExpr ), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ),
|
||||||
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
m_strMsg = m_ErrMsg[m_iErrc];
|
m_strMsg = m_ErrMsg[m_iErrc];
|
||||||
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
||||||
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.
|
||||||
|
@ -165,58 +165,58 @@ QmuParserError::QmuParserError ( EErrorCodes iErrc,
|
||||||
* @param [in] sTok The token string related to this error.
|
* @param [in] sTok The token string related to this error.
|
||||||
*/
|
*/
|
||||||
QmuParserError::QmuParserError ( EErrorCodes iErrc, int iPos, const QString &sTok )
|
QmuParserError::QmuParserError ( EErrorCodes iErrc, int iPos, const QString &sTok )
|
||||||
: m_strMsg(), m_strFormula(), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ),
|
: m_strMsg(), m_strFormula(), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ),
|
||||||
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
m_strMsg = m_ErrMsg[m_iErrc];
|
m_strMsg = m_ErrMsg[m_iErrc];
|
||||||
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
||||||
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.
|
||||||
* @param [in] sTok The token string related to this error.
|
* @param [in] sTok The token string related to this error.
|
||||||
*/
|
*/
|
||||||
QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &sTok )
|
QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &sTok )
|
||||||
: m_strMsg ( szMsg ), m_strFormula(), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( ecGENERIC ),
|
: m_strMsg ( szMsg ), m_strFormula(), m_strTok ( sTok ), m_iPos ( iPos ), m_iErrc ( ecGENERIC ),
|
||||||
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
ReplaceSubString ( m_strMsg, "$POS$", QString().setNum ( m_iPos ) );
|
||||||
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 ),
|
||||||
m_iPos ( a_Obj.m_iPos ), m_iErrc ( a_Obj.m_iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
m_iPos ( a_Obj.m_iPos ), m_iErrc ( a_Obj.m_iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/** @brief Assignment operator. */
|
/** @brief Assignment operator. */
|
||||||
QmuParserError& QmuParserError::operator= ( const QmuParserError &a_Obj )
|
QmuParserError& QmuParserError::operator= ( const QmuParserError &a_Obj )
|
||||||
{
|
{
|
||||||
if ( this == &a_Obj )
|
if ( this == &a_Obj )
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_strMsg = a_Obj.m_strMsg;
|
m_strMsg = a_Obj.m_strMsg;
|
||||||
m_strFormula = a_Obj.m_strFormula;
|
m_strFormula = a_Obj.m_strFormula;
|
||||||
m_strTok = a_Obj.m_strTok;
|
m_strTok = a_Obj.m_strTok;
|
||||||
m_iPos = a_Obj.m_iPos;
|
m_iPos = a_Obj.m_iPos;
|
||||||
m_iErrc = a_Obj.m_iErrc;
|
m_iErrc = a_Obj.m_iErrc;
|
||||||
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.
|
||||||
|
@ -224,65 +224,67 @@ QmuParserError::~QmuParserError()
|
||||||
*/
|
*/
|
||||||
void QmuParserError::ReplaceSubString ( QString &strSource, const QString &strFind, const QString &strReplaceWith )
|
void QmuParserError::ReplaceSubString ( QString &strSource, const QString &strFind, const QString &strReplaceWith )
|
||||||
{
|
{
|
||||||
QString strResult;
|
QString strResult;
|
||||||
int iPos ( 0 ), iNext ( 0 );
|
int iPos ( 0 ), iNext ( 0 );
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
iNext = strSource.indexOf ( strFind, iPos );
|
iNext = strSource.indexOf ( strFind, iPos );
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
strSource.swap ( strResult );
|
strSource.swap ( strResult );
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Reset the erro object.
|
* @brief Reset the erro object.
|
||||||
*/
|
*/
|
||||||
void QmuParserError::Reset()
|
void QmuParserError::Reset()
|
||||||
{
|
{
|
||||||
m_strMsg.clear();
|
m_strMsg.clear();
|
||||||
m_strFormula.clear();
|
m_strFormula.clear();
|
||||||
m_strTok.clear();
|
m_strTok.clear();
|
||||||
m_iPos = -1;
|
m_iPos = -1;
|
||||||
m_iErrc = ecUNDEFINED;
|
m_iErrc = ecUNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Set the expression related to this error.
|
* @brief Set the expression related to this error.
|
||||||
*/
|
*/
|
||||||
void QmuParserError::SetFormula ( const QString &a_strFormula )
|
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.
|
||||||
*/
|
*/
|
||||||
const QString& QmuParserError::GetExpr() const
|
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.
|
||||||
*/
|
*/
|
||||||
const QString& QmuParserError::GetMsg() const
|
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.
|
||||||
*
|
*
|
||||||
|
@ -290,24 +292,24 @@ const QString& QmuParserError::GetMsg() const
|
||||||
*/
|
*/
|
||||||
std::size_t QmuParserError::GetPos() const
|
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).
|
||||||
*/
|
*/
|
||||||
const QString& QmuParserError::GetToken() const
|
const QString& QmuParserError::GetToken() const
|
||||||
{
|
{
|
||||||
return m_strTok;
|
return m_strTok;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the error code.
|
* @brief Return the error code.
|
||||||
*/
|
*/
|
||||||
EErrorCodes QmuParserError::GetCode() const
|
EErrorCodes QmuParserError::GetCode() const
|
||||||
{
|
{
|
||||||
return m_iErrc;
|
return m_iErrc;
|
||||||
}
|
}
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -97,18 +97,18 @@ enum EErrorCodes
|
||||||
class QmuParserErrorMsg
|
class QmuParserErrorMsg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QmuParserErrorMsg self_type;
|
typedef QmuParserErrorMsg self_type;
|
||||||
|
|
||||||
QmuParserErrorMsg();
|
QmuParserErrorMsg();
|
||||||
~QmuParserErrorMsg();
|
~QmuParserErrorMsg();
|
||||||
|
|
||||||
static const QmuParserErrorMsg& Instance();
|
static const QmuParserErrorMsg& Instance();
|
||||||
QString operator[] ( unsigned a_iIdx ) const;
|
QString operator[] ( unsigned a_iIdx ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QmuParserErrorMsg)
|
Q_DISABLE_COPY(QmuParserErrorMsg)
|
||||||
QVector<QString> m_vErrMsg; ///< A vector with the predefined error messages
|
QVector<QString> m_vErrMsg; ///< A vector with the predefined error messages
|
||||||
static const self_type m_Instance; ///< The instance pointer
|
static const self_type m_Instance; ///< The instance pointer
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -121,38 +121,37 @@ class QmuParserError
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QmuParserError();
|
QmuParserError();
|
||||||
explicit QmuParserError ( EErrorCodes a_iErrc );
|
explicit QmuParserError ( EErrorCodes a_iErrc );
|
||||||
explicit QmuParserError ( const QString &sMsg );
|
explicit QmuParserError ( const QString &sMsg );
|
||||||
QmuParserError ( EErrorCodes a_iErrc, const QString &sTok, const QString &sFormula = QString(), int a_iPos = -1 );
|
QmuParserError ( EErrorCodes a_iErrc, const QString &sTok, const QString &sFormula = QString(), int a_iPos = -1 );
|
||||||
QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok );
|
QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok );
|
||||||
QmuParserError ( const QString &a_szMsg, int a_iPos, const QString &sTok = QString() );
|
QmuParserError ( const QString &a_szMsg, int a_iPos, const QString &sTok = QString() );
|
||||||
QmuParserError ( const QmuParserError &a_Obj );
|
QmuParserError ( const QmuParserError &a_Obj );
|
||||||
QmuParserError& operator= ( const QmuParserError &a_Obj );
|
QmuParserError& operator= ( const QmuParserError &a_Obj );
|
||||||
~QmuParserError();
|
~QmuParserError();
|
||||||
|
|
||||||
void SetFormula ( const QString &a_strFormula );
|
void SetFormula ( const QString &a_strFormula );
|
||||||
const QString& GetExpr() const;
|
const QString& GetExpr() const;
|
||||||
const QString& GetMsg() const;
|
const QString& GetMsg() const;
|
||||||
std::size_t GetPos() const;
|
std::size_t GetPos() const;
|
||||||
const QString& GetToken() const;
|
const QString& GetToken() const;
|
||||||
EErrorCodes GetCode() const;
|
EErrorCodes GetCode() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_strMsg; ///< The message string
|
QString m_strMsg; ///< The message string
|
||||||
QString m_strFormula; ///< Formula string
|
QString m_strFormula; ///< Formula string
|
||||||
QString m_strTok; ///< Token related with the error
|
QString m_strTok; ///< Token related with the error
|
||||||
int m_iPos; ///< Formula position related to the error
|
int m_iPos; ///< Formula position related to the error
|
||||||
EErrorCodes m_iErrc; ///< Error code
|
EErrorCodes m_iErrc; ///< Error code
|
||||||
const QmuParserErrorMsg &m_ErrMsg;
|
const QmuParserErrorMsg &m_ErrMsg;
|
||||||
/**
|
/**
|
||||||
* @brief Replace all ocuurences of a substring with another string.
|
* @brief Replace all ocuurences of a substring with another string.
|
||||||
*/
|
*/
|
||||||
void ReplaceSubString ( QString &strSource, const QString &strFind, const QString &strReplaceWith );
|
void ReplaceSubString ( QString &strSource, const QString &strFind, const QString &strReplaceWith );
|
||||||
void Reset();
|
void Reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,3 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,7 +41,7 @@ namespace qmu
|
||||||
*/
|
*/
|
||||||
namespace Test
|
namespace Test
|
||||||
{
|
{
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Test cases for unit testing.
|
* @brief Test cases for unit testing.
|
||||||
*
|
*
|
||||||
|
@ -50,253 +50,251 @@ namespace Test
|
||||||
class QmuParserTester // final
|
class QmuParserTester // final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef int ( QmuParserTester::*testfun_type ) ();
|
typedef int ( QmuParserTester::*testfun_type ) ();
|
||||||
|
|
||||||
QmuParserTester();
|
QmuParserTester();
|
||||||
void Run();
|
void Run();
|
||||||
private:
|
private:
|
||||||
QVector<testfun_type> m_vTestFun;
|
QVector<testfun_type> m_vTestFun;
|
||||||
static int c_iCount;
|
static int c_iCount;
|
||||||
|
|
||||||
void AddTest ( testfun_type a_pFun );
|
void AddTest ( testfun_type a_pFun );
|
||||||
|
|
||||||
// Test Double Parser
|
// Test Double Parser
|
||||||
int EqnTest ( const QString &a_str, double a_fRes, bool a_fPass );
|
int EqnTest ( const QString &a_str, double a_fRes, bool a_fPass );
|
||||||
int EqnTestWithVarChange ( const QString &a_str, double a_fRes1, double a_fVar1, double a_fRes2, double a_fVar2 );
|
int EqnTestWithVarChange ( const QString &a_str, double a_fRes1, double a_fVar1, double a_fRes2, double a_fVar2 );
|
||||||
int ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail = true );
|
int ThrowTest ( const QString &a_str, int a_iErrc, bool a_bFail = true );
|
||||||
|
|
||||||
// Multiarg callbacks
|
// Multiarg callbacks
|
||||||
static qreal f1of1 ( qreal v )
|
static qreal f1of1 ( qreal v )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f1of2 ( qreal v, qreal )
|
static qreal f1of2 ( qreal v, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f2of2 ( qreal , qreal v )
|
static qreal f2of2 ( qreal, qreal v )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f1of3 ( qreal v, qreal , qreal )
|
static qreal f1of3 ( qreal v, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f2of3 ( qreal , qreal v, qreal )
|
static qreal f2of3 ( qreal, qreal v, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f3of3 ( qreal , qreal , qreal v )
|
static qreal f3of3 ( qreal, qreal, qreal v )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f1of4 ( qreal v, qreal, qreal , qreal )
|
static qreal f1of4 ( qreal v, qreal, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f2of4 ( qreal , qreal v, qreal , qreal )
|
static qreal f2of4 ( qreal, qreal v, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f3of4 ( qreal , qreal, qreal v, qreal )
|
static qreal f3of4 ( qreal, qreal, qreal v, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f4of4 ( qreal , qreal, qreal , qreal v )
|
static qreal f4of4 ( qreal, qreal, qreal, qreal v )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f1of5 ( qreal v, qreal, qreal , qreal , qreal )
|
static qreal f1of5 ( qreal v, qreal, qreal, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f2of5 ( qreal , qreal v, qreal , qreal , qreal )
|
static qreal f2of5 ( qreal, qreal v, qreal, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f3of5 ( qreal , qreal, qreal v, qreal , qreal )
|
static qreal f3of5 ( qreal, qreal, qreal v, qreal, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f4of5 ( qreal , qreal, qreal , qreal v, qreal )
|
static qreal f4of5 ( qreal, qreal, qreal, qreal v, qreal )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal f5of5 ( qreal , qreal, qreal , qreal , qreal v )
|
static qreal f5of5 ( qreal, qreal, qreal, qreal, qreal v )
|
||||||
{
|
{
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Min ( qreal a_fVal1, qreal a_fVal2 )
|
static qreal Min ( qreal a_fVal1, qreal a_fVal2 )
|
||||||
{
|
{
|
||||||
return ( a_fVal1 < a_fVal2 ) ? a_fVal1 : a_fVal2;
|
return ( a_fVal1 < a_fVal2 ) ? a_fVal1 : a_fVal2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Max ( qreal a_fVal1, qreal a_fVal2 )
|
static qreal Max ( qreal a_fVal1, qreal a_fVal2 )
|
||||||
{
|
{
|
||||||
return ( a_fVal1 > a_fVal2 ) ? a_fVal1 : a_fVal2;
|
return ( a_fVal1 > a_fVal2 ) ? a_fVal1 : a_fVal2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal plus2 ( qreal v1 )
|
static qreal plus2 ( qreal v1 )
|
||||||
{
|
{
|
||||||
return v1 + 2;
|
return v1 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal times3 ( qreal v1 )
|
static qreal times3 ( qreal v1 )
|
||||||
{
|
{
|
||||||
return v1 * 3;
|
return v1 * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal sqr ( qreal v1 )
|
static qreal sqr ( qreal v1 )
|
||||||
{
|
{
|
||||||
return v1 * v1;
|
return v1 * v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal sign ( qreal v )
|
static qreal sign ( qreal v )
|
||||||
{
|
{
|
||||||
return -v;
|
return -v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal add ( qreal v1, qreal v2 )
|
static qreal add ( qreal v1, qreal v2 )
|
||||||
{
|
{
|
||||||
return v1 + v2;
|
return v1 + v2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal land ( qreal v1, qreal v2 )
|
static qreal land ( qreal v1, qreal v2 )
|
||||||
{
|
{
|
||||||
return static_cast<int>( v1 ) & static_cast<int>( v2 );
|
return static_cast<int>( v1 ) & static_cast<int>( v2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
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." );
|
||||||
}
|
}
|
||||||
|
|
||||||
return a_afArg[0];
|
return a_afArg[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
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." );
|
||||||
}
|
}
|
||||||
|
|
||||||
return a_afArg[a_iArgc - 1];
|
return a_afArg[a_iArgc - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
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." );
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal fRes = 0;
|
qreal fRes = 0;
|
||||||
for ( int i = 0; i < a_iArgc; ++i )
|
for ( int i = 0; i < a_iArgc; ++i )
|
||||||
{
|
{
|
||||||
fRes += a_afArg[i];
|
fRes += a_afArg[i];
|
||||||
}
|
}
|
||||||
return fRes;
|
return fRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Rnd ( qreal v )
|
static qreal Rnd ( qreal v )
|
||||||
{
|
{
|
||||||
return static_cast<qreal>( ( 1 + ( v * qrand() / ( RAND_MAX + 1.0 ) ) ) );
|
return static_cast<qreal>( ( 1 + ( v * qrand() / ( RAND_MAX + 1.0 ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal RndWithString ( const char_type* )
|
static qreal RndWithString ( const char_type* )
|
||||||
{
|
{
|
||||||
return static_cast<qreal>( ( 1 + ( 1000.0f * static_cast<qreal>(qrand()) / ( RAND_MAX + 1.0 ) ) ) );
|
return static_cast<qreal>( ( 1 + ( 1000.0f * static_cast<qreal>(qrand()) / ( RAND_MAX + 1.0 ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Ping()
|
static qreal Ping()
|
||||||
{
|
{
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal ValueOf ( const QString & )
|
static qreal ValueOf ( const QString & )
|
||||||
{
|
{
|
||||||
return 123;
|
return 123;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal StrFun1 ( const QString & v1 )
|
static qreal StrFun1 ( const QString & v1 )
|
||||||
{
|
{
|
||||||
int val = v1.toInt();
|
int val = v1.toInt();
|
||||||
return static_cast<qreal>(val);
|
return static_cast<qreal>(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal StrFun2 ( const QString & v1, qreal v2 )
|
static qreal StrFun2 ( const QString & v1, qreal v2 )
|
||||||
{
|
{
|
||||||
int val = v1.toInt();
|
int val = v1.toInt();
|
||||||
return static_cast<qreal>( val + v2 );
|
return static_cast<qreal>( val + v2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal StrFun3 ( const QString & v1, qreal v2, qreal v3 )
|
static qreal StrFun3 ( const QString & v1, qreal v2, qreal v3 )
|
||||||
{
|
{
|
||||||
int val = v1.toInt();
|
int val = v1.toInt();
|
||||||
return val + v2 + v3;
|
return val + v2 + v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal StrToFloat ( const QString & a_szMsg )
|
static qreal StrToFloat ( const QString & a_szMsg )
|
||||||
{
|
{
|
||||||
qreal val = a_szMsg.toDouble();
|
qreal val = a_szMsg.toDouble();
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// postfix operator callback
|
// postfix operator callback
|
||||||
static qreal Mega ( qreal a_fVal )
|
static qreal Mega ( qreal a_fVal )
|
||||||
{
|
{
|
||||||
return a_fVal * static_cast<qreal>( 1e6 );
|
return a_fVal * static_cast<qreal>( 1e6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Micro ( qreal a_fVal )
|
static qreal Micro ( qreal a_fVal )
|
||||||
{
|
{
|
||||||
return a_fVal * static_cast<qreal>( 1e-6 );
|
return a_fVal * static_cast<qreal>( 1e-6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal Milli ( qreal a_fVal )
|
static qreal Milli ( qreal a_fVal )
|
||||||
{
|
{
|
||||||
return a_fVal / static_cast<qreal>( 1e3 );
|
return a_fVal / static_cast<qreal>( 1e3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom value recognition
|
// Custom value recognition
|
||||||
static int IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal );
|
static int IsHexVal ( const QString &a_szExpr, int *a_iPos, qreal *a_fVal );
|
||||||
|
|
||||||
int TestNames();
|
int TestNames();
|
||||||
int TestSyntax();
|
int TestSyntax();
|
||||||
int TestMultiArg();
|
int TestMultiArg();
|
||||||
int TestPostFix();
|
int TestPostFix();
|
||||||
int TestExpression();
|
int TestExpression();
|
||||||
int TestInfixOprt();
|
int TestInfixOprt();
|
||||||
int TestBinOprt();
|
int TestBinOprt();
|
||||||
int TestVarConst();
|
int TestVarConst();
|
||||||
int TestInterface();
|
int TestInterface();
|
||||||
int TestException();
|
int TestException();
|
||||||
int TestStrArg();
|
int TestStrArg();
|
||||||
int TestIfThenElse();
|
int TestIfThenElse();
|
||||||
|
|
||||||
void Abort() const;
|
void Abort() const;
|
||||||
};
|
};
|
||||||
} // namespace Test
|
} // namespace Test
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace qmu
|
||||||
* <li>functions with a string as argument</li>
|
* <li>functions with a string as argument</li>
|
||||||
* <li>prefix operators</li>
|
* <li>prefix operators</li>
|
||||||
* <li>infix operators</li>
|
* <li>infix operators</li>
|
||||||
* <li>binary operator</li>
|
* <li>binary operator</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author (C) 2004-2013 Ingo Berg
|
* @author (C) 2004-2013 Ingo Berg
|
||||||
|
@ -59,458 +59,470 @@ template<typename TBase, typename TString>
|
||||||
class QmuParserToken
|
class QmuParserToken
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Constructor (default).
|
* @brief Constructor (default).
|
||||||
*
|
*
|
||||||
* Sets token to an neutral state of type cmUNKNOWN.
|
* Sets token to an neutral state of type cmUNKNOWN.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
* @sa ECmdCode
|
* @sa ECmdCode
|
||||||
*/
|
*/
|
||||||
QmuParserToken()
|
QmuParserToken()
|
||||||
: m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( 0 ), m_iIdx ( -1 ), m_strTok(), m_strVal(), m_fVal(),
|
: m_iCode ( cmUNKNOWN ), m_iType ( tpVOID ), m_pTok ( 0 ), m_iIdx ( -1 ), m_strTok(), m_strVal(), m_fVal(),
|
||||||
m_pCallback()
|
m_pCallback()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Create token from another one.
|
* @brief Create token from another one.
|
||||||
*
|
*
|
||||||
* Implemented by calling Assign(...)
|
* Implemented by calling Assign(...)
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
* @post m_iType==cmUNKNOWN
|
* @post m_iType==cmUNKNOWN
|
||||||
* @sa #Assign
|
* @sa #Assign
|
||||||
*/
|
*/
|
||||||
QmuParserToken ( const QmuParserToken &a_Tok )
|
QmuParserToken ( const QmuParserToken &a_Tok )
|
||||||
: m_iCode ( a_Tok.m_iCode ), m_iType ( a_Tok.m_iType ), m_pTok ( a_Tok.m_pTok ), m_iIdx ( a_Tok.m_iIdx ),
|
: m_iCode ( a_Tok.m_iCode ), m_iType ( a_Tok.m_iType ), m_pTok ( a_Tok.m_pTok ), m_iIdx ( a_Tok.m_iIdx ),
|
||||||
m_strTok( a_Tok.m_strTok ), m_strVal(a_Tok.m_strVal), m_fVal(a_Tok.m_fVal), m_pCallback()
|
m_strTok( a_Tok.m_strTok ), m_strVal(a_Tok.m_strVal), m_fVal(a_Tok.m_fVal), m_pCallback()
|
||||||
{
|
{
|
||||||
Assign ( a_Tok );
|
Assign ( a_Tok );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Assignement operator.
|
* @brief Assignement operator.
|
||||||
*
|
*
|
||||||
* Copy token state from another token and return this.
|
* Copy token state from another token and return this.
|
||||||
* Implemented by calling Assign(...).
|
* Implemented by calling Assign(...).
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserToken& operator= ( const QmuParserToken &a_Tok )
|
QmuParserToken& operator= ( const QmuParserToken &a_Tok )
|
||||||
{
|
{
|
||||||
Assign ( a_Tok );
|
Assign ( a_Tok );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Copy token information from argument.
|
* @brief Copy token information from argument.
|
||||||
*
|
*
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
void Assign ( const QmuParserToken &a_Tok )
|
void Assign ( const QmuParserToken &a_Tok )
|
||||||
{
|
{
|
||||||
m_iCode = a_Tok.m_iCode;
|
m_iCode = a_Tok.m_iCode;
|
||||||
m_pTok = a_Tok.m_pTok;
|
m_pTok = a_Tok.m_pTok;
|
||||||
m_strTok = a_Tok.m_strTok;
|
m_strTok = a_Tok.m_strTok;
|
||||||
m_iIdx = a_Tok.m_iIdx;
|
m_iIdx = a_Tok.m_iIdx;
|
||||||
m_strVal = a_Tok.m_strVal;
|
m_strVal = a_Tok.m_strVal;
|
||||||
m_iType = a_Tok.m_iType;
|
m_iType = a_Tok.m_iType;
|
||||||
m_fVal = a_Tok.m_fVal;
|
m_fVal = a_Tok.m_fVal;
|
||||||
// create new callback object if a_Tok has one
|
// create new callback object if a_Tok has one
|
||||||
m_pCallback.reset ( a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0 );
|
m_pCallback.reset ( a_Tok.m_pCallback.get() ? a_Tok.m_pCallback->Clone() : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Assign a token type.
|
* @brief Assign a token type.
|
||||||
*
|
*
|
||||||
* Token may not be of type value, variable or function. Those have seperate set functions.
|
* Token may not be of type value, variable or function. Those have seperate set functions.
|
||||||
*
|
*
|
||||||
* @pre [assert] a_iType!=cmVAR
|
* @pre [assert] a_iType!=cmVAR
|
||||||
* @pre [assert] a_iType!=cmVAL
|
* @pre [assert] a_iType!=cmVAL
|
||||||
* @pre [assert] a_iType!=cmFUNC
|
* @pre [assert] a_iType!=cmFUNC
|
||||||
* @post m_fVal = 0
|
* @post m_fVal = 0
|
||||||
* @post m_pTok = 0
|
* @post m_pTok = 0
|
||||||
*/
|
*/
|
||||||
QmuParserToken& Set ( ECmdCode a_iType, const TString &a_strTok = TString() )
|
QmuParserToken& Set ( ECmdCode a_iType, const TString &a_strTok = TString() )
|
||||||
{
|
{
|
||||||
// The following types cant be set this way, they have special Set functions
|
// The following types cant be set this way, they have special Set functions
|
||||||
assert ( a_iType != cmVAR );
|
assert ( a_iType != cmVAR );
|
||||||
assert ( a_iType != cmVAL );
|
assert ( a_iType != cmVAL );
|
||||||
assert ( a_iType != cmFUNC );
|
assert ( a_iType != cmFUNC );
|
||||||
|
|
||||||
m_iCode = a_iType;
|
m_iCode = a_iType;
|
||||||
m_iType = tpVOID;
|
m_iType = tpVOID;
|
||||||
m_pTok = 0;
|
m_pTok = 0;
|
||||||
m_strTok = a_strTok;
|
m_strTok = a_strTok;
|
||||||
m_iIdx = -1;
|
m_iIdx = -1;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Set Callback type.
|
* @brief Set Callback type.
|
||||||
*/
|
*/
|
||||||
QmuParserToken& Set ( const QmuParserCallback &a_pCallback, const TString &a_sTok )
|
QmuParserToken& Set ( const QmuParserCallback &a_pCallback, const TString &a_sTok )
|
||||||
{
|
{
|
||||||
assert ( a_pCallback.GetAddr() );
|
assert ( a_pCallback.GetAddr() );
|
||||||
|
|
||||||
m_iCode = a_pCallback.GetCode();
|
m_iCode = a_pCallback.GetCode();
|
||||||
m_iType = tpVOID;
|
m_iType = tpVOID;
|
||||||
m_strTok = a_sTok;
|
m_strTok = a_sTok;
|
||||||
m_pCallback.reset ( new QmuParserCallback ( a_pCallback ) );
|
m_pCallback.reset ( new QmuParserCallback ( a_pCallback ) );
|
||||||
|
|
||||||
m_pTok = 0;
|
m_pTok = 0;
|
||||||
m_iIdx = -1;
|
m_iIdx = -1;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Make this token a value token.
|
* @brief Make this token a value token.
|
||||||
*
|
*
|
||||||
* Member variables not necessary for value tokens will be invalidated.
|
* Member variables not necessary for value tokens will be invalidated.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserToken& SetVal ( TBase a_fVal, const TString &a_strTok = TString() )
|
QmuParserToken& SetVal ( TBase a_fVal, const TString &a_strTok = TString() )
|
||||||
{
|
{
|
||||||
m_iCode = cmVAL;
|
m_iCode = cmVAL;
|
||||||
m_iType = tpDBL;
|
m_iType = tpDBL;
|
||||||
m_fVal = a_fVal;
|
m_fVal = a_fVal;
|
||||||
m_strTok = a_strTok;
|
m_strTok = a_strTok;
|
||||||
m_iIdx = -1;
|
m_iIdx = -1;
|
||||||
|
|
||||||
m_pTok = 0;
|
m_pTok = 0;
|
||||||
m_pCallback.reset ( 0 );
|
m_pCallback.reset ( 0 );
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief make this token a variable token.
|
* @brief make this token a variable token.
|
||||||
*
|
*
|
||||||
* Member variables not necessary for variable tokens will be invalidated.
|
* Member variables not necessary for variable tokens will be invalidated.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserToken& SetVar ( TBase *a_pVar, const TString &a_strTok )
|
QmuParserToken& SetVar ( TBase *a_pVar, const TString &a_strTok )
|
||||||
{
|
{
|
||||||
m_iCode = cmVAR;
|
m_iCode = cmVAR;
|
||||||
m_iType = tpDBL;
|
m_iType = tpDBL;
|
||||||
m_strTok = a_strTok;
|
m_strTok = a_strTok;
|
||||||
m_iIdx = -1;
|
m_iIdx = -1;
|
||||||
m_pTok = reinterpret_cast<void*> ( a_pVar );
|
m_pTok = reinterpret_cast<void*> ( a_pVar );
|
||||||
m_pCallback.reset ( 0 );
|
m_pCallback.reset ( 0 );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Make this token a variable token.
|
* @brief Make this token a variable token.
|
||||||
*
|
*
|
||||||
* Member variables not necessary for variable tokens will be invalidated.
|
* Member variables not necessary for variable tokens will be invalidated.
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
QmuParserToken& SetString ( const TString &a_strTok, std::size_t a_iSize )
|
QmuParserToken& SetString ( const TString &a_strTok, std::size_t a_iSize )
|
||||||
{
|
{
|
||||||
m_iCode = cmSTRING;
|
m_iCode = cmSTRING;
|
||||||
m_iType = tpSTR;
|
m_iType = tpSTR;
|
||||||
m_strTok = a_strTok;
|
m_strTok = a_strTok;
|
||||||
m_iIdx = static_cast<int> ( a_iSize );
|
m_iIdx = static_cast<int> ( a_iSize );
|
||||||
|
|
||||||
m_pTok = 0;
|
m_pTok = 0;
|
||||||
m_pCallback.reset ( 0 );
|
m_pCallback.reset ( 0 );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Set an index associated with the token related data.
|
* @brief Set an index associated with the token related data.
|
||||||
*
|
*
|
||||||
* In cmSTRFUNC - This is the index to a string table in the main parser.
|
* In cmSTRFUNC - This is the index to a string table in the main parser.
|
||||||
* @param a_iIdx The index the string function result will take in the bytecode parser.
|
* @param a_iIdx The index the string function result will take in the bytecode parser.
|
||||||
* @throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING
|
* @throw exception_type if #a_iIdx<0 or #m_iType!=cmSTRING
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return Index associated with the token related data.
|
* @brief Return Index associated with the token related data.
|
||||||
*
|
*
|
||||||
* In cmSTRFUNC - This is the index to a string table in the main parser.
|
* In cmSTRFUNC - This is the index to a string table in the main parser.
|
||||||
*
|
*
|
||||||
* @throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING
|
* @throw exception_type if #m_iIdx<0 or #m_iType!=cmSTRING
|
||||||
* @return The index the result will take in the Bytecode calculatin array (#m_iIdx).
|
* @return The index the result will take in the Bytecode calculatin array (#m_iIdx).
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the token type.
|
* @brief Return the token type.
|
||||||
*
|
*
|
||||||
* @return #m_iType
|
* @return #m_iType
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
*/
|
*/
|
||||||
ECmdCode GetCode() const
|
ECmdCode GetCode() const
|
||||||
{
|
{
|
||||||
if ( m_pCallback.get() )
|
if ( m_pCallback.get() )
|
||||||
{
|
{
|
||||||
return m_pCallback->GetCode();
|
return m_pCallback->GetCode();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_iCode;
|
return m_iCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
ETypeCode GetType() const
|
ETypeCode GetType() const
|
||||||
{
|
{
|
||||||
if ( m_pCallback.get() )
|
if ( m_pCallback.get() )
|
||||||
{
|
{
|
||||||
return m_pCallback->GetType();
|
return m_pCallback->GetType();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return m_iType;
|
return m_iType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the address of the callback function assoziated with function and operator tokens.
|
* @brief Return the address of the callback function assoziated with function and operator tokens.
|
||||||
*
|
*
|
||||||
* @return The pointer stored in #m_pTok.
|
* @return The pointer stored in #m_pTok.
|
||||||
* @throw exception_type if token type is non of:
|
* @throw exception_type if token type is non of:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>cmFUNC</li>
|
* <li>cmFUNC</li>
|
||||||
* <li>cmSTRFUNC</li>
|
* <li>cmSTRFUNC</li>
|
||||||
* <li>cmPOSTOP</li>
|
* <li>cmPOSTOP</li>
|
||||||
* <li>cmINFIXOP</li>
|
* <li>cmINFIXOP</li>
|
||||||
* <li>cmOPRT_BIN</li>
|
* <li>cmOPRT_BIN</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* @sa ECmdCode
|
* @sa ECmdCode
|
||||||
*/
|
*/
|
||||||
generic_fun_type GetFuncAddr() const
|
generic_fun_type GetFuncAddr() const
|
||||||
{
|
{
|
||||||
return ( m_pCallback.get() ) ? reinterpret_cast<generic_fun_type> ( m_pCallback->GetAddr() ) :
|
return ( m_pCallback.get() ) ? reinterpret_cast<generic_fun_type> ( m_pCallback->GetAddr() ) :
|
||||||
reinterpret_cast<generic_fun_type> (0);
|
reinterpret_cast<generic_fun_type> (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Get value of the token.
|
* @brief Get value of the token.
|
||||||
*
|
*
|
||||||
* Only applicable to variable and value tokens.
|
* Only applicable to variable and value tokens.
|
||||||
* @throw exception_type if token is no value/variable token.
|
* @throw exception_type if token is no value/variable token.
|
||||||
*/
|
*/
|
||||||
TBase GetVal() const
|
TBase GetVal() const
|
||||||
{
|
{
|
||||||
switch ( m_iCode )
|
switch ( m_iCode )
|
||||||
{
|
{
|
||||||
case cmVAL:
|
case cmVAL:
|
||||||
return m_fVal;
|
return m_fVal;
|
||||||
case cmVAR:
|
case cmVAR:
|
||||||
return * ( reinterpret_cast<TBase*>(m_pTok) );
|
return * ( reinterpret_cast<TBase*>(m_pTok) );
|
||||||
case cmLE:
|
case cmLE:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmGE:
|
case cmGE:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmNEQ:
|
case cmNEQ:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmEQ:
|
case cmEQ:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmLT:
|
case cmLT:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmGT:
|
case cmGT:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmADD:
|
case cmADD:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmSUB:
|
case cmSUB:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmMUL:
|
case cmMUL:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmDIV:
|
case cmDIV:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmPOW:
|
case cmPOW:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmLAND:
|
case cmLAND:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmLOR:
|
case cmLOR:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmASSIGN:
|
case cmASSIGN:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmBO:
|
case cmBO:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmBC:
|
case cmBC:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmIF:
|
case cmIF:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmELSE:
|
case cmELSE:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmENDIF:
|
case cmENDIF:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmARG_SEP:
|
case cmARG_SEP:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmVARPOW2:
|
case cmVARPOW2:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmVARPOW3:
|
case cmVARPOW3:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmVARPOW4:
|
case cmVARPOW4:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmVARMUL:
|
case cmVARMUL:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmPOW2:
|
case cmPOW2:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmFUNC:
|
case cmFUNC:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmFUNC_STR:
|
case cmFUNC_STR:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmFUNC_BULK:
|
case cmFUNC_BULK:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmSTRING:
|
case cmSTRING:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmOPRT_BIN:
|
case cmOPRT_BIN:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmOPRT_POSTFIX:
|
case cmOPRT_POSTFIX:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmOPRT_INFIX:
|
case cmOPRT_INFIX:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmEND:
|
case cmEND:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case cmUNKNOWN:
|
case cmUNKNOWN:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw QmuParserError ( ecVAL_EXPECTED );
|
throw QmuParserError ( ecVAL_EXPECTED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Get address of a variable token.
|
* @brief Get address of a variable token.
|
||||||
*
|
*
|
||||||
* Valid only if m_iType==CmdVar.
|
* Valid only if m_iType==CmdVar.
|
||||||
* @throw exception_type if token is no variable token.
|
* @throw exception_type if token is no variable token.
|
||||||
*/
|
*/
|
||||||
TBase* GetVar() const
|
TBase* GetVar() const
|
||||||
{
|
{
|
||||||
if ( m_iCode != cmVAR )
|
if ( m_iCode != cmVAR )
|
||||||
{
|
{
|
||||||
throw QmuParserError ( ecINTERNAL_ERROR );
|
throw QmuParserError ( ecINTERNAL_ERROR );
|
||||||
}
|
}
|
||||||
|
|
||||||
return reinterpret_cast<TBase*>( m_pTok );
|
return reinterpret_cast<TBase*>( m_pTok );
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the number of function arguments.
|
* @brief Return the number of function arguments.
|
||||||
*
|
*
|
||||||
* Valid only if m_iType==CmdFUNC.
|
* Valid only if m_iType==CmdFUNC.
|
||||||
*/
|
*/
|
||||||
int GetArgCount() const
|
int GetArgCount() const
|
||||||
{
|
{
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Return the token identifier.
|
* @brief Return the token identifier.
|
||||||
*
|
*
|
||||||
* If #m_iType is cmSTRING the token identifier is the value of the string argument
|
* If #m_iType is cmSTRING the token identifier is the value of the string argument
|
||||||
* for a string function.
|
* for a string function.
|
||||||
* @return #m_strTok
|
* @return #m_strTok
|
||||||
* @throw nothrow
|
* @throw nothrow
|
||||||
* @sa m_strTok
|
* @sa m_strTok
|
||||||
*/
|
*/
|
||||||
const TString& GetAsString() const
|
const TString& GetAsString() const
|
||||||
{
|
{
|
||||||
return m_strTok;
|
return m_strTok;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode.
|
ECmdCode m_iCode; ///< Type of the token; The token type is a constant of type #ECmdCode.
|
||||||
ETypeCode m_iType;
|
ETypeCode m_iType;
|
||||||
void *m_pTok; ///< Stores Token pointer; not applicable for all tokens
|
void *m_pTok; ///< Stores Token pointer; not applicable for all tokens
|
||||||
int m_iIdx; ///< An otional index to an external buffer storing the token data
|
int m_iIdx; ///< An otional index to an external buffer storing the token data
|
||||||
TString m_strTok; ///< Token string
|
TString m_strTok; ///< Token string
|
||||||
TString m_strVal; ///< Value for string variables
|
TString m_strVal; ///< Value for string variables
|
||||||
qreal m_fVal; ///< the value
|
qreal m_fVal; ///< the value
|
||||||
std::unique_ptr<QmuParserCallback> m_pCallback;
|
std::unique_ptr<QmuParserCallback> m_pCallback;
|
||||||
};
|
};
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -74,13 +74,13 @@ 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
|
||||||
{
|
{
|
||||||
noBO = 1 << 0, ///< to avoid i.e. "cos(7)("
|
noBO = 1 << 0, ///< to avoid i.e. "cos(7)("
|
||||||
|
@ -91,7 +91,7 @@ namespace qmu
|
||||||
noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin"
|
noFUN = 1 << 5, ///< to avoid i.e. "sqrt cos" or "(1)sin"
|
||||||
noOPT = 1 << 6, ///< to avoid i.e. "(+)"
|
noOPT = 1 << 6, ///< to avoid i.e. "(+)"
|
||||||
noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!"
|
noPOSTOP = 1 << 7, ///< to avoid i.e. "(5!!)" "sin!"
|
||||||
noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4"
|
noINFIXOP = 1 << 8, ///< to avoid i.e. "++4" "!!4"
|
||||||
noEND = 1 << 9, ///< to avoid unexpected end of formula
|
noEND = 1 << 9, ///< to avoid unexpected end of formula
|
||||||
noSTR = 1 << 10, ///< to block numeric arguments on string functions
|
noSTR = 1 << 10, ///< to block numeric arguments on string functions
|
||||||
noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7"
|
noASSIGN = 1 << 11, ///< to block assignement to constant i.e. "4=7"
|
||||||
|
@ -152,5 +152,3 @@ namespace qmu
|
||||||
} // namespace qmu
|
} // namespace qmu
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user