From d1cbb61238ef0f48edb0f065c7a305a7b0df8d73 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 25 Jul 2023 14:02:01 +0300 Subject: [PATCH] Refactoring. Code style. --- src/app/puzzle/dialogs/vpdialogabout.cpp | 48 +- src/app/puzzle/main.cpp | 4 +- src/app/tape/dialogs/dialogabouttape.cpp | 46 +- src/app/tape/main.cpp | 4 +- src/app/valentina/dialogs/dialogaboutapp.cpp | 47 +- .../dialogs/dialoglayoutsettings.cpp | 118 ++-- src/libs/ifc/ifcdef.cpp | 303 ++++---- src/libs/ifc/ifcdef.h | 63 +- src/libs/ifc/xml/vabstractpattern.cpp | 11 +- src/libs/ifc/xml/vabstractpattern.h | 4 +- src/libs/qmuparser/qmuparserbase.cpp | 660 +++++++++--------- src/libs/qmuparser/qmuparserbase.h | 2 +- src/libs/qmuparser/qmuparsererror.cpp | 242 ++++--- src/libs/qmuparser/qmuparsererror.h | 6 +- src/libs/qmuparser/qmutranslation.cpp | 47 +- src/libs/vformat/vpatternrecipe.cpp | 156 ++--- src/libs/vmisc/literals.cpp | 168 ++--- src/libs/vmisc/literals.h | 2 +- src/libs/vmisc/projectversion.h | 28 +- .../TranslationsTest/tst_buitinregexp.cpp | 15 +- 20 files changed, 984 insertions(+), 990 deletions(-) diff --git a/src/app/puzzle/dialogs/vpdialogabout.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp index dbcf6b363..71f65ba89 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -27,10 +27,10 @@ *************************************************************************/ #include "vpdialogabout.h" -#include "ui_vpdialogabout.h" -#include "../vmisc/projectversion.h" -#include "../vmisc/def.h" #include "../fervor/fvupdater.h" +#include "../vmisc/def.h" +#include "../vmisc/projectversion.h" +#include "ui_vpdialogabout.h" #include #include @@ -46,29 +46,31 @@ //--------------------------------------------------------------------------------------------------------------------- VPDialogAbout::VPDialogAbout(QWidget *parent) - :QDialog(parent), - ui(new Ui::VPDialogAbout), - m_isInitialized(false) + : QDialog(parent), + ui(new Ui::VPDialogAbout), + m_isInitialized(false) { ui->setupUi(this); - //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + // mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); RetranslateUi(); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() - { - if ( not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR)))) - { - qWarning() << tr("Cannot open your default browser"); - } - }); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, + []() + { + if (not QDesktopServices::openUrl(QUrl(QStringLiteral(VER_COMPANYDOMAIN_STR)))) + { + qWarning() << tr("Cannot open your default browser"); + } + }); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &VPDialogAbout::close); - connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() - { - // Set feed URL before doing anything else - FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); - FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); - }); + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, + []() + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); // By default on Windows font point size 8 points we need 11 like on Linux. FontPointSize(ui->label_Legal_Stuff, 11); @@ -99,8 +101,8 @@ void VPDialogAbout::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VPDialogAbout::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); - if ( event->spontaneous() ) + QDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -114,7 +116,7 @@ void VPDialogAbout::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/main.cpp b/src/app/puzzle/main.cpp index 31e4a2525..6585ae0e4 100644 --- a/src/app/puzzle/main.cpp +++ b/src/app/puzzle/main.cpp @@ -65,8 +65,6 @@ auto main(int argc, char *argv[]) -> int Q_INIT_RESOURCE(win_theme); // NOLINT #endif - QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT - #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); #endif @@ -92,6 +90,8 @@ auto main(int argc, char *argv[]) -> int VPApplication app(argc, argv); app.InitOptions(); + QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT + #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) VPApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.puzzle.desktop")); #endif diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp index bd5785ac4..72a2dc9fa 100644 --- a/src/app/tape/dialogs/dialogabouttape.cpp +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -27,10 +27,10 @@ *************************************************************************/ #include "dialogabouttape.h" -#include "ui_dialogabouttape.h" +#include "../fervor/fvupdater.h" #include "../vmisc/def.h" #include "../vmisc/projectversion.h" -#include "../fervor/fvupdater.h" +#include "ui_dialogabouttape.h" #include #include @@ -46,30 +46,32 @@ //--------------------------------------------------------------------------------------------------------------------- DialogAboutTape::DialogAboutTape(QWidget *parent) - :QDialog(parent), - ui(new Ui::DialogAboutTape), - m_isInitialized(false) + : QDialog(parent), + ui(new Ui::DialogAboutTape), + m_isInitialized(false) { ui->setupUi(this); - //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); + // mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); RetranslateUi(); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() - { - if (not QDesktopServices::openUrl( + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, + []() + { + if (not QDesktopServices::openUrl( QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))))) - { - qWarning() << tr("Cannot open your default browser"); - } - }); + { + qWarning() << tr("Cannot open your default browser"); + } + }); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close); - connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() - { - // Set feed URL before doing anything else - FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); - FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); - }); + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, + []() + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); // By default on Windows font point size 8 points we need 11 like on Linux. FontPointSize(ui->label_Legal_Stuff, 11); @@ -100,8 +102,8 @@ void DialogAboutTape::changeEvent(QEvent *event) //--------------------------------------------------------------------------------------------------------------------- void DialogAboutTape::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); - if ( event->spontaneous() ) + QDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -115,7 +117,7 @@ void DialogAboutTape::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index 967ce3893..eac8ccb2a 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -63,8 +63,6 @@ auto main(int argc, char *argv[]) -> int Q_INIT_RESOURCE(win_theme); // NOLINT #endif - QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT - #if defined(Q_OS_WIN) VAbstractApplication::WinAttachConsole(); #endif @@ -90,6 +88,8 @@ auto main(int argc, char *argv[]) -> int MApplication app(argc, argv); app.InitOptions(); + QT_REQUIRE_VERSION(argc, argv, "5.4.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT + #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) MApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.tape.desktop")); #endif diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index 52fe6c036..ddcd00b8f 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -27,15 +27,15 @@ *************************************************************************/ #include "dialogaboutapp.h" +#include "../fervor/fvupdater.h" +#include "../vmisc/projectversion.h" +#include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vvalentinasettings.h" #include "ui_dialogaboutapp.h" #include #include #include #include -#include "../fervor/fvupdater.h" -#include "../vmisc/projectversion.h" -#include "../vmisc/vabstractvalapplication.h" -#include "../vmisc/vvalentinasettings.h" #if !defined(BUILD_REVISION) && defined(QBS_BUILD) #include @@ -43,8 +43,8 @@ #endif //--------------------------------------------------------------------------------------------------------------------- -DialogAboutApp::DialogAboutApp(QWidget *parent) : - QDialog(parent), +DialogAboutApp::DialogAboutApp(QWidget *parent) + : QDialog(parent), ui(new Ui::DialogAboutApp) { ui->setupUi(this); @@ -64,23 +64,24 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : "KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY " "AND FITNESS FOR A PARTICULAR PURPOSE.")); - ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, []() - { - if (not QDesktopServices::openUrl( + connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, + []() + { + if (not QDesktopServices::openUrl( QUrl(QStringLiteral("https://%1").arg(QStringLiteral(VER_COMPANYDOMAIN_STR))))) - { - qWarning() << tr("Cannot open your default browser"); - } - }); + { + qWarning() << tr("Cannot open your default browser"); + } + }); - connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() - { - // Set feed URL before doing anything else - FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); - FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); - }); + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, + []() + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(FvUpdater::CurrentFeedURL()); + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); // By default on Windows font point size 8 points we need 11 like on Linux. FontPointSize(ui->label_Legal_Stuff, 11); @@ -98,8 +99,8 @@ DialogAboutApp::~DialogAboutApp() //--------------------------------------------------------------------------------------------------------------------- void DialogAboutApp::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); - if ( event->spontaneous() ) + QDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -113,7 +114,7 @@ void DialogAboutApp::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 44e59fe12..a7f27d1a6 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -27,35 +27,35 @@ *************************************************************************/ #include "dialoglayoutsettings.h" -#include "ui_dialoglayoutsettings.h" -#include "../vmisc/vvalentinasettings.h" #include "../vmisc/vabstractvalapplication.h" +#include "../vmisc/vvalentinasettings.h" +#include "ui_dialoglayoutsettings.h" #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vmisc/backport/qoverload.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vlayout/vlayoutgenerator.h" #include -#include #include +#include //--------------------------------------------------------------------------------------------------------------------- DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent, bool disableSettings) - : VAbstractLayoutDialog(parent), - m_disableSettings(disableSettings), - ui(new Ui::DialogLayoutSettings), - m_oldPaperUnit(Unit::Mm), - m_oldLayoutUnit(Unit::Mm), - m_generator(generator), - m_isInitialized(false) + : VAbstractLayoutDialog(parent), + m_disableSettings(disableSettings), + ui(new Ui::DialogLayoutSettings), + m_oldPaperUnit(Unit::Mm), + m_oldLayoutUnit(Unit::Mm), + m_generator(generator), + m_isInitialized(false) { ui->setupUi(this); VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); - //moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont - //even cleanse lists before adding + // moved from ReadSettings - well...it seems it can be done once only (i.e. constructor) because Init funcs dont + // even cleanse lists before adding InitPaperUnits(); InitLayoutUnits(); InitTemplates(ui->comboBoxTemplates); @@ -63,7 +63,7 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget MinimumLayoutSize(); InitPrinter(); - //in export console mode going to use defaults + // in export console mode going to use defaults if (not disableSettings) { ReadSettings(); @@ -73,35 +73,35 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget RestoreDefaults(); } - connect(ui->comboBoxPrinter, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogLayoutSettings::PrinterMargins); + connect(ui->comboBoxPrinter, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLayoutSettings::PrinterMargins); - connect(ui->comboBoxTemplates, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogLayoutSettings::TemplateSelected); - connect(ui->comboBoxPaperSizeUnit, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogLayoutSettings::ConvertPaperSize); + connect(ui->comboBoxTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLayoutSettings::TemplateSelected); + connect(ui->comboBoxPaperSizeUnit, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLayoutSettings::ConvertPaperSize); - connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::PaperSizeChanged); - connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::PaperSizeChanged); + connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::PaperSizeChanged); + connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::PaperSizeChanged); - connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::FindTemplate); - connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::FindTemplate); + connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::FindTemplate); + connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::FindTemplate); - connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::CorrectMaxFileds); - connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutSettings::CorrectMaxFileds); + connect(ui->doubleSpinBoxPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::CorrectMaxFileds); + connect(ui->doubleSpinBoxPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutSettings::CorrectMaxFileds); connect(ui->checkBoxIgnoreFileds, &QCheckBox::stateChanged, this, &DialogLayoutSettings::IgnoreAllFields); connect(ui->toolButtonPortrait, &QToolButton::toggled, this, &DialogLayoutSettings::Swap); connect(ui->toolButtonLandscape, &QToolButton::toggled, this, &DialogLayoutSettings::Swap); - connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), - this, &DialogLayoutSettings::ConvertLayoutSize); + connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), this, + &DialogLayoutSettings::ConvertLayoutSize); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); connect(bOk, &QPushButton::clicked, this, &DialogLayoutSettings::DialogAccepted); @@ -407,7 +407,7 @@ void DialogLayoutSettings::FindTemplate() const Unit paperUnit = PaperUnit(); const int max = static_cast(PaperSizeTemplate::Custom); - for (int i=0; i < max; ++i) + for (int i = 0; i < max; ++i) { const QSizeF tmplSize = GetTemplateSize(static_cast(i), paperUnit); if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) @@ -473,7 +473,7 @@ void DialogLayoutSettings::ConvertPaperSize() } //--------------------------------------------------------------------------------------------------------------------- -auto DialogLayoutSettings::SelectPaperUnit(const QString& units) -> bool +auto DialogLayoutSettings::SelectPaperUnit(const QString &units) -> bool { qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData(units); if (indexUnit != -1) @@ -509,15 +509,15 @@ auto DialogLayoutSettings::PageToPixels(qreal value) const -> qreal //--------------------------------------------------------------------------------------------------------------------- auto DialogLayoutSettings::MakeGroupsHelp() -> QString { - //that is REALLY dummy ... can't figure fast how to automate generation... :/ + // that is REALLY dummy ... can't figure fast how to automate generation... :/ return tr("\n\tThree groups: big, middle, small = 0;\n\tTwo groups: big, small = 1;\n\tDescending area = 2"); } //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::showEvent(QShowEvent *event) { - VAbstractLayoutDialog::showEvent( event ); - if ( event->spontaneous() ) + VAbstractLayoutDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -534,7 +534,7 @@ void DialogLayoutSettings::showEvent(QShowEvent *event) resize(sz); } - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -585,7 +585,7 @@ void DialogLayoutSettings::PaperSizeChanged() } //--------------------------------------------------------------------------------------------------------------------- -auto DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) -> bool +auto DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate &id) -> bool { int index = ui->comboBoxTemplates->findData(static_cast(id)); if (index > -1) @@ -657,7 +657,7 @@ void DialogLayoutSettings::DialogAccepted() QMessageBox::StandardButton answer; answer = QMessageBox::question(this, tr("Wrong fields."), tr("Margins go beyond printing. \n\nApply settings anyway?"), - QMessageBox::Yes|QMessageBox::No, QMessageBox::No); + QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (answer == QMessageBox::No) { SetMinMargins(fields, minFields); @@ -675,7 +675,7 @@ void DialogLayoutSettings::DialogAccepted() } } - //don't want to break visual settings when cmd used + // don't want to break visual settings when cmd used if (not m_disableSettings) { WriteSettings(); @@ -687,7 +687,7 @@ void DialogLayoutSettings::DialogAccepted() void DialogLayoutSettings::RestoreDefaults() { ui->comboBoxTemplates->blockSignals(true); - ui->comboBoxTemplates->setCurrentIndex(0);//A0 + ui->comboBoxTemplates->setCurrentIndex(0); // A0 TemplateSelected(); ui->comboBoxTemplates->blockSignals(false); @@ -734,8 +734,8 @@ void DialogLayoutSettings::CorrectMaxFileds() const qreal height = ui->doubleSpinBoxPaperHeight->value(); // 80%/2 of paper size for each field - const qreal widthField = (width*80.0/100.0)/2.0; - const qreal heightField = (height*80.0/100.0)/2.0; + const qreal widthField = (width * 80.0 / 100.0) / 2.0; + const qreal heightField = (height * 80.0 / 100.0) / 2.0; ui->doubleSpinBoxLeftField->setMaximum(widthField); ui->doubleSpinBoxRightField->setMaximum(widthField); @@ -762,8 +762,8 @@ void DialogLayoutSettings::InitPaperUnits() // set default unit m_oldPaperUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); - const qint32 indexUnit = ui->comboBoxPaperSizeUnit->findData( - VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = + ui->comboBoxPaperSizeUnit->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxPaperSizeUnit->setCurrentIndex(indexUnit); @@ -779,15 +779,14 @@ void DialogLayoutSettings::InitLayoutUnits() // set default unit m_oldLayoutUnit = StrToUnits(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); - const qint32 indexUnit = ui->comboBoxLayoutUnit->findData( - VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); + const qint32 indexUnit = + ui->comboBoxLayoutUnit->findData(VAbstractValApplication::VApp()->ValentinaSettings()->GetUnit()); if (indexUnit != -1) { ui->comboBoxLayoutUnit->setCurrentIndex(indexUnit); } } - //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutSettings::InitPrinter() { @@ -801,7 +800,7 @@ void DialogLayoutSettings::InitPrinter() else { const int index = ui->comboBoxPrinter->findText(QPrinterInfo::defaultPrinterName()); - if(index != -1) + if (index != -1) { ui->comboBoxPrinter->setCurrentIndex(index); } @@ -816,17 +815,17 @@ auto DialogLayoutSettings::MakeHelpTemplateList() -> QString auto cntr = static_cast(PaperSizeTemplate::A0); for (int i = 0; i < VAbstractLayoutDialog::PageFormatNames().size(); ++i) { - if (cntr < static_cast(PaperSizeTemplate::Custom))// Don't include custom template + if (cntr < static_cast(PaperSizeTemplate::Custom)) // Don't include custom template { - out += "\t* "+VAbstractLayoutDialog::PageFormatNames().at(i)+" = "+ QString::number(cntr++); + out += "\t* " + VAbstractLayoutDialog::PageFormatNames().at(i) + " = " + QString::number(cntr++); if (i < VAbstractLayoutDialog::PageFormatNames().size() - 2) { - out += QLatin1String(",\n"); + out += QLatin1String(",\n"); } else { - out += QLatin1String(".\n"); + out += QLatin1String(".\n"); } } } @@ -840,15 +839,15 @@ auto DialogLayoutSettings::MakeHelpTiledPdfTemplateList() -> QString for (int i = 0; i <= static_cast(PaperSizeTemplate::Tabloid); ++i) { - out += "\t* "+VAbstractLayoutDialog::PageFormatNames().at(i)+" = "+ QString::number(i); + out += "\t* " + VAbstractLayoutDialog::PageFormatNames().at(i) + " = " + QString::number(i); if (i < static_cast(PaperSizeTemplate::Tabloid)) { - out += QLatin1String(",\n"); + out += QLatin1String(",\n"); } else { - out += QLatin1String(".\n"); + out += QLatin1String(".\n"); } } return out; @@ -1108,7 +1107,6 @@ void DialogLayoutSettings::SetMinMargins(const QMarginsF &fields, const QMargins if (fields.bottom() < minFields.bottom()) { - ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, - LayoutUnit())); + ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, LayoutUnit())); } } diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index d24806947..7355a8743 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -39,119 +39,119 @@ #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) -const QString CustomMSign = QStringLiteral("@"); +const QString CustomMSign = QStringLiteral("@"); const QString CustomIncrSign = QStringLiteral("#"); -const QString AttrType = QStringLiteral("type"); -const QString AttrMx = QStringLiteral("mx"); -const QString AttrMy = QStringLiteral("my"); -const QString AttrName = QStringLiteral("name"); -const QString AttrShortName = QStringLiteral("shortName"); -const QString AttrUUID = QStringLiteral("uuid"); +const QString AttrType = QStringLiteral("type"); +const QString AttrMx = QStringLiteral("mx"); +const QString AttrMy = QStringLiteral("my"); +const QString AttrName = QStringLiteral("name"); +const QString AttrShortName = QStringLiteral("shortName"); +const QString AttrUUID = QStringLiteral("uuid"); const QString AttrGradationLabel = QStringLiteral("gradationLabel"); -const QString AttrMx1 = QStringLiteral("mx1"); -const QString AttrMy1 = QStringLiteral("my1"); -const QString AttrName1 = QStringLiteral("name1"); -const QString AttrMx2 = QStringLiteral("mx2"); -const QString AttrMy2 = QStringLiteral("my2"); -const QString AttrName2 = QStringLiteral("name2"); -const QString AttrBaseLineP1 = QStringLiteral("baseLineP1"); -const QString AttrBaseLineP2 = QStringLiteral("baseLineP2"); -const QString AttrDartP1 = QStringLiteral("dartP1"); -const QString AttrDartP2 = QStringLiteral("dartP2"); -const QString AttrDartP3 = QStringLiteral("dartP3"); -const QString AttrX = QStringLiteral("x"); -const QString AttrY = QStringLiteral("y"); -const QString AttrTypeLine = QStringLiteral("typeLine"); -const QString AttrCut = QStringLiteral("cut"); -const QString AttrLength = QStringLiteral("length"); -const QString AttrBasePoint = QStringLiteral("basePoint"); -const QString AttrFirstPoint = QStringLiteral("firstPoint"); +const QString AttrMx1 = QStringLiteral("mx1"); +const QString AttrMy1 = QStringLiteral("my1"); +const QString AttrName1 = QStringLiteral("name1"); +const QString AttrMx2 = QStringLiteral("mx2"); +const QString AttrMy2 = QStringLiteral("my2"); +const QString AttrName2 = QStringLiteral("name2"); +const QString AttrBaseLineP1 = QStringLiteral("baseLineP1"); +const QString AttrBaseLineP2 = QStringLiteral("baseLineP2"); +const QString AttrDartP1 = QStringLiteral("dartP1"); +const QString AttrDartP2 = QStringLiteral("dartP2"); +const QString AttrDartP3 = QStringLiteral("dartP3"); +const QString AttrX = QStringLiteral("x"); +const QString AttrY = QStringLiteral("y"); +const QString AttrTypeLine = QStringLiteral("typeLine"); +const QString AttrCut = QStringLiteral("cut"); +const QString AttrLength = QStringLiteral("length"); +const QString AttrBasePoint = QStringLiteral("basePoint"); +const QString AttrFirstPoint = QStringLiteral("firstPoint"); const QString AttrSecondPoint = QStringLiteral("secondPoint"); -const QString AttrThirdPoint = QStringLiteral("thirdPoint"); -const QString AttrCenter = QStringLiteral("center"); -const QString AttrRadius = QStringLiteral("radius"); -const QString AttrRadius1 = QStringLiteral("radius1"); -const QString AttrRadius2 = QStringLiteral("radius2"); -const QString AttrAngle = QStringLiteral("angle"); -const QString AttrAngle1 = QStringLiteral("angle1"); -const QString AttrAngle2 = QStringLiteral("angle2"); -const QString AttrLength1 = QStringLiteral("length1"); -const QString AttrLength2 = QStringLiteral("length2"); -const QString AttrP1Line = QStringLiteral("p1Line"); -const QString AttrP2Line = QStringLiteral("p2Line"); -const QString AttrP1Line1 = QStringLiteral("p1Line1"); -const QString AttrP2Line1 = QStringLiteral("p2Line1"); -const QString AttrP1Line2 = QStringLiteral("p1Line2"); -const QString AttrP2Line2 = QStringLiteral("p2Line2"); -const QString AttrPShoulder = QStringLiteral("pShoulder"); -const QString AttrPoint1 = QStringLiteral("point1"); -const QString AttrPoint2 = QStringLiteral("point2"); -const QString AttrPoint3 = QStringLiteral("point3"); -const QString AttrPoint4 = QStringLiteral("point4"); -const QString AttrKAsm1 = QStringLiteral("kAsm1"); -const QString AttrKAsm2 = QStringLiteral("kAsm2"); -const QString AttrKCurve = QStringLiteral("kCurve"); -const QString AttrDuplicate = QStringLiteral("duplicate"); -const QString AttrAScale = QStringLiteral("aScale"); -const QString AttrPathPoint = QStringLiteral("pathPoint"); -const QString AttrPSpline = QStringLiteral("pSpline"); -const QString AttrAxisP1 = QStringLiteral("axisP1"); -const QString AttrAxisP2 = QStringLiteral("axisP2"); -const QString AttrCurve = QStringLiteral("curve"); -const QString AttrCurve1 = QStringLiteral("curve1"); -const QString AttrCurve2 = QStringLiteral("curve2"); -const QString AttrLineColor = QStringLiteral("lineColor"); -const QString AttrColor = QStringLiteral("color"); -const QString AttrPenStyle = QStringLiteral("penStyle"); -const QString AttrFirstArc = QStringLiteral("firstArc"); -const QString AttrSecondArc = QStringLiteral("secondArc"); -const QString AttrCrossPoint = QStringLiteral("crossPoint"); +const QString AttrThirdPoint = QStringLiteral("thirdPoint"); +const QString AttrCenter = QStringLiteral("center"); +const QString AttrRadius = QStringLiteral("radius"); +const QString AttrRadius1 = QStringLiteral("radius1"); +const QString AttrRadius2 = QStringLiteral("radius2"); +const QString AttrAngle = QStringLiteral("angle"); +const QString AttrAngle1 = QStringLiteral("angle1"); +const QString AttrAngle2 = QStringLiteral("angle2"); +const QString AttrLength1 = QStringLiteral("length1"); +const QString AttrLength2 = QStringLiteral("length2"); +const QString AttrP1Line = QStringLiteral("p1Line"); +const QString AttrP2Line = QStringLiteral("p2Line"); +const QString AttrP1Line1 = QStringLiteral("p1Line1"); +const QString AttrP2Line1 = QStringLiteral("p2Line1"); +const QString AttrP1Line2 = QStringLiteral("p1Line2"); +const QString AttrP2Line2 = QStringLiteral("p2Line2"); +const QString AttrPShoulder = QStringLiteral("pShoulder"); +const QString AttrPoint1 = QStringLiteral("point1"); +const QString AttrPoint2 = QStringLiteral("point2"); +const QString AttrPoint3 = QStringLiteral("point3"); +const QString AttrPoint4 = QStringLiteral("point4"); +const QString AttrKAsm1 = QStringLiteral("kAsm1"); +const QString AttrKAsm2 = QStringLiteral("kAsm2"); +const QString AttrKCurve = QStringLiteral("kCurve"); +const QString AttrDuplicate = QStringLiteral("duplicate"); +const QString AttrAScale = QStringLiteral("aScale"); +const QString AttrPathPoint = QStringLiteral("pathPoint"); +const QString AttrPSpline = QStringLiteral("pSpline"); +const QString AttrAxisP1 = QStringLiteral("axisP1"); +const QString AttrAxisP2 = QStringLiteral("axisP2"); +const QString AttrCurve = QStringLiteral("curve"); +const QString AttrCurve1 = QStringLiteral("curve1"); +const QString AttrCurve2 = QStringLiteral("curve2"); +const QString AttrLineColor = QStringLiteral("lineColor"); +const QString AttrColor = QStringLiteral("color"); +const QString AttrPenStyle = QStringLiteral("penStyle"); +const QString AttrFirstArc = QStringLiteral("firstArc"); +const QString AttrSecondArc = QStringLiteral("secondArc"); +const QString AttrCrossPoint = QStringLiteral("crossPoint"); const QString AttrVCrossPoint = QStringLiteral("vCrossPoint"); const QString AttrHCrossPoint = QStringLiteral("hCrossPoint"); -const QString AttrAxisType = QStringLiteral("axisType"); -const QString AttrC1Center = QStringLiteral("c1Center"); -const QString AttrC2Center = QStringLiteral("c2Center"); -const QString AttrC1Radius = QStringLiteral("c1Radius"); -const QString AttrC2Radius = QStringLiteral("c2Radius"); -const QString AttrCCenter = QStringLiteral("cCenter"); -const QString AttrTangent = QStringLiteral("tangent"); -const QString AttrCRadius = QStringLiteral("cRadius"); -const QString AttrArc = QStringLiteral("arc"); -const QString AttrSuffix = QStringLiteral("suffix"); -const QString AttrItem = QStringLiteral("item"); -const QString AttrIdObject = QStringLiteral("idObject"); -const QString AttrInLayout = QStringLiteral("inLayout"); +const QString AttrAxisType = QStringLiteral("axisType"); +const QString AttrC1Center = QStringLiteral("c1Center"); +const QString AttrC2Center = QStringLiteral("c2Center"); +const QString AttrC1Radius = QStringLiteral("c1Radius"); +const QString AttrC2Radius = QStringLiteral("c2Radius"); +const QString AttrCCenter = QStringLiteral("cCenter"); +const QString AttrTangent = QStringLiteral("tangent"); +const QString AttrCRadius = QStringLiteral("cRadius"); +const QString AttrArc = QStringLiteral("arc"); +const QString AttrSuffix = QStringLiteral("suffix"); +const QString AttrItem = QStringLiteral("item"); +const QString AttrIdObject = QStringLiteral("idObject"); +const QString AttrInLayout = QStringLiteral("inLayout"); const QString AttrForbidFlipping = QStringLiteral("forbidFlipping"); const QString AttrForceFlipping = QStringLiteral("forceFlipping"); const QString AttrSewLineOnDrawing = QStringLiteral("sewLineOnDrawing"); const QString AttrRotationAngle = QStringLiteral("rotationAngle"); -const QString AttrClosed = QStringLiteral("closed"); -const QString AttrShowLabel = QStringLiteral("showLabel"); -const QString AttrShowLabel1 = QStringLiteral("showLabel1"); -const QString AttrShowLabel2 = QStringLiteral("showLabel2"); -const QString AttrWidth = QStringLiteral("width"); -const QString AttrHeight = QStringLiteral("height"); +const QString AttrClosed = QStringLiteral("closed"); +const QString AttrShowLabel = QStringLiteral("showLabel"); +const QString AttrShowLabel1 = QStringLiteral("showLabel1"); +const QString AttrShowLabel2 = QStringLiteral("showLabel2"); +const QString AttrWidth = QStringLiteral("width"); +const QString AttrHeight = QStringLiteral("height"); const QString AttrPlaceLabelType = QStringLiteral("placeLabelType"); -const QString AttrVersion = QStringLiteral("version"); +const QString AttrVersion = QStringLiteral("version"); const QString AttrFirstToContour = QStringLiteral("firstToContour"); const QString AttrLastToContour = QStringLiteral("lastToContour"); -const QString AttrNotes = QStringLiteral("notes"); -const QString AttrAlias = QStringLiteral("alias"); -const QString AttrAlias1 = QStringLiteral("alias1"); -const QString AttrAlias2 = QStringLiteral("alias2"); +const QString AttrNotes = QStringLiteral("notes"); +const QString AttrAlias = QStringLiteral("alias"); +const QString AttrAlias1 = QStringLiteral("alias1"); +const QString AttrAlias2 = QStringLiteral("alias2"); const QString AttrCurve1Alias1 = QStringLiteral("curve1Alias1"); const QString AttrCurve1Alias2 = QStringLiteral("curve1Alias2"); const QString AttrCurve2Alias1 = QStringLiteral("curve2Alias1"); const QString AttrCurve2Alias2 = QStringLiteral("curve2Alias2"); const QString AttrLayoutVersion = QStringLiteral("version"); -const QString TypeLineDefault = QStringLiteral("default"); -const QString TypeLineNone = QStringLiteral("none"); -const QString TypeLineLine = QStringLiteral("hair"); -const QString TypeLineDashLine = QStringLiteral("dashLine"); -const QString TypeLineDotLine = QStringLiteral("dotLine"); -const QString TypeLineDashDotLine = QStringLiteral("dashDotLine"); +const QString TypeLineDefault = QStringLiteral("default"); +const QString TypeLineNone = QStringLiteral("none"); +const QString TypeLineLine = QStringLiteral("hair"); +const QString TypeLineDashLine = QStringLiteral("dashLine"); +const QString TypeLineDotLine = QStringLiteral("dotLine"); +const QString TypeLineDashDotLine = QStringLiteral("dashDotLine"); const QString TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); //--------------------------------------------------------------------------------------------------------------------- @@ -161,14 +161,7 @@ const QString TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); */ auto StylesList() -> QStringList { - return QStringList{ - TypeLineNone, - TypeLineLine, - TypeLineDashLine, - TypeLineDotLine, - TypeLineDashDotLine, - TypeLineDashDotDotLine - }; + return {TypeLineNone, TypeLineLine, TypeLineDashLine, TypeLineDotLine, TypeLineDashDotLine, TypeLineDashDotDotLine}; } //--------------------------------------------------------------------------------------------------------------------- @@ -261,61 +254,61 @@ auto CurvePenStylesPics() -> QMap return map; } -const QString ColorDefault = QStringLiteral("default"); -const QString ColorBlack = QStringLiteral("black"); -const QString ColorGreen = QStringLiteral("green"); -const QString ColorBlue = QStringLiteral("blue"); -const QString ColorDarkRed = QStringLiteral("darkRed"); -const QString ColorDarkGreen = QStringLiteral("darkGreen"); -const QString ColorDarkBlue = QStringLiteral("darkBlue"); -const QString ColorYellow = QStringLiteral("yellow"); -const QString ColorLightSalmon = QStringLiteral("lightsalmon"); -const QString ColorGoldenRod = QStringLiteral("goldenrod"); -const QString ColorOrange = QStringLiteral("orange"); -const QString ColorDeepPink = QStringLiteral("deeppink"); -const QString ColorViolet = QStringLiteral("violet"); -const QString ColorDarkViolet = QStringLiteral("darkviolet"); -const QString ColorMediumSeaGreen = QStringLiteral("mediumseagreen"); -const QString ColorLime = QStringLiteral("lime"); -const QString ColorDeepSkyBlue = QStringLiteral("deepskyblue"); -const QString ColorCornFlowerBlue = QStringLiteral("cornflowerblue"); +const QString ColorDefault = QStringLiteral("default"); +const QString ColorBlack = QStringLiteral("black"); +const QString ColorGreen = QStringLiteral("green"); +const QString ColorBlue = QStringLiteral("blue"); +const QString ColorDarkRed = QStringLiteral("darkRed"); +const QString ColorDarkGreen = QStringLiteral("darkGreen"); +const QString ColorDarkBlue = QStringLiteral("darkBlue"); +const QString ColorYellow = QStringLiteral("yellow"); +const QString ColorLightSalmon = QStringLiteral("lightsalmon"); +const QString ColorGoldenRod = QStringLiteral("goldenrod"); +const QString ColorOrange = QStringLiteral("orange"); +const QString ColorDeepPink = QStringLiteral("deeppink"); +const QString ColorViolet = QStringLiteral("violet"); +const QString ColorDarkViolet = QStringLiteral("darkviolet"); +const QString ColorMediumSeaGreen = QStringLiteral("mediumseagreen"); +const QString ColorLime = QStringLiteral("lime"); +const QString ColorDeepSkyBlue = QStringLiteral("deepskyblue"); +const QString ColorCornFlowerBlue = QStringLiteral("cornflowerblue"); -//variables -const QString measurement_ = QStringLiteral("M_"); -const QString increment_ = QStringLiteral("Increment_"); -const QString line_ = QStringLiteral("Line_"); -const QString angleLine_ = QStringLiteral("AngleLine_"); -const QString spl_ = QStringLiteral(SPL_); -const QString arc_ = QStringLiteral(ARC_); -const QString elarc_ = QStringLiteral(ELARC_); -const QString splPath = QStringLiteral("SplPath"); -const QString radius_V = QStringLiteral("Radius"); -const QString radiusArc_ = radius_V + arc_; -const QString radius1ElArc_ = radius_V + QLatin1Char('1') + elarc_; -const QString radius2ElArc_ = radius_V + QLatin1Char('2') + elarc_; -const QString angle1_V = QStringLiteral("Angle1"); -const QString angle2_V = QStringLiteral("Angle2"); -const QString c1Length_V = QStringLiteral("C1Length"); -const QString c2Length_V = QStringLiteral("C2Length"); -const QString c1LengthSpl_ = c1Length_V + spl_; -const QString c2LengthSpl_ = c2Length_V + spl_; -const QString c1LengthSplPath = c1Length_V + splPath; -const QString c2LengthSplPath = c2Length_V + splPath; -const QString angle1Arc_ = angle1_V + arc_; -const QString angle2Arc_ = angle2_V + arc_; -const QString angle1ElArc_ = angle1_V + elarc_; -const QString angle2ElArc_ = angle2_V + elarc_; -const QString angle1Spl_ = angle1_V + spl_; -const QString angle2Spl_ = angle2_V + spl_; -const QString angle1SplPath = angle1_V + splPath; -const QString angle2SplPath = angle2_V + splPath; -const QString seg_ = QStringLiteral("Seg_"); -const QString currentLength = QStringLiteral("CurrentLength"); +// variables +const QString measurement_ = QStringLiteral("M_"); +const QString increment_ = QStringLiteral("Increment_"); +const QString line_ = QStringLiteral("Line_"); +const QString angleLine_ = QStringLiteral("AngleLine_"); +const QString spl_ = QStringLiteral(SPL_); +const QString arc_ = QStringLiteral(ARC_); +const QString elarc_ = QStringLiteral(ELARC_); +const QString splPath = QStringLiteral("SplPath"); +const QString radius_V = QStringLiteral("Radius"); +const QString radiusArc_ = radius_V + arc_; +const QString radius1ElArc_ = radius_V + QLatin1Char('1') + elarc_; +const QString radius2ElArc_ = radius_V + QLatin1Char('2') + elarc_; +const QString angle1_V = QStringLiteral("Angle1"); +const QString angle2_V = QStringLiteral("Angle2"); +const QString c1Length_V = QStringLiteral("C1Length"); +const QString c2Length_V = QStringLiteral("C2Length"); +const QString c1LengthSpl_ = c1Length_V + spl_; +const QString c2LengthSpl_ = c2Length_V + spl_; +const QString c1LengthSplPath = c1Length_V + splPath; +const QString c2LengthSplPath = c2Length_V + splPath; +const QString angle1Arc_ = angle1_V + arc_; +const QString angle2Arc_ = angle2_V + arc_; +const QString angle1ElArc_ = angle1_V + elarc_; +const QString angle2ElArc_ = angle2_V + elarc_; +const QString angle1Spl_ = angle1_V + spl_; +const QString angle2Spl_ = angle2_V + spl_; +const QString angle1SplPath = angle1_V + splPath; +const QString angle2SplPath = angle2_V + splPath; +const QString seg_ = QStringLiteral("Seg_"); +const QString currentLength = QStringLiteral("CurrentLength"); const QString currentSeamAllowance = QStringLiteral("CurrentSeamAllowance"); -const QString rotation_V = QStringLiteral("Rotation"); -const QString rotationElArc_ = rotation_V + elarc_; -const QString pieceArea_ = QStringLiteral("PieceArea_"); -const QString pieceSeamLineArea_ = QStringLiteral("PieceSeamLineArea_"); +const QString rotation_V = QStringLiteral("Rotation"); +const QString rotationElArc_ = rotation_V + elarc_; +const QString pieceArea_ = QStringLiteral("PieceArea_"); +const QString pieceSeamLineArea_ = QStringLiteral("PieceSeamLineArea_"); auto BuilInVariables() -> QStringList { diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 74516c5e5..71e311816 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -32,7 +32,7 @@ #include #ifdef Q_OS_WIN // extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; -# include +#include #endif /*Q_OS_WIN*/ #include @@ -40,8 +40,8 @@ #include #include -#include "../vmisc/typedef.h" #include "../vmisc/def.h" +#include "../vmisc/typedef.h" #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) @@ -50,19 +50,19 @@ extern const QString CustomMSign; extern const QString CustomIncrSign; // Detect whether the compiler supports C++11 noexcept exception specifications. -# if defined(__clang__) -# if __has_feature(cxx_noexcept) -# define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept -# endif -# elif defined(__GNUC__) -# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept -# endif -# elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 -# define V_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept -# else -# define V_NOEXCEPT_EXPR(x) -# endif +#if defined(__clang__) +#if __has_feature(cxx_noexcept) +#define V_NOEXCEPT_EXPR(x) noexcept(x) // Clang 3.0 and above have noexcept +#endif +#elif defined(__GNUC__) +#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__) +#define V_NOEXCEPT_EXPR(x) noexcept(x) // GCC 4.7 and following have noexcept +#endif +#elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 +#define V_NOEXCEPT_EXPR(x) noexcept(x) // Visual Studio 2015 and following have noexcept +#else +#define V_NOEXCEPT_EXPR(x) +#endif extern const QString AttrType; extern const QString AttrMx; @@ -112,9 +112,9 @@ extern const QString AttrPoint1; extern const QString AttrPoint2; extern const QString AttrPoint3; extern const QString AttrPoint4; -extern const QString AttrKAsm1;// TODO. Delete if minimal supported version is 0.2.7 -extern const QString AttrKAsm2;// TODO. Delete if minimal supported version is 0.2.7 -extern const QString AttrKCurve;// TODO. Delete if minimal supported version is 0.2.7 +extern const QString AttrKAsm1; // TODO. Delete if minimal supported version is 0.2.7 +extern const QString AttrKAsm2; // TODO. Delete if minimal supported version is 0.2.7 +extern const QString AttrKCurve; // TODO. Delete if minimal supported version is 0.2.7 extern const QString AttrDuplicate; extern const QString AttrAScale; extern const QString AttrPathPoint; @@ -202,7 +202,6 @@ extern const QString ColorLime; extern const QString ColorDeepSkyBlue; extern const QString ColorCornFlowerBlue; - // variables name // Hacks for avoiding the linker error "undefined reference to" #define SPL_ "Spl_" @@ -253,25 +252,25 @@ QT_WARNING_DISABLE_GCC("-Weffc++") struct VLabelTemplateLine { QString line; - bool bold; - bool italic; - int alignment; - int fontSizeIncrement; + bool bold; + bool italic; + int alignment; + int fontSizeIncrement; }; struct VWatermarkData { - int opacity{20}; - bool showText{true}; + int opacity{20}; + bool showText{true}; QString text{}; - int textRotation{0}; - QFont font{}; - bool showImage{true}; + int textRotation{0}; + QFont font{}; + bool showImage{true}; QString path{}; - int imageRotation{0}; - bool grayscale{false}; - bool invalidFile{false}; - QColor textColor{Qt::black}; + int imageRotation{0}; + bool grayscale{false}; + bool invalidFile{false}; + QColor textColor{Qt::black}; }; QT_WARNING_POP diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 9b4ad2c4b..b6b52a745 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2039,7 +2039,7 @@ auto VAbstractPattern::ListFinalMeasurementsExpressions() const -> QVector bool +auto VAbstractPattern::IsVariable(const QString &token) -> bool { for (const auto &var : BuilInVariables()) { @@ -2054,16 +2054,11 @@ auto VAbstractPattern::IsVariable(const QString &token) const -> bool } } - if (token.startsWith('#')) - { - return true; - } - - return false; + return token.startsWith('#'); } //--------------------------------------------------------------------------------------------------------------------- -auto VAbstractPattern::IsFunction(const QString &token) const -> bool +auto VAbstractPattern::IsFunction(const QString &token) -> bool { for (const auto &fn : BuilInFunctions()) { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 388465717..fa6adc7c9 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -538,8 +538,8 @@ private: auto ListPieceExpressions() const -> QVector; auto ListFinalMeasurementsExpressions() const -> QVector; - auto IsVariable(const QString &token) const -> bool; - auto IsFunction(const QString &token) const -> bool; + static auto IsVariable(const QString &token) -> bool; + static auto IsFunction(const QString &token) -> bool; auto ParseItemElement(const QDomElement &domElement) -> QPair>; diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 54faff58b..99097b619 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -27,11 +27,10 @@ #include #include #include -#include #include #include #ifdef QMUP_USE_OPENMP - #include +#include #endif #include @@ -52,46 +51,36 @@ namespace qmu bool QmuParserBase::g_DbgDumpCmdCode = false; bool QmuParserBase::g_DbgDumpStack = false; -/** - * @brief Identifiers for built in binary operators. - * - * When defining custom binary operators with #AddOprt(...) make sure not to choose - * names conflicting with these definitions. - */ -const QStringList QmuParserBase::c_DefaultOprt = QStringList()<< "<=" << ">=" << "!=" << "==" << "<" << ">" << "+" - << "-" << "*" << "/" << "^" << "&&" << "||" << "=" - << "(" << ")" << "?" << ":"; - //--------------------------------------------------------------------------------------------------------------------- /** * @brief Constructor. */ QmuParserBase::QmuParserBase() - : m_locale(QLocale::c()), - m_decimalPoint(LocaleDecimalPoint(QLocale::c())), - m_thousandsSeparator(LocaleGroupSeparator(QLocale::c())), - m_FunDef(), - m_pTokenReader(), - m_pParseFormula(&QmuParserBase::ParseString), - m_vRPN(), - m_vStringBuf(), - m_vStringVarBuf(), - m_PostOprtDef(), - m_InfixOprtDef(), - m_OprtDef(), - m_ConstDef(), - m_StrVarDef(), - m_VarDef(), - m_bBuiltInOp(true), - m_sNameChars(), - m_sOprtChars(), - m_sInfixOprtChars(), - m_nIfElseCounter(0), - m_vStackBuffer(), - m_nFinalResultIdx(0), - m_Tokens(QMap()), - m_Numbers(QMap()), - allowSubexpressions(true) + : m_locale(QLocale::c()), + m_decimalPoint(LocaleDecimalPoint(QLocale::c())), + m_thousandsSeparator(LocaleGroupSeparator(QLocale::c())), + m_FunDef(), + m_pTokenReader(), + m_pParseFormula(&QmuParserBase::ParseString), + m_vRPN(), + m_vStringBuf(), + m_vStringVarBuf(), + m_PostOprtDef(), + m_InfixOprtDef(), + m_OprtDef(), + m_ConstDef(), + m_StrVarDef(), + m_VarDef(), + m_bBuiltInOp(true), + m_sNameChars(), + m_sOprtChars(), + m_sInfixOprtChars(), + m_nIfElseCounter(0), + m_vStackBuffer(), + m_nFinalResultIdx(0), + m_Tokens(QMap()), + m_Numbers(QMap()), + allowSubexpressions(true) { InitTokenReader(); } @@ -103,31 +92,31 @@ QmuParserBase::QmuParserBase() * Tha parser can be safely copy constructed but the bytecode is reset during copy construction. */ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser) - : m_locale(a_Parser.getLocale()), - m_decimalPoint(a_Parser.getDecimalPoint()), - m_thousandsSeparator(a_Parser.getThousandsSeparator()), - m_FunDef(), - m_pTokenReader(), - m_pParseFormula(&QmuParserBase::ParseString), - m_vRPN(), - m_vStringBuf(), - m_vStringVarBuf(), - m_PostOprtDef(), - m_InfixOprtDef(), - m_OprtDef(), - m_ConstDef(), - m_StrVarDef(), - m_VarDef(), - m_bBuiltInOp(true), - m_sNameChars(), - m_sOprtChars(), - m_sInfixOprtChars(), - m_nIfElseCounter(0), - m_vStackBuffer(), - m_nFinalResultIdx(0), - m_Tokens(QMap()), - m_Numbers(QMap()), - allowSubexpressions(true) + : m_locale(a_Parser.getLocale()), + m_decimalPoint(a_Parser.getDecimalPoint()), + m_thousandsSeparator(a_Parser.getThousandsSeparator()), + m_FunDef(), + m_pTokenReader(), + m_pParseFormula(&QmuParserBase::ParseString), + m_vRPN(), + m_vStringBuf(), + m_vStringVarBuf(), + m_PostOprtDef(), + m_InfixOprtDef(), + m_OprtDef(), + m_ConstDef(), + m_StrVarDef(), + m_VarDef(), + m_bBuiltInOp(true), + m_sNameChars(), + m_sOprtChars(), + m_sInfixOprtChars(), + m_nIfElseCounter(0), + m_vStackBuffer(), + m_nFinalResultIdx(0), + m_Tokens(QMap()), + m_Numbers(QMap()), + allowSubexpressions(true) { m_pTokenReader.reset(new token_reader_type(this)); Assign(a_Parser); @@ -135,7 +124,8 @@ QmuParserBase::QmuParserBase(const QmuParserBase &a_Parser) //--------------------------------------------------------------------------------------------------------------------- QmuParserBase::~QmuParserBase() -{} +{ +} //--------------------------------------------------------------------------------------------------------------------- /** @@ -167,34 +157,34 @@ auto QmuParserBase::operator=(const QmuParserBase &a_Parser) -> QmuParserBase & */ void QmuParserBase::Assign(const QmuParserBase &a_Parser) { - if (&a_Parser==this) + if (&a_Parser == this) { - return; + return; } // Don't copy bytecode instead cause the parser to create new bytecode // by resetting the parse function. ReInit(); - m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants - m_VarDef = a_Parser.m_VarDef; // Copy user defined variables - m_bBuiltInOp = a_Parser.m_bBuiltInOp; - m_vStringBuf = a_Parser.m_vStringBuf; - m_vStackBuffer = a_Parser.m_vStackBuffer; + m_ConstDef = a_Parser.m_ConstDef; // Copy user define constants + m_VarDef = a_Parser.m_VarDef; // Copy user defined variables + m_bBuiltInOp = a_Parser.m_bBuiltInOp; + m_vStringBuf = a_Parser.m_vStringBuf; + m_vStackBuffer = a_Parser.m_vStackBuffer; m_nFinalResultIdx = a_Parser.m_nFinalResultIdx; - m_StrVarDef = a_Parser.m_StrVarDef; - m_vStringVarBuf = a_Parser.m_vStringVarBuf; - m_nIfElseCounter = a_Parser.m_nIfElseCounter; + m_StrVarDef = a_Parser.m_StrVarDef; + m_vStringVarBuf = a_Parser.m_vStringVarBuf; + m_nIfElseCounter = a_Parser.m_nIfElseCounter; m_pTokenReader.reset(a_Parser.m_pTokenReader->Clone(this)); // Copy function and operator callbacks - m_FunDef = a_Parser.m_FunDef; // Copy function definitions - m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators - m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation - m_OprtDef = a_Parser.m_OprtDef; // binary operators + m_FunDef = a_Parser.m_FunDef; // Copy function definitions + m_PostOprtDef = a_Parser.m_PostOprtDef; // post value unary operators + m_InfixOprtDef = a_Parser.m_InfixOprtDef; // unary operators for infix notation + m_OprtDef = a_Parser.m_OprtDef; // binary operators - m_sNameChars = a_Parser.m_sNameChars; - m_sOprtChars = a_Parser.m_sOprtChars; + m_sNameChars = a_Parser.m_sNameChars; + m_sOprtChars = a_Parser.m_sOprtChars; m_sInfixOprtChars = a_Parser.m_sInfixOprtChars; } @@ -311,38 +301,38 @@ auto QmuParserBase::GetVersion(EParserVersionInfo eInfo) -> QString ss << QMUP_VERSION; - if (eInfo==pviFULL) + if (eInfo == pviFULL) { ss << " (" << QMUP_VERSION_DATE; - ss << "; " << sizeof(void*)*8 << "BIT"; + ss << "; " << sizeof(void *) * 8 << "BIT"; - #ifdef _DEBUG +#ifdef _DEBUG ss << "; DEBUG"; - #else +#else ss << "; RELEASE"; - #endif +#endif - #ifdef _UNICODE +#ifdef _UNICODE ss << "; UNICODE"; - #else - #ifdef _MBCS +#else +#ifdef _MBCS ss << "; MBCS"; - #else +#else ss << "; ASCII"; - #endif - #endif +#endif +#endif - #ifdef QMUP_USE_OPENMP +#ifdef QMUP_USE_OPENMP ss << "; OPENMP"; - //#else - // ss << "; NO_OPENMP"; - #endif +// #else +// ss << "; NO_OPENMP"; +#endif - #if defined(MUP_MATH_EXCEPTIONS) +#if defined(MUP_MATH_EXCEPTIONS) ss << "; MATHEXC"; - //#else - // ss << "; NO_MATHEXC"; - #endif +// #else +// ss << "; NO_MATHEXC"; +#endif ss << ")"; } @@ -353,8 +343,8 @@ auto QmuParserBase::GetVersion(EParserVersionInfo eInfo) -> QString /** * @brief Add a function or operator callback to the parser. */ -void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback, - funmap_type &a_Storage, const QString &a_szCharSet ) +void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallback &a_Callback, funmap_type &a_Storage, + const QString &a_szCharSet) { if (a_Callback.GetAddr() == nullptr) { @@ -364,22 +354,22 @@ void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallbac const funmap_type *pFunMap = &a_Storage; // Check for conflicting operator or function names - if ( pFunMap!=&m_FunDef && m_FunDef.find(a_strName)!=m_FunDef.end() ) + if (pFunMap != &m_FunDef && m_FunDef.find(a_strName) != m_FunDef.end()) { Error(ecNAME_CONFLICT, -1, a_strName); } - if ( pFunMap!=&m_PostOprtDef && m_PostOprtDef.find(a_strName)!=m_PostOprtDef.end() ) + if (pFunMap != &m_PostOprtDef && m_PostOprtDef.find(a_strName) != m_PostOprtDef.end()) { Error(ecNAME_CONFLICT, -1, a_strName); } - if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_InfixOprtDef.find(a_strName)!=m_InfixOprtDef.end() ) + if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_InfixOprtDef.find(a_strName) != m_InfixOprtDef.end()) { Error(ecNAME_CONFLICT, -1, a_strName); } - if ( pFunMap!=&m_InfixOprtDef && pFunMap!=&m_OprtDef && m_OprtDef.find(a_strName)!=m_OprtDef.end() ) + if (pFunMap != &m_InfixOprtDef && pFunMap != &m_OprtDef && m_OprtDef.find(a_strName) != m_OprtDef.end()) { Error(ecNAME_CONFLICT, -1, a_strName); } @@ -399,8 +389,8 @@ void QmuParserBase::AddCallback(const QString &a_strName, const QmuParserCallbac void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a_Callback, const QString &a_szCharSet) const { - if ( a_sName.isEmpty() || (FindFirstNotOf(a_sName, a_szCharSet) != -1) || - (a_sName.at(0)>='0' && a_sName.at(0)<='9')) + if (a_sName.isEmpty() || (FindFirstNotOf(a_sName, a_szCharSet) != -1) || + (a_sName.at(0) >= '0' && a_sName.at(0) <= '9')) { switch (a_Callback.GetCode()) { @@ -425,8 +415,8 @@ void QmuParserBase::CheckOprt(const QString &a_sName, const QmuParserCallback &a */ void QmuParserBase::CheckName(const QString &a_sName, const QString &a_szCharSet) const { - if ( a_sName.isEmpty() || (FindFirstNotOf(a_sName, a_szCharSet) != -1) || - (a_sName.at(0)>='0' && a_sName.at(0)<='9')) + if (a_sName.isEmpty() || (FindFirstNotOf(a_sName, a_szCharSet) != -1) || + (a_sName.at(0) >= '0' && a_sName.at(0) <= '9')) { Error(ecINVALID_NAME); } @@ -444,7 +434,7 @@ void QmuParserBase::SetExpr(const QString &a_sExpr) { // Check locale compatibility std::locale loc; - if (m_pTokenReader->GetArgSep() == QChar(std::use_facet >(loc).decimal_point())) + if (m_pTokenReader->GetArgSep() == QChar(std::use_facet>(loc).decimal_point())) { Error(ecLOCALE); } @@ -454,7 +444,7 @@ void QmuParserBase::SetExpr(const QString &a_sExpr) // when calling tellg on a stringstream created from the expression after // reading a value at the end of an expression. (qmu::QmuParser::IsVal function) // (tellg returns -1 otherwise causing the parser to ignore the value) - QString sBuf(a_sExpr + QChar(' ') ); + QString sBuf(a_sExpr + QChar(' ')); m_pTokenReader->SetFormula(sBuf); ReInit(); } @@ -500,7 +490,7 @@ auto QmuParserBase::ValidInfixOprtChars() const -> const QString & void QmuParserBase::DefinePostfixOprt(const QString &a_sFun, fun_type1 a_pFun, bool a_bAllowOpt) { AddCallback(a_sFun, QmuParserCallback(a_pFun, a_bAllowOpt, prPOSTFIX, cmOPRT_POSTFIX), m_PostOprtDef, - ValidOprtChars() ); + ValidOprtChars()); } //--------------------------------------------------------------------------------------------------------------------- @@ -531,7 +521,7 @@ void QmuParserBase::Init() void QmuParserBase::DefineInfixOprt(const QString &a_sName, fun_type1 a_pFun, int a_iPrec, bool a_bAllowOpt) { AddCallback(a_sName, QmuParserCallback(a_pFun, a_bAllowOpt, a_iPrec, cmOPRT_INFIX), m_InfixOprtDef, - ValidInfixOprtChars() ); + ValidInfixOprtChars()); } //--------------------------------------------------------------------------------------------------------------------- @@ -545,11 +535,11 @@ void QmuParserBase::DefineInfixOprt(const QString &a_sName, fun_type1 a_pFun, in * * Adds a new Binary operator the the parser instance. */ -void QmuParserBase::DefineOprt( const QString &a_sName, fun_type2 a_pFun, unsigned a_iPrec, - EOprtAssociativity a_eAssociativity, bool a_bAllowOpt ) +void QmuParserBase::DefineOprt(const QString &a_sName, fun_type2 a_pFun, unsigned a_iPrec, + EOprtAssociativity a_eAssociativity, bool a_bAllowOpt) { // Check for conflicts with built in operator names - for (int i=0; m_bBuiltInOp && i(a_iPrec), a_eAssociativity), m_OprtDef, - ValidOprtChars() ); + ValidOprtChars()); } //--------------------------------------------------------------------------------------------------------------------- @@ -571,15 +561,15 @@ void QmuParserBase::DefineOprt( const QString &a_sName, fun_type2 a_pFun, unsign void QmuParserBase::DefineStrConst(const QString &a_strName, const QString &a_strVal) { // Test if a constant with that names already exists - if (m_StrVarDef.find(a_strName)!=m_StrVarDef.end()) + if (m_StrVarDef.find(a_strName) != m_StrVarDef.end()) { Error(ecNAME_CONFLICT); } CheckName(a_strName, ValidNameChars()); - m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer - m_StrVarDef[a_strName] = m_vStringBuf.size(); // bind buffer index to variable name + m_vStringVarBuf.push_back(a_strVal); // Store variable string in internal buffer + m_StrVarDef[a_strName] = m_vStringBuf.size(); // bind buffer index to variable name ReInit(); } @@ -600,7 +590,7 @@ void QmuParserBase::DefineVar(const QString &a_sName, qreal *a_pVar) } // Test if a constant with that names already exists - if (m_ConstDef.find(a_sName)!=m_ConstDef.end()) + if (m_ConstDef.find(a_sName) != m_ConstDef.end()) { Error(ecNAME_CONFLICT); } @@ -740,12 +730,12 @@ auto QmuParserBase::GetUsedVar() const -> const varmap_type & auto QmuParserBase::ApplyStrFunc(const token_type &a_FunTok, const QVector &a_vArg) const -> QmuParserBase::token_type { - if (a_vArg.back().GetCode()!=cmSTRING) + if (a_vArg.back().GetCode() != cmSTRING) { Error(ecSTRING_EXPECTED, m_pTokenReader->GetPos(), a_FunTok.GetAsString()); } - token_type valTok; + token_type valTok; generic_fun_type pFunc = a_FunTok.GetFuncAddr(); assert(pFunc); @@ -774,7 +764,7 @@ auto QmuParserBase::ApplyStrFunc(const token_type &a_FunTok, const QVectorGetPos(), a_FunTok.GetAsString()); } @@ -794,7 +784,7 @@ auto QmuParserBase::ApplyStrFunc(const token_type &a_FunTok, const QVector &a_stOpt, QStack &a_stVal, int a_iArgCount) const +void QmuParserBase::ApplyFunc(QStack &a_stOpt, QStack &a_stVal, int a_iArgCount) const { assert(m_pTokenReader.get()); @@ -810,46 +800,46 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & // Binary operators must rely on their internal operator number // since counting of operators relies on commas for function arguments // binary operators do not have commas in their expression - int iArgCount = (funTok.GetCode()==cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; + int iArgCount = (funTok.GetCode() == cmOPRT_BIN) ? funTok.GetArgCount() : a_iArgCount; // determine how many parameters the function needs. To remember iArgCount includes the // string parameter whilst GetArgCount() counts only numeric parameters. - int iArgRequired = funTok.GetArgCount() + ((funTok.GetType()==tpSTR) ? 1 : 0); + int iArgRequired = funTok.GetArgCount() + ((funTok.GetType() == tpSTR) ? 1 : 0); // Thats the number of numerical parameters - int iArgNumerical = iArgCount - ((funTok.GetType()==tpSTR) ? 1 : 0); + int iArgNumerical = iArgCount - ((funTok.GetType() == tpSTR) ? 1 : 0); - if (funTok.GetCode()==cmFUNC_STR && iArgCount-iArgNumerical>1) + if (funTok.GetCode() == cmFUNC_STR && iArgCount - iArgNumerical > 1) { Error(ecINTERNAL_ERROR); } - if (funTok.GetArgCount()>=0 && iArgCount>iArgRequired) + if (funTok.GetArgCount() >= 0 && iArgCount > iArgRequired) { - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); } - if (funTok.GetCode()!=cmOPRT_BIN && iArgCountGetPos()-1, funTok.GetAsString()); + Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); } - if (funTok.GetCode()==cmFUNC_STR && iArgCount>iArgRequired ) + if (funTok.GetCode() == cmFUNC_STR && iArgCount > iArgRequired) { - Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos()-1, funTok.GetAsString()); + Error(ecTOO_MANY_PARAMS, m_pTokenReader->GetPos() - 1, funTok.GetAsString()); } // Collect the numeric function arguments from the value stack and store them // in a vector QVector stArg; - for (int i=0; iGetPos(), funTok.GetAsString()); } - stArg.push_back( a_stVal.pop() ); - if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + stArg.push_back(a_stVal.pop()); + if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) { Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); } @@ -860,7 +850,7 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & case cmFUNC_STR: stArg.push_back(a_stVal.pop()); - if ( stArg.back().GetType()==tpSTR && funTok.GetType()!=tpSTR ) + if (stArg.back().GetType() == tpSTR && funTok.GetType() != tpSTR) { Error(ecVAL_EXPECTED, m_pTokenReader->GetPos(), funTok.GetAsString()); } @@ -874,12 +864,12 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & case cmOPRT_POSTFIX: case cmOPRT_INFIX: case cmFUNC: - if (funTok.GetArgCount()==-1 && iArgCount==0) + if (funTok.GetArgCount() == -1 && iArgCount == 0) { Error(ecTOO_FEW_PARAMS, m_pTokenReader->GetPos(), funTok.GetAsString()); } - m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount()==-1) ? -iArgNumerical : iArgNumerical); + m_vRPN.AddFun(funTok.GetFuncAddr(), (funTok.GetArgCount() == -1) ? -iArgNumerical : iArgNumerical); break; default: break; @@ -894,27 +884,27 @@ void QmuParserBase::ApplyFunc( QStack &a_stOpt, QStack & void QmuParserBase::ApplyIfElse(QStack &a_stOpt, QStack &a_stVal) const { // Check if there is an if Else clause to be calculated - while (a_stOpt.size() && a_stOpt.top().GetCode()==cmELSE) + while (a_stOpt.size() && a_stOpt.top().GetCode() == cmELSE) { token_type opElse = a_stOpt.pop(); - Q_ASSERT(a_stOpt.size()>0); + Q_ASSERT(a_stOpt.size() > 0); // Take the value associated with the else branch from the value stack token_type vVal2 = a_stVal.pop(); - Q_ASSERT(a_stOpt.size()>0); - Q_ASSERT(a_stVal.size()>=2); + Q_ASSERT(a_stOpt.size() > 0); + Q_ASSERT(a_stVal.size() >= 2); // it then else is a ternary operator Pop all three values from the value s // tack and just return the right value token_type vVal1 = a_stVal.pop(); token_type vExpr = a_stVal.pop(); - a_stVal.push( not qFuzzyIsNull(vExpr.GetVal()) ? vVal1 : vVal2); + a_stVal.push(not qFuzzyIsNull(vExpr.GetVal()) ? vVal1 : vVal2); token_type opIf = a_stOpt.pop(); - Q_ASSERT(opElse.GetCode()==cmELSE); - Q_ASSERT(opIf.GetCode()==cmIF); + Q_ASSERT(opElse.GetCode() == cmELSE); + Q_ASSERT(opIf.GetCode() == cmIF); m_vRPN.AddIfElse(cmENDIF); } // while pending if-else-clause found @@ -927,30 +917,27 @@ void QmuParserBase::ApplyIfElse(QStack &a_stOpt, QStack void QmuParserBase::ApplyBinOprt(QStack &a_stOpt, QStack &a_stVal) const { // is it a user defined binary operator? - if (a_stOpt.top().GetCode()==cmOPRT_BIN) + if (a_stOpt.top().GetCode() == cmOPRT_BIN) { ApplyFunc(a_stOpt, a_stVal, 2); } else { - if(a_stVal.size()<2) + if (a_stVal.size() < 2) { Error(ecUNEXPECTED_OPERATOR); } - token_type valTok1 = a_stVal.pop(), - valTok2 = a_stVal.pop(), - optTok = a_stOpt.pop(), - resTok; + token_type valTok1 = a_stVal.pop(), valTok2 = a_stVal.pop(), optTok = a_stOpt.pop(), resTok; - if ( valTok1.GetType()!=valTok2.GetType() || (valTok1.GetType()==tpSTR && valTok2.GetType()==tpSTR) ) + if (valTok1.GetType() != valTok2.GetType() || (valTok1.GetType() == tpSTR && valTok2.GetType() == tpSTR)) { Error(ecOPRT_TYPE_CONFLICT, m_pTokenReader->GetPos(), optTok.GetAsString()); } - if (optTok.GetCode()==cmASSIGN) + if (optTok.GetCode() == cmASSIGN) { - if (valTok2.GetCode()!=cmVAR) + if (valTok2.GetCode() != cmVAR) { Error(ecUNEXPECTED_OPERATOR, -1, QChar('=')); } @@ -979,7 +966,7 @@ void QmuParserBase::ApplyRemainingOprt(QStack &stOpt, QStack= cmLE && code <= cmASSIGN) || code == cmOPRT_INFIX || code == cmOPRT_BIN) { - if (code==cmOPRT_INFIX) + if (code == cmOPRT_INFIX) { ApplyFunc(stOpt, stVal, 1); } @@ -1020,82 +1007,83 @@ auto QmuParserBase::ParseCmdCode() const -> qreal */ auto QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const -> qreal { - assert(nThreadID<=s_MaxNumOpenMPThreads); + assert(nThreadID <= s_MaxNumOpenMPThreads); // Note: The check for nOffset==0 and nThreadID here is not necessary but // brings a minor performance gain when not in bulk mode. - qreal *Stack = ((nOffset==0) && (nThreadID==0)) ? &m_vStackBuffer[0] : &m_vStackBuffer[nThreadID * - (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; + qreal *Stack = ((nOffset == 0) && (nThreadID == 0)) + ? &m_vStackBuffer[0] + : &m_vStackBuffer[nThreadID * (m_vStackBuffer.size() / s_MaxNumOpenMPThreads)]; qreal buf; qmusizetype sidx(0); - for (const SToken *pTok = m_vRPN.GetBase(); pTok->Cmd!=cmEND ; ++pTok) + for (const SToken *pTok = m_vRPN.GetBase(); pTok->Cmd != cmEND; ++pTok) { switch (pTok->Cmd) { - // built in binary operators + // built in binary operators case cmLE: --sidx; - Stack[sidx] = Stack[sidx] <= Stack[sidx+1]; + Stack[sidx] = Stack[sidx] <= Stack[sidx + 1]; continue; case cmGE: --sidx; - Stack[sidx] = Stack[sidx] >= Stack[sidx+1]; + Stack[sidx] = Stack[sidx] >= Stack[sidx + 1]; continue; case cmNEQ: --sidx; - Stack[sidx] = not QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx+1]); + Stack[sidx] = not QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx + 1]); continue; case cmEQ: --sidx; - Stack[sidx] = QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx+1]); + Stack[sidx] = QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx + 1]); continue; case cmLT: --sidx; - Stack[sidx] = Stack[sidx] < Stack[sidx+1]; + Stack[sidx] = Stack[sidx] < Stack[sidx + 1]; continue; case cmGT: --sidx; - Stack[sidx] = Stack[sidx] > Stack[sidx+1]; + Stack[sidx] = Stack[sidx] > Stack[sidx + 1]; continue; case cmADD: --sidx; - Stack[sidx] += Stack[1+sidx]; + Stack[sidx] += Stack[1 + sidx]; continue; case cmSUB: --sidx; - Stack[sidx] -= Stack[1+sidx]; + Stack[sidx] -= Stack[1 + sidx]; continue; case cmMUL: --sidx; - Stack[sidx] *= Stack[1+sidx]; + Stack[sidx] *= Stack[1 + sidx]; continue; case cmDIV: --sidx; - #if defined(MUP_MATH_EXCEPTIONS) - if (Stack[1+sidx]==0) +#if defined(MUP_MATH_EXCEPTIONS) + if (Stack[1 + sidx] == 0) { Error(ecDIV_BY_ZERO); } - #endif - Stack[sidx] /= Stack[1+sidx]; +#endif + Stack[sidx] /= Stack[1 + sidx]; continue; case cmPOW: --sidx; - Stack[sidx] = qPow(Stack[sidx], Stack[1+sidx]); + Stack[sidx] = qPow(Stack[sidx], Stack[1 + sidx]); continue; case cmLAND: --sidx; -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wfloat-equal") - Stack[sidx] = static_cast(Stack[sidx]) && static_cast(Stack[sidx+1]); -QT_WARNING_POP + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wfloat-equal") + Stack[sidx] = static_cast(Stack[sidx]) && static_cast(Stack[sidx + 1]); + QT_WARNING_POP continue; case cmLOR: --sidx; -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wfloat-equal") - Stack[sidx] = static_cast(Stack[sidx]) || static_cast(Stack[sidx+1]); -QT_WARNING_POP + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wfloat-equal") + Stack[sidx] = static_cast(Stack[sidx]) || static_cast(Stack[sidx + 1]); + QT_WARNING_POP continue; case cmASSIGN: // Bugfix for Bulkmode: @@ -1108,8 +1096,8 @@ QT_WARNING_POP continue; // original code: //--sidx; - //Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; - //continue; + // Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1]; + // continue; case cmIF: if (qFuzzyIsNull(Stack[sidx--])) { @@ -1127,19 +1115,19 @@ QT_WARNING_POP Stack[++sidx] = *(pTok->Val.ptr + nOffset); continue; case cmVAL: - Stack[++sidx] = pTok->Val.data2; + Stack[++sidx] = pTok->Val.data2; continue; case cmVARPOW2: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf; + Stack[++sidx] = buf * buf; continue; case cmVARPOW3: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf*buf; + Stack[++sidx] = buf * buf * buf; continue; case cmVARPOW4: buf = *(pTok->Val.ptr + nOffset); - Stack[++sidx] = buf*buf*buf*buf; + Stack[++sidx] = buf * buf * buf * buf; continue; case cmVARMUL: Stack[++sidx] = *(pTok->Val.ptr + nOffset) * pTok->Val.data + pTok->Val.data2; @@ -1149,10 +1137,10 @@ QT_WARNING_POP { qmusizetype iArgCount = pTok->Fun.argc; -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wcast-function-type") -QT_WARNING_DISABLE_CLANG("-Wundefined-reinterpret-cast") -QT_WARNING_DISABLE_MSVC(4191) + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wcast-function-type") + QT_WARNING_DISABLE_CLANG("-Wundefined-reinterpret-cast") + QT_WARNING_DISABLE_MSVC(4191) // switch according to argument count switch (iArgCount) @@ -1166,83 +1154,85 @@ QT_WARNING_DISABLE_MSVC(4191) continue; case 2: sidx -= 1; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx + 1]); continue; case 3: sidx -= 2; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx + 1], + Stack[sidx + 2]); continue; case 4: sidx -= 3; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx + 1], + Stack[sidx + 2], Stack[sidx + 3]); continue; case 5: sidx -= 4; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], Stack[sidx + 4]); continue; case 6: sidx -= 5; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx + 1], + Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5]); continue; case 7: sidx -= 6; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], Stack[sidx + 4], + Stack[sidx + 5], Stack[sidx + 6]); continue; case 8: sidx -= 7; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], - Stack[sidx+7]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], Stack[sidx + 4], + Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7]); continue; case 9: sidx -= 8; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], - Stack[sidx+7], Stack[sidx+8]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], Stack[sidx + 4], + Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7], Stack[sidx + 8]); continue; case 10: sidx -= 9; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(Stack[sidx], Stack[sidx+1], - Stack[sidx+2], Stack[sidx+3], Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], - Stack[sidx+7], Stack[sidx+8], Stack[sidx+9]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], Stack[sidx + 4], + Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7], Stack[sidx + 8], Stack[sidx + 9]); continue; default: - if (iArgCount>0) // function with variable arguments store the number as a negative value + if (iArgCount > 0) // function with variable arguments store the number as a negative value { Error(ecINTERNAL_ERROR, 1); } sidx -= -iArgCount - 1; - Stack[sidx] =(*reinterpret_cast(pTok->Fun.ptr))(&Stack[sidx], -iArgCount); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(&Stack[sidx], -iArgCount); continue; } } // Next is treatment of string functions case cmFUNC_STR: { - sidx -= pTok->Fun.argc -1; + sidx -= pTok->Fun.argc - 1; // The index of the string argument in the string table qmusizetype iIdxStack = pTok->Fun.idx; - Q_ASSERT( iIdxStack>=0 && iIdxStack= 0 && iIdxStack < m_vStringBuf.size()); - switch (pTok->Fun.argc) // switch according to argument count + switch (pTok->Fun.argc) // switch according to argument count { case 0: Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack)); continue; case 1: - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack), - Stack[sidx]); + Stack[sidx] = + (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack), Stack[sidx]); continue; case 2: Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(m_vStringBuf.at(iIdxStack), - Stack[sidx], Stack[sidx+1]); + Stack[sidx], Stack[sidx + 1]); continue; default: break; @@ -1262,61 +1252,60 @@ QT_WARNING_DISABLE_MSVC(4191) Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID); continue; case 1: - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, - Stack[sidx]); + Stack[sidx] = + (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx]); continue; case 2: sidx -= 1; Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1]); + Stack[sidx + 1]); continue; case 3: sidx -= 2; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2]); continue; case 4: sidx -= 3; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3]); continue; case 5: sidx -= 4; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], - Stack[sidx+4]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4]); continue; case 6: sidx -= 5; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], - Stack[sidx+3], Stack[sidx+4], Stack[sidx+5]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5]); continue; case 7: sidx -= 6; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], - Stack[sidx+4], Stack[sidx+5], Stack[sidx+6]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5], Stack[sidx + 6]); continue; case 8: sidx -= 7; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], - Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7]); continue; case 9: sidx -= 8; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], - Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7], Stack[sidx + 8]); continue; case 10: sidx -= 9; - Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))(nOffset, nThreadID, - Stack[sidx], - Stack[sidx+1], Stack[sidx+2], Stack[sidx+3], - Stack[sidx+4], Stack[sidx+5], Stack[sidx+6], Stack[sidx+7], Stack[sidx+8], - Stack[sidx+9]); + Stack[sidx] = (*reinterpret_cast(pTok->Fun.ptr))( + nOffset, nThreadID, Stack[sidx], Stack[sidx + 1], Stack[sidx + 2], Stack[sidx + 3], + Stack[sidx + 4], Stack[sidx + 5], Stack[sidx + 6], Stack[sidx + 7], Stack[sidx + 8], + Stack[sidx + 9]); continue; default: Error(ecINTERNAL_ERROR, 2); @@ -1330,10 +1319,10 @@ QT_WARNING_DISABLE_MSVC(4191) // Q_ASSERT(INVALID_CODE_IN_BYTECODE); // continue; case cmEND: - // return Stack[m_nFinalResultIdx]; + // return Stack[m_nFinalResultIdx]; case cmPOW2: case cmUNKNOWN: - case cmBO: // unused, listed for compiler optimization purposes + case cmBO: // unused, listed for compiler optimization purposes case cmBC: // Q_ASSERT(INVALID_CODE_IN_BYTECODE); // continue; @@ -1345,7 +1334,7 @@ QT_WARNING_DISABLE_MSVC(4191) return 0; } // switch CmdCode -QT_WARNING_POP + QT_WARNING_POP } // for all bytecode tokens @@ -1362,9 +1351,9 @@ void QmuParserBase::CreateRPN() const QStack stOpt, stVal; QStack stArgCount; - token_type opta, opt; // for storing operators - //token_type val, tval; // for storing value - //string_type strBuf; // buffer for string function arguments + token_type opta, opt; // for storing operators + // token_type val, tval; // for storing value + // string_type strBuf; // buffer for string function arguments ReInit(); @@ -1383,7 +1372,7 @@ void QmuParserBase::CreateRPN() const // case cmSTRING: { - opt.SetIdx(m_vStringBuf.size()); // Assign buffer index to token + opt.SetIdx(m_vStringBuf.size()); // Assign buffer index to token stVal.push(opt); const QString &str = opt.GetAsString(); m_vStringBuf.push_back(str); // Store string in internal buffer @@ -1392,22 +1381,22 @@ void QmuParserBase::CreateRPN() const case cmVAR: { stVal.push(opt); - m_vRPN.AddVar( static_cast(opt.GetVar()) ); + m_vRPN.AddVar(static_cast(opt.GetVar())); const QString &str = opt.GetAsString(); - m_Tokens.insert(m_pTokenReader->GetPos()-str.length(), str); + m_Tokens.insert(m_pTokenReader->GetPos() - str.length(), str); break; } case cmVAL: { stVal.push(opt); - m_vRPN.AddVal( opt.GetVal() ); + m_vRPN.AddVal(opt.GetVal()); const QString &str = opt.GetAsString(); - m_Numbers.insert(m_pTokenReader->GetPos()-str.length(), str); + m_Numbers.insert(m_pTokenReader->GetPos() - str.length(), str); break; } case cmELSE: m_nIfElseCounter--; - if (m_nIfElseCounter<0) + if (m_nIfElseCounter < 0) { Error(ecMISPLACED_COLON, m_pTokenReader->GetPos()); } @@ -1436,7 +1425,7 @@ void QmuParserBase::CreateRPN() const // by default an opening bracket sets parameter count to 1 // in preparation of arguments to come. If the last token // was an opening bracket we know better... - if (opta.GetCode()==cmBO) + if (opta.GetCode() == cmBO) { --stArgCount.top(); } @@ -1444,7 +1433,7 @@ void QmuParserBase::CreateRPN() const ApplyRemainingOprt(stOpt, stVal); // Check if the bracket content has been evaluated completely - if (stOpt.size() && stOpt.top().GetCode()==cmBO) + if (stOpt.size() && stOpt.top().GetCode() == cmBO) { // if opt is ")" and opta is "(" the bracket has been evaluated, now its time to check // if there is either a function or a sign pending @@ -1457,17 +1446,17 @@ void QmuParserBase::CreateRPN() const stOpt.pop(); // Take opening bracket from stack - if (iArgCount>1 && ( stOpt.size()==0 || (stOpt.top().GetCode()!=cmFUNC && - stOpt.top().GetCode()!=cmFUNC_BULK && - stOpt.top().GetCode()!=cmFUNC_STR) ) ) + if (iArgCount > 1 && (stOpt.size() == 0 || + (stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK && + stOpt.top().GetCode() != cmFUNC_STR))) { Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); } // The opening bracket was popped from the stack now check if there // was a function before this bracket - if (stOpt.size() && stOpt.top().GetCode()!=cmOPRT_INFIX && stOpt.top().GetCode()!=cmOPRT_BIN && - stOpt.top().GetFuncAddr()!=nullptr) + if (stOpt.size() && stOpt.top().GetCode() != cmOPRT_INFIX && stOpt.top().GetCode() != cmOPRT_BIN && + stOpt.top().GetFuncAddr() != nullptr) { ApplyFunc(stOpt, stVal, iArgCount); } @@ -1477,9 +1466,9 @@ void QmuParserBase::CreateRPN() const // // Next are the binary operator entries // - //case cmAND: // built in binary operators - //case cmOR: - //case cmXOR: + // case cmAND: // built in binary operators + // case cmOR: + // case cmXOR: case cmIF: m_nIfElseCounter++; // fallthrough intentional (no break!) @@ -1500,20 +1489,18 @@ void QmuParserBase::CreateRPN() const case cmASSIGN: case cmOPRT_BIN: // A binary operator (user defined or built in) has been found. - while ( stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmELSE && - stOpt.top().GetCode() != cmIF) + while (stOpt.size() && stOpt.top().GetCode() != cmBO && stOpt.top().GetCode() != cmELSE && + stOpt.top().GetCode() != cmIF) { const token_type &topToken = stOpt.top(); - int nPrec1 = GetOprtPrecedence(topToken), - nPrec2 = GetOprtPrecedence(opt); + int nPrec1 = GetOprtPrecedence(topToken), nPrec2 = GetOprtPrecedence(opt); const ECmdCode code = topToken.GetCode(); - if (code==opt.GetCode()) + if (code == opt.GetCode()) { // Deal with operator associativity EOprtAssociativity eOprtAsct = GetOprtAssociativity(opt); - if ( (eOprtAsct==oaRIGHT && (nPrec1 <= nPrec2)) || - (eOprtAsct==oaLEFT && (nPrec1 < nPrec2)) ) + if ((eOprtAsct == oaRIGHT && (nPrec1 <= nPrec2)) || (eOprtAsct == oaLEFT && (nPrec1 < nPrec2))) { break; } @@ -1523,7 +1510,7 @@ void QmuParserBase::CreateRPN() const // In case the operators are not equal the precedence decides alone... break; } - if (code==cmOPRT_INFIX) + if (code == cmOPRT_INFIX) { ApplyFunc(stOpt, stVal, 1); } @@ -1533,12 +1520,12 @@ void QmuParserBase::CreateRPN() const } } // while ( ... ) - if (opt.GetCode()==cmIF) + if (opt.GetCode() == cmIF) { m_vRPN.AddIfElse(opt.GetCode()); } - // The operator can't be evaluated right now, push back to the operator stack + // The operator can't be evaluated right now, push back to the operator stack stOpt.push(opt); break; // @@ -1553,12 +1540,12 @@ void QmuParserBase::CreateRPN() const case cmFUNC_BULK: case cmFUNC_STR: stOpt.push(opt); - m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + m_Tokens.insert(m_pTokenReader->GetPos() - opt.GetAsString().length(), opt.GetAsString()); break; case cmOPRT_POSTFIX: stOpt.push(opt); - ApplyFunc(stOpt, stVal, 1); // this is the postfix operator - m_Tokens.insert(m_pTokenReader->GetPos()-opt.GetAsString().length(), opt.GetAsString()); + ApplyFunc(stOpt, stVal, 1); // this is the postfix operator + m_Tokens.insert(m_pTokenReader->GetPos() - opt.GetAsString().length(), opt.GetAsString()); break; case cmENDIF: case cmVARPOW2: @@ -1573,7 +1560,7 @@ void QmuParserBase::CreateRPN() const opta = opt; - if ( opt.GetCode() == cmEND ) + if (opt.GetCode() == cmEND) { m_vRPN.Finalize(); break; @@ -1591,25 +1578,25 @@ void QmuParserBase::CreateRPN() const m_vRPN.AsciiDump(); } - if (m_nIfElseCounter>0) + if (m_nIfElseCounter > 0) { Error(ecMISSING_ELSE_CLAUSE); } // get the last value (= final result) from the stack - Q_ASSERT(stArgCount.size()==1); + Q_ASSERT(stArgCount.size() == 1); m_nFinalResultIdx = stArgCount.top(); - if (m_nFinalResultIdx==0) + if (m_nFinalResultIdx == 0) { Error(ecINTERNAL_ERROR, 9); } - if (stVal.size()==0) + if (stVal.size() == 0) { Error(ecEMPTY_EXPRESSION); } - if (stVal.top().GetType()!=tpDBL) + if (stVal.top().GetType() != tpDBL) { Error(ecSTR_RESULT); } @@ -1643,18 +1630,18 @@ auto QmuParserBase::ParseString() const -> qreal //--------------------------------------------------------------------------------------------------------------------- /** -* @brief Create an error containing the parse error position. -* -* This function will create an Parser Exception object containing the error text and its position. -* -* @param a_iErrc [in] The error code of type #EErrorCodes. -* @param a_iPos [in] The position where the error was detected. -* @param a_sTok [in] The token string representation associated with the error. -* @throw ParserException always throws thats the only purpose of this function. -*/ + * @brief Create an error containing the parse error position. + * + * This function will create an Parser Exception object containing the error text and its position. + * + * @param a_iErrc [in] The error code of type #EErrorCodes. + * @param a_iPos [in] The position where the error was detected. + * @param a_sTok [in] The token string representation associated with the error. + * @throw ParserException always throws thats the only purpose of this function. + */ Q_NORETURN void QmuParserBase::Error(EErrorCodes a_iErrc, qmusizetype a_iPos, const QString &a_sTok) const { - throw qmu::QmuParserError (a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); + throw qmu::QmuParserError(a_iErrc, a_sTok, m_pTokenReader->GetExpr(), a_iPos); } //--------------------------------------------------------------------------------------------------------------------- @@ -1681,7 +1668,7 @@ void QmuParserBase::ClearVar() void QmuParserBase::RemoveVar(const QString &a_strVarName) { varmap_type::iterator item = m_VarDef.find(a_strVarName); - if (item!=m_VarDef.end()) + if (item != m_VarDef.end()) { m_VarDef.erase(item); ReInit(); @@ -1778,7 +1765,7 @@ void QmuParserBase::EnableOptimizer(bool a_bIsOn) void QmuParserBase::EnableDebugDump(bool bDumpCmd, bool bDumpStack) { QmuParserBase::g_DbgDumpCmdCode = bDumpCmd; - QmuParserBase::g_DbgDumpStack = bDumpStack; + QmuParserBase::g_DbgDumpStack = bDumpStack; } //--------------------------------------------------------------------------------------------------------------------- @@ -1824,14 +1811,13 @@ void QmuParserBase::SetArgSep(char_type cArgSep) */ void QmuParserBase::StackDump(const QStack &a_stVal, const QStack &a_stOprt) const { - QStack stOprt(a_stOprt), - stVal(a_stVal); + QStack stOprt(a_stOprt), stVal(a_stVal); qDebug() << "\nValue stack:\n"; - while ( stVal.empty() == false ) + while (stVal.empty() == false) { token_type val = stVal.pop(); - if (val.GetType()==tpSTR) + if (val.GetType() == tpSTR) { qDebug() << " \"" << val.GetAsString() << "\" "; } @@ -1842,16 +1828,16 @@ void QmuParserBase::StackDump(const QStack &a_stVal, const QStack &a_stVal, const QStack qreal * { (this->*m_pParseFormula)(); @@ -1929,52 +1915,52 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const int i = 0; - #ifdef QMUP_USE_OPENMP - //#define DEBUG_OMP_STUFF - #ifdef DEBUG_OMP_STUFF - int *pThread = new int[nBulkSize]; - int *pIdx = new int[nBulkSize]; - #endif +#ifdef QMUP_USE_OPENMP +// #define DEBUG_OMP_STUFF +#ifdef DEBUG_OMP_STUFF + int *pThread = new int[nBulkSize]; + int *pIdx = new int[nBulkSize]; +#endif int nMaxThreads = qMin(omp_get_max_threads(), s_MaxNumOpenMPThreads); - int ct=0; + int ct = 0; omp_set_num_threads(nMaxThreads); - #pragma omp parallel for schedule(static, nBulkSize/nMaxThreads) private(nThreadID) - for (i=0; i QmuParserBase &; virtual ~QmuParserBase(); diff --git a/src/libs/qmuparser/qmuparsererror.cpp b/src/libs/qmuparser/qmuparsererror.cpp index d5de4c738..65756b153 100644 --- a/src/libs/qmuparser/qmuparsererror.cpp +++ b/src/libs/qmuparser/qmuparsererror.cpp @@ -27,132 +27,104 @@ namespace qmu { -const QmuParserErrorMsg QmuParserErrorMsg::m_Instance; - -//--------------------------------------------------------------------------------------------------------------------- -QmuParserErrorMsg::~QmuParserErrorMsg() -{} - #define translate(context, source, disambiguation) QmuTranslation::translate((context), (source), (disambiguation)) //--------------------------------------------------------------------------------------------------------------------- QmuParserErrorMsg::QmuParserErrorMsg() - : m_vErrMsg () { - m_vErrMsg.clear(); - m_vErrMsg.insert(ecUNASSIGNABLE_TOKEN, translate("QmuParserErrorMsg", "Unexpected token \"$TOK$\" found at position $POS$.", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); - m_vErrMsg.insert(ecINTERNAL_ERROR, - translate("QmuParserErrorMsg", "Internal error", - "Math parser error messages.")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecINTERNAL_ERROR, translate("QmuParserErrorMsg", "Internal error", "Math parser error messages.")); m_vErrMsg.insert(ecINVALID_NAME, translate("QmuParserErrorMsg", "Invalid function-, variable- or constant name: \"$TOK$\".", - "Math parser error messages. Left untouched \"$TOK$\"")); + "Math parser error messages. Left untouched \"$TOK$\"")); m_vErrMsg.insert(ecINVALID_BINOP_IDENT, translate("QmuParserErrorMsg", "Invalid binary operator identifier: \"$TOK$\".", - "Math parser error messages. Left untouched \"$TOK$\"")); + "Math parser error messages. Left untouched \"$TOK$\"")); m_vErrMsg.insert(ecINVALID_INFIX_IDENT, translate("QmuParserErrorMsg", "Invalid infix operator identifier: \"$TOK$\".", - "Math parser error messages. Left untouched \"$TOK$\"")); + "Math parser error messages. Left untouched \"$TOK$\"")); m_vErrMsg.insert(ecINVALID_POSTFIX_IDENT, translate("QmuParserErrorMsg", "Invalid postfix operator identifier: \"$TOK$\".", - "Math parser error messages. Left untouched \"$TOK$\"")); - m_vErrMsg.insert(ecINVALID_FUN_PTR, - translate("QmuParserErrorMsg", "Invalid pointer to callback function.", - "Math parser error messages.")); + "Math parser error messages. Left untouched \"$TOK$\"")); + m_vErrMsg.insert(ecINVALID_FUN_PTR, translate("QmuParserErrorMsg", "Invalid pointer to callback function.", + "Math parser error messages.")); m_vErrMsg.insert(ecEMPTY_EXPRESSION, - translate("QmuParserErrorMsg", "Expression is empty.", - "Math parser error messages.")); + translate("QmuParserErrorMsg", "Expression is empty.", "Math parser error messages.")); m_vErrMsg.insert(ecINVALID_VAR_PTR, - translate("QmuParserErrorMsg", "Invalid pointer to variable.", - "Math parser error messages.")); + translate("QmuParserErrorMsg", "Invalid pointer to variable.", "Math parser error messages.")); m_vErrMsg.insert(ecUNEXPECTED_OPERATOR, translate("QmuParserErrorMsg", "Unexpected operator \"$TOK$\" found at position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); - m_vErrMsg.insert(ecUNEXPECTED_EOF, - translate("QmuParserErrorMsg", "Unexpected end of expression at position $POS$", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_EOF, translate("QmuParserErrorMsg", "Unexpected end of expression at position $POS$", + "Math parser error messages. Left untouched $POS$")); m_vErrMsg.insert(ecUNEXPECTED_ARG_SEP, translate("QmuParserErrorMsg", "Unexpected argument separator at position $POS$", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Left untouched $POS$")); m_vErrMsg.insert(ecUNEXPECTED_PARENS, translate("QmuParserErrorMsg", "Unexpected parenthesis \"$TOK$\" at position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); - m_vErrMsg.insert(ecUNEXPECTED_FUN, - translate("QmuParserErrorMsg", "Unexpected function \"$TOK$\" at position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecUNEXPECTED_FUN, translate("QmuParserErrorMsg", "Unexpected function \"$TOK$\" at position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); m_vErrMsg.insert(ecUNEXPECTED_VAL, translate("QmuParserErrorMsg", "Unexpected value \"$TOK$\" found at position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); m_vErrMsg.insert(ecUNEXPECTED_VAR, translate("QmuParserErrorMsg", "Unexpected variable \"$TOK$\" found at position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); m_vErrMsg.insert(ecUNEXPECTED_ARG, translate("QmuParserErrorMsg", "Function arguments used without a function (position: $POS$)", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Left untouched $POS$")); m_vErrMsg.insert(ecMISSING_PARENS, - translate("QmuParserErrorMsg", "Missing parenthesis", - "Math parser error messages.")); + translate("QmuParserErrorMsg", "Missing parenthesis", "Math parser error messages.")); m_vErrMsg.insert(ecTOO_MANY_PARAMS, translate("QmuParserErrorMsg", - "Too many parameters for function \"$TOK$\" at expression position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + "Too many parameters for function \"$TOK$\" at expression position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); m_vErrMsg.insert(ecTOO_FEW_PARAMS, translate("QmuParserErrorMsg", - "Too few parameters for function \"$TOK$\" at expression position $POS$", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); - m_vErrMsg.insert(ecDIV_BY_ZERO, - translate("QmuParserErrorMsg", "Divide by zero", - "Math parser error messages.")); - m_vErrMsg.insert(ecDOMAIN_ERROR, - translate("QmuParserErrorMsg", "Domain error", - "Math parser error messages.")); - m_vErrMsg.insert(ecNAME_CONFLICT, - translate("QmuParserErrorMsg", "Name conflict", - "Math parser error messages.")); - m_vErrMsg.insert(ecOPT_PRI, - translate("QmuParserErrorMsg", - "Invalid value for operator priority (must be greater or equal to zero).", - "Math parser error messages.")); + "Too few parameters for function \"$TOK$\" at expression position $POS$", + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + m_vErrMsg.insert(ecDIV_BY_ZERO, translate("QmuParserErrorMsg", "Divide by zero", "Math parser error messages.")); + m_vErrMsg.insert(ecDOMAIN_ERROR, translate("QmuParserErrorMsg", "Domain error", "Math parser error messages.")); + m_vErrMsg.insert(ecNAME_CONFLICT, translate("QmuParserErrorMsg", "Name conflict", "Math parser error messages.")); + m_vErrMsg.insert(ecOPT_PRI, translate("QmuParserErrorMsg", + "Invalid value for operator priority (must be greater or equal to zero).", + "Math parser error messages.")); m_vErrMsg.insert(ecBUILTIN_OVERLOAD, translate("QmuParserErrorMsg", - "user defined binary operator \"$TOK$\" conflicts with a built in operator.", - "Math parser error messages. Left untouched \"$TOK$\"")); + "user defined binary operator \"$TOK$\" conflicts with a built in operator.", + "Math parser error messages. Left untouched \"$TOK$\"")); m_vErrMsg.insert(ecUNEXPECTED_STR, translate("QmuParserErrorMsg", "Unexpected string token found at position $POS$.", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Left untouched $POS$")); m_vErrMsg.insert(ecUNTERMINATED_STRING, translate("QmuParserErrorMsg", "Unterminated string starting at position $POS$.", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Left untouched $POS$")); m_vErrMsg.insert(ecSTRING_EXPECTED, translate("QmuParserErrorMsg", "String function called with a non string type of argument.", - "Math parser error messages.")); + "Math parser error messages.")); m_vErrMsg.insert(ecVAL_EXPECTED, translate("QmuParserErrorMsg", "String value used where a numerical argument is expected.", - "Math parser error messages.")); + "Math parser error messages.")); m_vErrMsg.insert(ecOPRT_TYPE_CONFLICT, translate("QmuParserErrorMsg", "No suitable overload for operator \"$TOK$\" at position $POS$.", - "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); + "Math parser error messages. Left untouched \"$TOK$\" and $POS$")); m_vErrMsg.insert(ecSTR_RESULT, - translate("QmuParserErrorMsg", "Function result is a string.", - "Math parser error messages.")); - m_vErrMsg.insert(ecGENERIC, - translate("QmuParserErrorMsg", "Parser error.", - "Math parser error messages.")); + translate("QmuParserErrorMsg", "Function result is a string.", "Math parser error messages.")); + m_vErrMsg.insert(ecGENERIC, translate("QmuParserErrorMsg", "Parser error.", "Math parser error messages.")); m_vErrMsg.insert(ecLOCALE, translate("QmuParserErrorMsg", "Decimal separator is identic to function argument separator.", - "Math parser error messages.")); + "Math parser error messages.")); m_vErrMsg.insert(ecUNEXPECTED_CONDITIONAL, translate("QmuParserErrorMsg", "The \"$TOK$\" operator must be preceeded by a closing bracket.", - "Math parser error messages. Left untouched \"$TOK$\"")); + "Math parser error messages. Left untouched \"$TOK$\"")); m_vErrMsg.insert(ecMISSING_ELSE_CLAUSE, translate("QmuParserErrorMsg", "If-then-else operator is missing an else clause", - "Math parser error messages. Do not translate operator name.")); - m_vErrMsg.insert(ecMISPLACED_COLON, - translate("QmuParserErrorMsg", "Misplaced colon at position $POS$", - "Math parser error messages. Left untouched $POS$")); + "Math parser error messages. Do not translate operator name.")); + m_vErrMsg.insert(ecMISPLACED_COLON, translate("QmuParserErrorMsg", "Misplaced colon at position $POS$", + "Math parser error messages. Left untouched $POS$")); } #undef translate @@ -167,9 +139,15 @@ QmuParserErrorMsg::QmuParserErrorMsg() * @brief Default constructor. */ QmuParserError::QmuParserError() - : QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) -{} + : QException(), + m_sMsg(), + m_sExpr(), + m_sTok(), + m_iPos(-1), + m_iErrc(ecUNDEFINED), + m_ErrMsg(QmuParserErrorMsg::Instance()) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** @@ -177,23 +155,34 @@ QmuParserError::QmuParserError() * * It does not contain any information but the error code. */ -QmuParserError::QmuParserError ( EErrorCodes a_iErrc ) - : QException(), m_sMsg(), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( a_iErrc ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) +QmuParserError::QmuParserError(EErrorCodes a_iErrc) + : QException(), + m_sMsg(), + m_sExpr(), + m_sTok(), + m_iPos(-1), + m_iErrc(a_iErrc), + m_ErrMsg(QmuParserErrorMsg::Instance()) { m_sMsg = m_ErrMsg[m_iErrc]; - m_sMsg.replace("$POS$", QString().setNum ( m_iPos )); - m_sMsg.replace("$TOK$", m_sTok ); + m_sMsg.replace("$POS$", QString().setNum(m_iPos)); + m_sMsg.replace("$TOK$", m_sTok); } //--------------------------------------------------------------------------------------------------------------------- /** * @brief Construct an error from a message text. */ -QmuParserError::QmuParserError ( const QString &sMsg ) - : QException(), m_sMsg(sMsg), m_sExpr(), m_sTok(), m_iPos ( -1 ), m_iErrc ( ecUNDEFINED ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) -{} +QmuParserError::QmuParserError(const QString &sMsg) + : QException(), + m_sMsg(sMsg), + m_sExpr(), + m_sTok(), + m_iPos(-1), + m_iErrc(ecUNDEFINED), + m_ErrMsg(QmuParserErrorMsg::Instance()) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** @@ -203,13 +192,18 @@ QmuParserError::QmuParserError ( const QString &sMsg ) * @param [in] sExpr The expression related to the error. * @param [in] iPos the position in the expression where the error occured. */ -QmuParserError::QmuParserError (EErrorCodes iErrc, const QString &sTok, const QString &sExpr, qmusizetype iPos ) - : QException(), m_sMsg(), m_sExpr ( sExpr ), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( iErrc ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) +QmuParserError::QmuParserError(EErrorCodes iErrc, const QString &sTok, const QString &sExpr, qmusizetype iPos) + : QException(), + m_sMsg(), + m_sExpr(sExpr), + m_sTok(sTok), + m_iPos(iPos), + m_iErrc(iErrc), + m_ErrMsg(QmuParserErrorMsg::Instance()) { m_sMsg = m_ErrMsg[m_iErrc]; - m_sMsg.replace("$POS$", QString().setNum ( m_iPos )); - m_sMsg.replace("$TOK$", m_sTok ); + m_sMsg.replace("$POS$", QString().setNum(m_iPos)); + m_sMsg.replace("$TOK$", m_sTok); } //--------------------------------------------------------------------------------------------------------------------- @@ -219,43 +213,59 @@ QmuParserError::QmuParserError (EErrorCodes iErrc, const QString &sTok, const QS * @param [in] a_iPos the position in the expression where the error occured. * @param [in] sTok The token string related to this error. */ -QmuParserError::QmuParserError ( EErrorCodes a_iErrc, int a_iPos, const QString &sTok ) - : QException(), m_sMsg(), m_sExpr(), m_sTok ( sTok ), m_iPos ( a_iPos ), m_iErrc ( a_iErrc ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) +QmuParserError::QmuParserError(EErrorCodes a_iErrc, int a_iPos, const QString &sTok) + : QException(), + m_sMsg(), + m_sExpr(), + m_sTok(sTok), + m_iPos(a_iPos), + m_iErrc(a_iErrc), + m_ErrMsg(QmuParserErrorMsg::Instance()) { m_sMsg = m_ErrMsg[m_iErrc]; - m_sMsg.replace("$POS$", QString().setNum ( m_iPos )); - m_sMsg.replace("$TOK$", m_sTok ); + m_sMsg.replace("$POS$", QString().setNum(m_iPos)); + m_sMsg.replace("$TOK$", m_sTok); } //--------------------------------------------------------------------------------------------------------------------- /** @brief Construct an error object. - * @param [in] szMsg The error message text. - * @param [in] iPos the position related to the error. - * @param [in] sTok The token string related to this error. - */ -QmuParserError::QmuParserError ( const QString &szMsg, int iPos, const QString &sTok ) - : QException(), m_sMsg ( szMsg ), m_sExpr(), m_sTok ( sTok ), m_iPos ( iPos ), m_iErrc ( ecGENERIC ), - m_ErrMsg ( QmuParserErrorMsg::Instance() ) + * @param [in] szMsg The error message text. + * @param [in] iPos the position related to the error. + * @param [in] sTok The token string related to this error. + */ +QmuParserError::QmuParserError(const QString &szMsg, int iPos, const QString &sTok) + : QException(), + m_sMsg(szMsg), + m_sExpr(), + m_sTok(sTok), + m_iPos(iPos), + m_iErrc(ecGENERIC), + m_ErrMsg(QmuParserErrorMsg::Instance()) { - m_sMsg.replace("$POS$", QString().setNum ( m_iPos )); - m_sMsg.replace("$TOK$", m_sTok ); + m_sMsg.replace("$POS$", QString().setNum(m_iPos)); + m_sMsg.replace("$TOK$", m_sTok); } //--------------------------------------------------------------------------------------------------------------------- /** * @brief Copy constructor. */ -QmuParserError::QmuParserError ( const QmuParserError &a_Obj ) - : QException(), m_sMsg ( a_Obj.m_sMsg ), m_sExpr ( a_Obj.m_sExpr ), m_sTok ( a_Obj.m_sTok ), - m_iPos ( a_Obj.m_iPos ), m_iErrc ( a_Obj.m_iErrc ), m_ErrMsg ( QmuParserErrorMsg::Instance() ) -{} +QmuParserError::QmuParserError(const QmuParserError &a_Obj) + : QException(), + m_sMsg(a_Obj.m_sMsg), + m_sExpr(a_Obj.m_sExpr), + m_sTok(a_Obj.m_sTok), + m_iPos(a_Obj.m_iPos), + m_iErrc(a_Obj.m_iErrc), + m_ErrMsg(QmuParserErrorMsg::Instance()) +{ +} //--------------------------------------------------------------------------------------------------------------------- /** @brief Assignment operator. */ auto QmuParserError::operator=(const QmuParserError &a_Obj) -> QmuParserError & { - if ( this == &a_Obj ) + if (this == &a_Obj) { return *this; } @@ -303,18 +313,22 @@ auto QmuParserError::clone() const -> QmuParserError * //--------------------------------------------------------------------------------------------------------------------- QmuParserWarning::QmuParserWarning(const QString &sMsg) - : QException(), m_sMsg ( sMsg ) -{} + : QException(), + m_sMsg(sMsg) +{ +} //--------------------------------------------------------------------------------------------------------------------- QmuParserWarning::QmuParserWarning(const QmuParserWarning &a_Obj) - : QException(), m_sMsg(a_Obj.m_sMsg) -{} + : QException(), + m_sMsg(a_Obj.m_sMsg) +{ +} //--------------------------------------------------------------------------------------------------------------------- auto QmuParserWarning::operator=(const QmuParserWarning &a_Obj) -> QmuParserWarning & { - if ( this == &a_Obj ) + if (this == &a_Obj) { return *this; } diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 46eadc7a5..ee3a0ee3d 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -104,10 +104,10 @@ enum EErrorCodes class QMUPARSERSHARED_EXPORT QmuParserErrorMsg { public: - typedef QmuParserErrorMsg self_type; + using self_type = QmuParserErrorMsg; QmuParserErrorMsg(); - ~QmuParserErrorMsg(); + ~QmuParserErrorMsg() = default; static auto Instance() -> const QmuParserErrorMsg &; auto operator[](int a_iIdx) const -> QString; @@ -115,7 +115,7 @@ public: private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(QmuParserErrorMsg) // NOLINT - QMap m_vErrMsg; ///< A map with the predefined error messages + QMap m_vErrMsg{}; ///< A map with the predefined error messages }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmutranslation.cpp b/src/libs/qmuparser/qmutranslation.cpp index 56a1cb804..87b9c7f53 100644 --- a/src/libs/qmuparser/qmutranslation.cpp +++ b/src/libs/qmuparser/qmutranslation.cpp @@ -20,7 +20,6 @@ ******************************************************************************************************/ #include "qmutranslation.h" -#include "qmuparserdef.h" #include #include @@ -37,29 +36,36 @@ auto QmuTranslation::translate(const char *context, const char *sourceText, cons { n = -1; } - QmuTranslation t(context, sourceText, disambiguation, n); - return t; + + return {context, sourceText, disambiguation, n}; } //--------------------------------------------------------------------------------------------------------------------- QmuTranslation::QmuTranslation() - : mcontext(), msourceText(), mdisambiguation(), mn(-1), localeName(), cachedTranslation() -{} + : mcontext(), + msourceText(), + mdisambiguation(), + mn(-1), + localeName(), + cachedTranslation() +{ +} //--------------------------------------------------------------------------------------------------------------------- QmuTranslation::QmuTranslation(const QString &context, const QString &sourceText, const QString &disambiguation, int n) - : mcontext(context), - msourceText(sourceText), - mdisambiguation(disambiguation), - mn(n), - localeName(), - cachedTranslation() -{} + : mcontext(context), + msourceText(sourceText), + mdisambiguation(disambiguation), + mn(n), + localeName(), + cachedTranslation() +{ +} //--------------------------------------------------------------------------------------------------------------------- auto QmuTranslation::operator=(const QmuTranslation &tr) -> QmuTranslation & { - if ( &tr == this ) + if (&tr == this) { return *this; } @@ -74,13 +80,14 @@ auto QmuTranslation::operator=(const QmuTranslation &tr) -> QmuTranslation & //--------------------------------------------------------------------------------------------------------------------- QmuTranslation::QmuTranslation(const QmuTranslation &tr) - : mcontext(tr.mcontext), - msourceText(tr.msourceText), - mdisambiguation(tr.mdisambiguation), - mn(tr.mn), - localeName(), - cachedTranslation() -{} + : mcontext(tr.mcontext), + msourceText(tr.msourceText), + mdisambiguation(tr.mdisambiguation), + mn(tr.mn), + localeName(), + cachedTranslation() +{ +} //--------------------------------------------------------------------------------------------------------------------- auto QmuTranslation::translate(const QString &locale) const -> QString diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 84ca35b69..635caec19 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -27,53 +27,53 @@ *************************************************************************/ #include "vpatternrecipe.h" +#include "../ifc/exception/vexceptioninvalidhistory.h" +#include "../ifc/xml/vabstractpattern.h" +#include "../vgeometry/vcubicbezier.h" +#include "../vgeometry/vcubicbezierpath.h" +#include "../vgeometry/vpointf.h" +#include "../vgeometry/vsplinepath.h" #include "../vmisc/projectversion.h" #include "../vmisc/vabstractvalapplication.h" -#include "../ifc/xml/vabstractpattern.h" -#include "../ifc/exception/vexceptioninvalidhistory.h" -#include "../vpatterndb/vcontainer.h" -#include "../vgeometry/vpointf.h" -#include "../vgeometry/vcubicbezier.h" -#include "../vgeometry/vsplinepath.h" -#include "../vgeometry/vcubicbezierpath.h" #include "../vpatterndb/calculator.h" #include "../vpatterndb/variables/vincrement.h" #include "../vpatterndb/variables/vmeasurement.h" +#include "../vpatterndb/vcontainer.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" +#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" +#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/operation/vtoolrotation.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarc.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" #include "../vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h" -#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" #include "../vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h" -#include "../vtools/tools/drawTools/vtoolline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolspline.h" +#include "../vtools/tools/drawTools/toolcurve/vtoolsplinepath.h" +#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h" -#include "../vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h" -#include "../vtools/tools/drawTools/operation/vtoolrotation.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h" -#include "../vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h" -#include "../vtools/tools/drawTools/operation/vtoolmove.h" +#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h" +#include "../vtools/tools/drawTools/vtoolline.h" namespace { @@ -103,19 +103,19 @@ inline auto FileComment() -> QString //--------------------------------------------------------------------------------------------------------------------- template auto GetPatternTool(quint32 id) -> T * { - T* tool = qobject_cast(VAbstractPattern::getTool(id)); + T *tool = qobject_cast(VAbstractPattern::getTool(id)); if (not tool) { throw VExceptionInvalidHistory(QObject::tr("Cannot cast tool with id '%1'.").arg(id)); } return tool; } -} // namespace +} // namespace //--------------------------------------------------------------------------------------------------------------------- VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent) - : VDomDocument(parent), - m_pattern(pattern) + : VDomDocument(parent), + m_pattern(pattern) { SCASSERT(pattern != nullptr) @@ -127,8 +127,9 @@ VPatternRecipe::VPatternRecipe(VAbstractPattern *pattern, QObject *parent) recipeElement.appendChild(Content()); appendChild(recipeElement); - insertBefore(createProcessingInstruction(QStringLiteral("xml"), - QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), firstChild()); + insertBefore( + createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), + firstChild()); } //--------------------------------------------------------------------------------------------------------------------- @@ -150,8 +151,8 @@ auto VPatternRecipe::Prerequisite() -> QDomElement QDomElement prerequisiteElement = createElement(QStringLiteral("prerequisite")); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("valentina"), AppVersionStr())); - prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("unit"), - UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); + prerequisiteElement.appendChild( + CreateElementWithText(QStringLiteral("unit"), UnitsToStr(VAbstractValApplication::VApp()->patternUnits()))); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("author"), m_pattern->GetCompanyName())); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("pattenName"), m_pattern->GetPatternName())); prerequisiteElement.appendChild(CreateElementWithText(QStringLiteral("description"), m_pattern->GetDescription())); @@ -174,9 +175,9 @@ auto VPatternRecipe::Measurements() -> QDomElement // Resore order std::sort(patternMeasurements.begin(), patternMeasurements.end(), [](const QSharedPointer &a, const QSharedPointer &b) - {return a->Index() < b->Index();}); + { return a->Index() < b->Index(); }); - for(auto &m : patternMeasurements) + for (auto &m : patternMeasurements) { measurements.appendChild(Measurement(m)); } @@ -231,9 +232,9 @@ auto VPatternRecipe::Increments() -> QDomElement // Resore order std::sort(patternIncrements.begin(), patternIncrements.end(), [](const QSharedPointer &a, const QSharedPointer &b) - {return a->GetIndex() < b->GetIndex();}); + { return a->GetIndex() < b->GetIndex(); }); - for(auto &incr : patternIncrements) + for (auto &incr : patternIncrements) { if (not incr->IsPreviewCalculation()) { @@ -255,9 +256,9 @@ auto VPatternRecipe::PreviewCalculations() -> QDomElement // Resore order std::sort(patternIncrements.begin(), patternIncrements.end(), [](const QSharedPointer &a, const QSharedPointer &b) - {return a->GetIndex() < b->GetIndex();}); + { return a->GetIndex() < b->GetIndex(); }); - for(auto &incr : patternIncrements) + for (auto &incr : patternIncrements) { if (incr->IsPreviewCalculation()) { @@ -295,7 +296,7 @@ auto VPatternRecipe::Content() -> QDomElement QDomElement content = createElement(QStringLiteral("content")); const QDomNodeList draws = m_pattern->documentElement().elementsByTagName(VAbstractPattern::TagDraw); - for (int i=0; i < draws.size(); ++i) + for (int i = 0; i < draws.size(); ++i) { QDomElement draw = draws.at(i).toElement(); if (draw.isNull()) @@ -350,8 +351,8 @@ auto VPatternRecipe::Step(const VToolRecord &tool, const VContainer &data) -> QD } try { -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wswitch-default") + QT_WARNING_PUSH + QT_WARNING_DISABLE_GCC("-Wswitch-default") switch (tool.getTypeTool()) { case Tool::Arrow: @@ -360,8 +361,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case Tool::LinePoint: case Tool::AbstractSpline: case Tool::Cut: - case Tool::Midpoint:// Same as Tool::AlongLine, but tool will never has such type - case Tool::ArcIntersectAxis:// Same as Tool::CurveIntersectAxis, but tool will never has such type + case Tool::Midpoint: // Same as Tool::AlongLine, but tool will never has such type + case Tool::ArcIntersectAxis: // Same as Tool::CurveIntersectAxis, but tool will never has such type case Tool::BackgroundImage: case Tool::BackgroundImageControls: case Tool::BackgroundPixmapImage: @@ -437,8 +438,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") return FlippingByAxis(tool, data); case Tool::Move: return Move(tool, data); - //Because "history" not only show history of pattern, but help restore current data for each pattern's - //piece, we need add record about details and nodes, but don't show them. + // Because "history" not only show history of pattern, but help restore current data for each pattern's + // piece, we need add record about details and nodes, but don't show them. case Tool::Piece: case Tool::UnionDetails: case Tool::NodeArc: @@ -454,7 +455,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case Tool::DuplicateDetail: return QDomElement(); } -QT_WARNING_POP + QT_WARNING_POP } catch (const VExceptionBadId &e) { @@ -495,20 +496,22 @@ auto VPatternRecipe::FinalMeasurement(const VFinalMeasurement &fm, const VContai const qreal result = cal->EvalFormula(data.DataVariables(), fm.formula); if (qIsInf(result) || qIsNaN(result)) { - const QString errorMsg = QString("%1\n\n%1").arg(tr("Reading final measurements error."), - tr("Value for final measurtement '%1' is infinite or NaN. " - "Please, check your calculations.").arg(fm.name)); - VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) - : qWarning() - << VAbstractValApplication::warningMessageSignature + errorMsg; + const QString errorMsg = QString("%1\n\n%1") + .arg(tr("Reading final measurements error."), + tr("Value for final measurtement '%1' is infinite or NaN. " + "Please, check your calculations.") + .arg(fm.name)); + VAbstractApplication::VApp()->IsPedantic() + ? throw VException(errorMsg) + : qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } SetAttribute(recipeFinalMeasurement, QStringLiteral("value"), result); } catch (const qmu::QmuParserError &e) { - throw VExceptionInvalidHistory(tr("Unable to create record for final measurement '%1'. Error: %2") - .arg(fm.name).arg(e.GetMsg())); + throw VExceptionInvalidHistory( + tr("Unable to create record for final measurement '%1'. Error: %2").arg(fm.name).arg(e.GetMsg())); } return recipeFinalMeasurement; @@ -1142,14 +1145,14 @@ auto VPatternRecipe::Move(const VToolRecord &record, const VContainer &data) -> //--------------------------------------------------------------------------------------------------------------------- inline void VPatternRecipe::Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr, - const QString &formulaValue) + const QString &formulaValue) { if (formula.error()) { throw VExceptionInvalidHistory(QObject::tr("Invalid formula '%1' for tool with id '%2'. %3.") - .arg(formula.GetFormula(FormulaType::ToSystem)) - .arg(formula.getToolId()) - .arg(formula.Reason())); + .arg(formula.GetFormula(FormulaType::ToSystem)) + .arg(formula.getToolId()) + .arg(formula.Reason())); } SetAttribute(step, formulaStr, formula.GetFormula(FormulaType::ToSystem)); @@ -1157,39 +1160,34 @@ inline void VPatternRecipe::Formula(QDomElement &step, const VFormula &formula, } //--------------------------------------------------------------------------------------------------------------------- -template -inline void VPatternRecipe::LineAttributes(QDomElement &step, T *tool) +template inline void VPatternRecipe::LineAttributes(QDomElement &step, T *tool) { SetAttribute(step, AttrLineColor, tool->GetLineColor()); SetAttribute(step, AttrTypeLine, tool->getLineType()); } //--------------------------------------------------------------------------------------------------------------------- -template -void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool) +template void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool) { SetAttribute(step, AttrLineColor, tool->GetLineColor()); SetAttribute(step, AttrPenStyle, tool->GetPenStyle()); SetAttribute(step, AttrAScale, tool->GetApproximationScale()); SetAttribute(step, AttrDuplicate, tool->GetDuplicate()); SetAttributeOrRemoveIf(step, AttrAlias, tool->GetAliasSuffix(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); } - //--------------------------------------------------------------------------------------------------------------------- -template -void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) +template void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) { SetAttributeOrRemoveIf(step, AttrAlias1, tool->GetAliasSuffix1(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); SetAttributeOrRemoveIf(step, AttrAlias2, tool->GetAliasSuffix2(), - [](const QString &suffix) noexcept {return suffix.isEmpty();}); + [](const QString &suffix) noexcept { return suffix.isEmpty(); }); } //--------------------------------------------------------------------------------------------------------------------- -template -inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool) +template inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool) { SetAttribute(step, AttrType, T::ToolType); SetAttribute(step, AttrLabel, tool->name()); @@ -1221,13 +1219,13 @@ auto VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id, } catch (const VExceptionBadId &e) { - qCritical() << e.ErrorMessage()<ObjectName()); SetAttributeOrRemoveIf(node, AttrAlias, item.alias, - [](const QString &alias) noexcept {return alias.isEmpty();}); + [](const QString &alias) noexcept { return alias.isEmpty(); }); if (obj->getType() != GOType::Point) { @@ -1244,7 +1242,7 @@ auto VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id, QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") - switch(static_cast(obj->getType())) + switch (static_cast(obj->getType())) { case GOType::Point: SetAttribute(node, AttrType, QStringLiteral("point")); diff --git a/src/libs/vmisc/literals.cpp b/src/libs/vmisc/literals.cpp index 34ba4aa5b..2305bac01 100644 --- a/src/libs/vmisc/literals.cpp +++ b/src/libs/vmisc/literals.cpp @@ -38,44 +38,44 @@ const QString degreeSymbol = QStringLiteral("°"); const QString trueStr = QStringLiteral("true"); const QString falseStr = QStringLiteral("false"); -//functions +// functions const QString degTorad_F = QStringLiteral("degTorad"); const QString radTodeg_F = QStringLiteral("radTodeg"); -const QString sin_F = QStringLiteral("sin"); -const QString cos_F = QStringLiteral("cos"); -const QString tan_F = QStringLiteral("tan"); -const QString asin_F = QStringLiteral("asin"); -const QString acos_F = QStringLiteral("acos"); -const QString atan_F = QStringLiteral("atan"); -const QString sinh_F = QStringLiteral("sinh"); -const QString cosh_F = QStringLiteral("cosh"); -const QString tanh_F = QStringLiteral("tanh"); +const QString sin_F = QStringLiteral("sin"); +const QString cos_F = QStringLiteral("cos"); +const QString tan_F = QStringLiteral("tan"); +const QString asin_F = QStringLiteral("asin"); +const QString acos_F = QStringLiteral("acos"); +const QString atan_F = QStringLiteral("atan"); +const QString sinh_F = QStringLiteral("sinh"); +const QString cosh_F = QStringLiteral("cosh"); +const QString tanh_F = QStringLiteral("tanh"); const QString asinh_F = QStringLiteral("asinh"); const QString acosh_F = QStringLiteral("acosh"); const QString atanh_F = QStringLiteral("atanh"); -const QString sinD_F = QStringLiteral("sinD"); -const QString cosD_F = QStringLiteral("cosD"); -const QString tanD_F = QStringLiteral("tanD"); -const QString asinD_F = QStringLiteral("asinD"); -const QString acosD_F = QStringLiteral("acosD"); -const QString atanD_F = QStringLiteral("atanD"); -const QString log2_F = QStringLiteral("log2"); +const QString sinD_F = QStringLiteral("sinD"); +const QString cosD_F = QStringLiteral("cosD"); +const QString tanD_F = QStringLiteral("tanD"); +const QString asinD_F = QStringLiteral("asinD"); +const QString acosD_F = QStringLiteral("acosD"); +const QString atanD_F = QStringLiteral("atanD"); +const QString log2_F = QStringLiteral("log2"); const QString log10_F = QStringLiteral("log10"); -const QString log_F = QStringLiteral("log"); -const QString ln_F = QStringLiteral("ln"); -const QString exp_F = QStringLiteral("exp"); -const QString sqrt_F = QStringLiteral("sqrt"); -const QString sign_F = QStringLiteral("sign"); -const QString rint_F = QStringLiteral("rint"); -const QString r2cm_F = QStringLiteral("r2cm"); +const QString log_F = QStringLiteral("log"); +const QString ln_F = QStringLiteral("ln"); +const QString exp_F = QStringLiteral("exp"); +const QString sqrt_F = QStringLiteral("sqrt"); +const QString sign_F = QStringLiteral("sign"); +const QString rint_F = QStringLiteral("rint"); +const QString r2cm_F = QStringLiteral("r2cm"); const QString csrCm_F = QStringLiteral("csrCm"); const QString csrInch_F = QStringLiteral("csrInch"); -const QString abs_F = QStringLiteral("abs"); -const QString min_F = QStringLiteral("min"); -const QString max_F = QStringLiteral("max"); -const QString sum_F = QStringLiteral("sum"); -const QString avg_F = QStringLiteral("avg"); -const QString fmod_F = QStringLiteral("fmod"); +const QString abs_F = QStringLiteral("abs"); +const QString min_F = QStringLiteral("min"); +const QString max_F = QStringLiteral("max"); +const QString sum_F = QStringLiteral("sum"); +const QString avg_F = QStringLiteral("avg"); +const QString fmod_F = QStringLiteral("fmod"); const QString warning_F = QStringLiteral("warning"); auto BuilInFunctions() -> QStringList @@ -88,13 +88,13 @@ auto BuilInFunctions() -> QStringList const QString pl_size = QStringLiteral("size"); const QString pl_height = QStringLiteral("height"); -const QString pl_hip = QStringLiteral("hip"); -const QString pl_waist = QStringLiteral("waist"); +const QString pl_hip = QStringLiteral("hip"); +const QString pl_waist = QStringLiteral("waist"); -const QString pl_sizeLabel = QStringLiteral("sizeLabel"); +const QString pl_sizeLabel = QStringLiteral("sizeLabel"); const QString pl_heightLabel = QStringLiteral("heightLabel"); -const QString pl_hipLabel = QStringLiteral("hipLabel"); -const QString pl_waistLabel = QStringLiteral("waistLabel"); +const QString pl_hipLabel = QStringLiteral("hipLabel"); +const QString pl_waistLabel = QStringLiteral("waistLabel"); const QString pl_dimensionX = QStringLiteral("dimensionX"); const QString pl_dimensionY = QStringLiteral("dimensionY"); @@ -106,64 +106,64 @@ const QString pl_dimensionYLabel = QStringLiteral("dimensionYLabel"); const QString pl_dimensionWLabel = QStringLiteral("dimensionWLabel"); const QString pl_dimensionZLabel = QStringLiteral("dimensionZLabel"); -const QString pl_date = QStringLiteral("date"); -const QString pl_time = QStringLiteral("time"); -const QString pl_birthDate = QStringLiteral("birthDate"); -const QString pl_patternName = QStringLiteral("patternName"); -const QString pl_patternNumber = QStringLiteral("patternNumber"); -const QString pl_author = QStringLiteral("author"); -const QString pl_customer = QStringLiteral("customer"); -const QString pl_email = QStringLiteral("email"); -const QString pl_userMaterial = QStringLiteral("userMaterial"); -const QString pl_pExt = QStringLiteral("pExt"); -const QString pl_pUnits = QStringLiteral("pUnits"); -const QString pl_pFileName = QStringLiteral("pFileName"); -const QString pl_mFileName = QStringLiteral("mFileName"); -const QString pl_mExt = QStringLiteral("mExt"); -const QString pl_mUnits = QStringLiteral("mUnits"); -const QString pl_mSizeUnits = QStringLiteral("mSizeUnits"); -const QString pl_areaUnits = QStringLiteral("areaUnits"); -const QString pl_pLetter = QStringLiteral("pLetter"); -const QString pl_pAnnotation = QStringLiteral("pAnnotation"); -const QString pl_pOrientation = QStringLiteral("pOrientation"); -const QString pl_pRotation = QStringLiteral("pRotation"); -const QString pl_pTilt = QStringLiteral("pTilt"); -const QString pl_pFoldPosition = QStringLiteral("pFoldPosition"); -const QString pl_pName = QStringLiteral("pName"); -const QString pl_pQuantity = QStringLiteral("pQuantity"); -const QString pl_mFabric = QStringLiteral("mFabric"); -const QString pl_mLining = QStringLiteral("mLining"); -const QString pl_mInterfacing = QStringLiteral("mInterfacing"); -const QString pl_mInterlining = QStringLiteral("mInterlining"); -const QString pl_wCut = QStringLiteral("wCut"); -const QString pl_wOnFold = QStringLiteral("wOnFold"); -const QString pl_measurement = QStringLiteral("measurement_"); -const QString pl_finalMeasurement = QStringLiteral("finalMeasurement_"); -const QString pl_currentArea = QStringLiteral("currentArea"); +const QString pl_date = QStringLiteral("date"); +const QString pl_time = QStringLiteral("time"); +const QString pl_birthDate = QStringLiteral("birthDate"); +const QString pl_patternName = QStringLiteral("patternName"); +const QString pl_patternNumber = QStringLiteral("patternNumber"); +const QString pl_author = QStringLiteral("author"); +const QString pl_customer = QStringLiteral("customer"); +const QString pl_email = QStringLiteral("email"); +const QString pl_userMaterial = QStringLiteral("userMaterial"); +const QString pl_pExt = QStringLiteral("pExt"); +const QString pl_pUnits = QStringLiteral("pUnits"); +const QString pl_pFileName = QStringLiteral("pFileName"); +const QString pl_mFileName = QStringLiteral("mFileName"); +const QString pl_mExt = QStringLiteral("mExt"); +const QString pl_mUnits = QStringLiteral("mUnits"); +const QString pl_mSizeUnits = QStringLiteral("mSizeUnits"); +const QString pl_areaUnits = QStringLiteral("areaUnits"); +const QString pl_pLetter = QStringLiteral("pLetter"); +const QString pl_pAnnotation = QStringLiteral("pAnnotation"); +const QString pl_pOrientation = QStringLiteral("pOrientation"); +const QString pl_pRotation = QStringLiteral("pRotation"); +const QString pl_pTilt = QStringLiteral("pTilt"); +const QString pl_pFoldPosition = QStringLiteral("pFoldPosition"); +const QString pl_pName = QStringLiteral("pName"); +const QString pl_pQuantity = QStringLiteral("pQuantity"); +const QString pl_mFabric = QStringLiteral("mFabric"); +const QString pl_mLining = QStringLiteral("mLining"); +const QString pl_mInterfacing = QStringLiteral("mInterfacing"); +const QString pl_mInterlining = QStringLiteral("mInterlining"); +const QString pl_wCut = QStringLiteral("wCut"); +const QString pl_wOnFold = QStringLiteral("wOnFold"); +const QString pl_measurement = QStringLiteral("measurement_"); +const QString pl_finalMeasurement = QStringLiteral("finalMeasurement_"); +const QString pl_currentArea = QStringLiteral("currentArea"); const QString pl_currentSeamLineArea = QStringLiteral("currentSeamLineArea"); const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png"); const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png"); -const QString strOne = QStringLiteral("one"); -const QString strTwo = QStringLiteral("two"); +const QString strOne = QStringLiteral("one"); +const QString strTwo = QStringLiteral("two"); const QString strThree = QStringLiteral("three"); -const QString strStraightforward = QStringLiteral("straightforward"); -const QString strBisector = QStringLiteral("bisector"); -const QString strIntersection = QStringLiteral("intersection"); -const QString strIntersectionOnlyLeft = QStringLiteral("intersectionLeft"); -const QString strIntersectionOnlyRight = QStringLiteral("intersectionRight"); -const QString strIntersection2 = QStringLiteral("intersection2"); -const QString strIntersection2OnlyLeft = QStringLiteral("intersection2Left"); +const QString strStraightforward = QStringLiteral("straightforward"); +const QString strBisector = QStringLiteral("bisector"); +const QString strIntersection = QStringLiteral("intersection"); +const QString strIntersectionOnlyLeft = QStringLiteral("intersectionLeft"); +const QString strIntersectionOnlyRight = QStringLiteral("intersectionRight"); +const QString strIntersection2 = QStringLiteral("intersection2"); +const QString strIntersection2OnlyLeft = QStringLiteral("intersection2Left"); const QString strIntersection2OnlyRight = QStringLiteral("intersection2Right"); -const QString strTypeIncrement = QStringLiteral("increment"); -const QString strTypeSeparator = QStringLiteral("separator"); -const QString strTypeMeasurement = QStringLiteral("measurement"); +const QString strTypeIncrement = QStringLiteral("increment"); +const QString strTypeSeparator = QStringLiteral("separator"); +const QString strTypeMeasurement = QStringLiteral("measurement"); -const QString unitMM = QStringLiteral("mm"); -const QString unitCM = QStringLiteral("cm"); +const QString unitMM = QStringLiteral("mm"); +const QString unitCM = QStringLiteral("cm"); const QString unitINCH = QStringLiteral("inch"); -const QString unitPX = QStringLiteral("px"); +const QString unitPX = QStringLiteral("px"); const QString valentinaNamespace = QStringLiteral("valentina"); diff --git a/src/libs/vmisc/literals.h b/src/libs/vmisc/literals.h index 4ad5c560d..90e3acf8a 100644 --- a/src/libs/vmisc/literals.h +++ b/src/libs/vmisc/literals.h @@ -28,8 +28,8 @@ #ifndef LITERALS_H #define LITERALS_H -#include #include +#include class QString; #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) diff --git a/src/libs/vmisc/projectversion.h b/src/libs/vmisc/projectversion.h index 9460ccc24..c0f03a76c 100644 --- a/src/libs/vmisc/projectversion.h +++ b/src/libs/vmisc/projectversion.h @@ -39,7 +39,7 @@ auto AppVersionStr() -> const QString &; constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned { - return ((major<<16u)|(minor<<8u)|patch); + return ((major << 16u) | (minor << 8u) | patch); } constexpr inline auto AppVersion() -> unsigned @@ -50,24 +50,24 @@ constexpr inline auto AppVersion() -> unsigned // Change version number in projectversion.cpp too. // Synchronize valentina.nsi -#define VER_FILEVERSION 0,7,52 -#define VER_FILEVERSION_STR "0.7.52\0" +#define VER_FILEVERSION 0, 7, 52 +#define VER_FILEVERSION_STR "0.7.52\0" #define V_PRERELEASE // Mark prerelease builds -#define VER_PRODUCTVERSION VER_FILEVERSION -#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR +#define VER_PRODUCTVERSION VER_FILEVERSION +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR -#define VER_COMPANYNAME_STR "ValentinaTeam" -//#define VER_FILEDESCRIPTION_STR "Patternmaking program." // Defined in program -//#define VER_INTERNALNAME_STR "Valentina" // Defined in program -#define VER_LEGALCOPYRIGHT_STR "Copyright © 2014-2022 Valentina Team" -#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved" -#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR -//#define VER_ORIGINALFILENAME_STR "valentina.exe" // Defined in program -//#define VER_PRODUCTNAME_STR "Valentina" // Defined in program +#define VER_COMPANYNAME_STR "ValentinaTeam" +// #define VER_FILEDESCRIPTION_STR "Patternmaking program." // Defined in program +// #define VER_INTERNALNAME_STR "Valentina" // Defined in program +#define VER_LEGALCOPYRIGHT_STR "Copyright © 2014-2022 Valentina Team" +#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved" +#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR +// #define VER_ORIGINALFILENAME_STR "valentina.exe" // Defined in program +// #define VER_PRODUCTNAME_STR "Valentina" // Defined in program -#define VER_COMPANYDOMAIN_STR "smart-pattern.com.ua" +#define VER_COMPANYDOMAIN_STR "smart-pattern.com.ua" auto compilerString() -> QString; auto buildCompatibilityString() -> QString; diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index dc99b04f2..767b1b79a 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -27,17 +27,16 @@ *************************************************************************/ #include "tst_buitinregexp.h" -#include "../qmuparser/qmudef.h" -#include "../vpatterndb/vtranslatevars.h" #include "../ifc/ifcdef.h" #include "../vmisc/literals.h" +#include "../vpatterndb/vtranslatevars.h" -#include #include +#include //--------------------------------------------------------------------------------------------------------------------- TST_BuitInRegExp::TST_BuitInRegExp(const QString &locale, QObject *parent) - : TST_AbstractRegExp(locale, parent) + : TST_AbstractRegExp(locale, parent) { } @@ -64,7 +63,7 @@ void TST_BuitInRegExp::initTestCase() QLocale::setDefault(QLocale(m_locale)); - InitTrMs();//Very important do this after loading QM files. + InitTrMs(); // Very important do this after loading QM files. } //--------------------------------------------------------------------------------------------------------------------- @@ -121,7 +120,7 @@ void TST_BuitInRegExp::TestCheckIsNamesUnique() if (originalNames.size() > 1) { const QString message = QString("Name is not unique. Translated name:'%1' also assosiated with: %2.") - .arg(translatedName, originalNames.join(", ")); + .arg(translatedName, originalNames.join(", ")); QFAIL(qUtf8Printable(message)); } } @@ -197,8 +196,8 @@ void TST_BuitInRegExp::TestCheckUnderlineExists() const QString translated = m_trMs->InternalVarToUser(name); if ((translated.right(1) == QLatin1String("_")) != exists) { - const QString message = QString("String '%1' doesn't contain underline. Original string is '%2'") - .arg(translated, name); + const QString message = + QString("String '%1' doesn't contain underline. Original string is '%2'").arg(translated, name); QFAIL(qUtf8Printable(message)); } }