From debc37d78a2c37d9bf8d535d19b324e0433dcd17 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 4 Dec 2017 14:32:17 +0200 Subject: [PATCH] Removed unused postfix operator. --HG-- branch : develop --- src/libs/ifc/xml/vabstractpattern.cpp | 16 +---- src/libs/ifc/xml/vabstractpattern.h | 1 - src/libs/vmisc/def.cpp | 9 --- src/libs/vmisc/def.h | 7 --- src/libs/vpatterndb/vtranslatevars.cpp | 82 -------------------------- src/libs/vpatterndb/vtranslatevars.h | 7 +-- 6 files changed, 2 insertions(+), 120 deletions(-) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index f3b8dde3d..1dbac7ddd 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -274,7 +274,7 @@ QStringList VAbstractPattern::ListMeasurements() const continue; } - if (IsVariable(tValues.at(j)) || IsPostfixOperator(tValues.at(j)) || IsFunction(tValues.at(j))) + if (IsVariable(tValues.at(j)) || IsFunction(tValues.at(j))) { others.insert(tValues.at(j)); } @@ -2049,20 +2049,6 @@ bool VAbstractPattern::IsVariable(const QString &token) const return false; } -//--------------------------------------------------------------------------------------------------------------------- -bool VAbstractPattern::IsPostfixOperator(const QString &token) const -{ - for (int i = 0; i < builInPostfixOperators.size(); ++i) - { - if (token.indexOf( builInPostfixOperators.at(i) ) == 0) - { - return true; - } - } - - return false; -} - //--------------------------------------------------------------------------------------------------------------------- bool VAbstractPattern::IsFunction(const QString &token) const { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index d2ccf0d16..1a4b6c5f4 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -450,7 +450,6 @@ private: QVector ListFinalMeasurementsExpressions() const; bool IsVariable(const QString& token) const; - bool IsPostfixOperator(const QString& token) const; bool IsFunction(const QString& token) const; QPair > ParseItemElement(const QDomElement &domElement); diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index ed0834142..976d9f405 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -137,15 +137,6 @@ const QStringList builInFunctions = QStringList() << degTorad_F << avg_F << fmod_F; -// Postfix operators -const QString cm_Oprt = QStringLiteral("cm"); -const QString mm_Oprt = QStringLiteral("mm"); -const QString in_Oprt = QStringLiteral("in"); - -const QStringList builInPostfixOperators = QStringList() << cm_Oprt - << mm_Oprt - << in_Oprt; - const QString pl_size = QStringLiteral("size"); const QString pl_height = QStringLiteral("height"); const QString pl_date = QStringLiteral("date"); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 1dd886c3f..45ba99a41 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -358,13 +358,6 @@ extern const QString fmod_F; extern const QStringList builInFunctions; -// Postfix operators -extern const QString cm_Oprt; -extern const QString mm_Oprt; -extern const QString in_Oprt; - -extern const QStringList builInPostfixOperators; - // Placeholders extern const QString pl_size; extern const QString pl_height; diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index c862deae4..2956a05fc 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -53,7 +53,6 @@ VTranslateVars::VTranslateVars() PMSystemBooks(QMap()), variables(QMap()), functions(QMap()), - postfixOperators(QMap()), placeholders(QMap()), stDescriptions(QMap()), translatedFunctions(QMap()) @@ -61,16 +60,11 @@ VTranslateVars::VTranslateVars() InitPatternMakingSystems(); InitVariables(); InitFunctions(); - InitPostfixOperators(); InitPlaceholder(); PrepareFunctionTranslations(); } -//--------------------------------------------------------------------------------------------------------------------- -VTranslateVars::~VTranslateVars() -{} - #define translate(context, source, disambiguation) qmu::QmuTranslation::translate((context), (source), (disambiguation)) //--------------------------------------------------------------------------------------------------------------------- @@ -454,14 +448,6 @@ void VTranslateVars::InitFunctions() "Returns the floating-point remainder of numer/denom (rounded towards zero)")); } -//--------------------------------------------------------------------------------------------------------------------- -void VTranslateVars::InitPostfixOperators() -{ - postfixOperators.insert(cm_Oprt, translate("VTranslateVars", "cm", "centimeter")); - postfixOperators.insert(mm_Oprt, translate("VTranslateVars", "mm", "millimeter")); - postfixOperators.insert(in_Oprt, translate("VTranslateVars", "in", "inch")); -} - //--------------------------------------------------------------------------------------------------------------------- void VTranslateVars::InitPlaceholder() { @@ -612,31 +598,6 @@ bool VTranslateVars::VariablesFromUser(QString &newFormula, int position, const return false; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief PostfixOperatorsFromUser translate postfix operator to internal look. - * @param newFormula [in|out] expression to translate - * @param position token position - * @param token token to translate - * @param bias hold change of length between translated and origin token string - * @return true if was found postfix operator with same name. - */ -bool VTranslateVars::PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, int &bias) const -{ - QMap::const_iterator i = postfixOperators.constBegin(); - while (i != postfixOperators.constEnd()) - { - if (token == i.value().translate()) - { - newFormula.replace(position, token.length(), i.key()); - bias = token.length() - i.key().length(); - return true; - } - ++i; - } - return false; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief FunctionsFromUser translate function name to internal look. @@ -780,11 +741,6 @@ QString VTranslateVars::VarToUser(const QString &var) const return functions.value(var).translate(); } - if (postfixOperators.contains(var)) - { - return postfixOperators.value(var).translate(); - } - return InternalVarToUser(var); } @@ -803,11 +759,6 @@ QString VTranslateVars::VarFromUser(const QString &var) const return newVar; } - if (PostfixOperatorsFromUser(newVar, 0, var, bias)) - { - return newVar; - } - if (FunctionsFromUser(newVar, 0, var, bias)) { return newVar; @@ -833,13 +784,6 @@ QString VTranslateVars::PMSystemBook(const QString &code) const return PMSystemBooks.value(code).translate(); } -//--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress unusedFunction -QString VTranslateVars::PostfixOperator(const QString &name) const -{ - return postfixOperators.value(name).translate(); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief FormulaFromUser replace all known tokens in formula to internal look. Also change decimal @@ -890,17 +834,6 @@ QString VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator continue; } - if (PostfixOperatorsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) - { - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - if (FunctionsFromUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { if (bias != 0) @@ -1029,19 +962,6 @@ QString VTranslateVars::FormulaToUser(const QString &formula, bool osSeparator) continue; } - if (postfixOperators.contains(tValues.at(i))) - { - newFormula.replace(tKeys.at(i), tValues.at(i).length(), postfixOperators.value(tValues.at(i)).translate()); - int bias = tValues.at(i).length() - postfixOperators.value(tValues.at(i)).translate().length(); - if (bias != 0) - {// Translated token has different length than original. Position next tokens need to be corrected. - CorrectionsPositions(tKeys.at(i), bias, tokens, numbers); - tKeys = tokens.keys(); - tValues = tokens.values(); - } - continue; - } - int bias = 0; if (VariablesToUser(newFormula, tKeys.at(i), tValues.at(i), bias)) { @@ -1120,13 +1040,11 @@ void VTranslateVars::Retranslate() PMSystemBooks.clear(); variables.clear(); functions.clear(); - postfixOperators.clear(); stDescriptions.clear(); InitPatternMakingSystems(); InitVariables(); InitFunctions(); - InitPostfixOperators(); InitPlaceholder(); PrepareFunctionTranslations(); diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index 5d4856b18..8e284b58a 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -38,10 +38,9 @@ class VTranslateVars : public VTranslateMeasurements { public: explicit VTranslateVars(); - virtual ~VTranslateVars() Q_DECL_OVERRIDE; + virtual ~VTranslateVars() = default; bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; - bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; @@ -58,8 +57,6 @@ public: QString PMSystemAuthor(const QString &code) const; QString PMSystemBook(const QString &code) const; - QString PostfixOperator(const QString &name) const; - QString FormulaFromUser(const QString &formula, bool osSeparator) const; static QString TryFormulaFromUser(const QString &formula, bool osSeparator); @@ -80,7 +77,6 @@ private: QMap PMSystemBooks; QMap variables; QMap functions; - QMap postfixOperators; QMap placeholders; QMap stDescriptions; QMap translatedFunctions; @@ -88,7 +84,6 @@ private: void InitPatternMakingSystems(); void InitVariables(); void InitFunctions(); - void InitPostfixOperators(); void InitPlaceholder(); void PrepareFunctionTranslations();