/************************************************************************ ** ** @file vtranslatevars.h ** @author Roman Telezhynskyi ** @date 10 6, 2015 ** ** @brief ** @copyright ** This source code is part of the Valentina project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2015 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** Valentina is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with Valentina. If not, see . ** *************************************************************************/ #ifndef VTRANSLATEVARS_H #define VTRANSLATEVARS_H #include #include #include "../qmuparser/qmutranslation.h" #include "../vmisc/defglobal.h" class VTranslateVars { public: explicit VTranslateVars(); ~VTranslateVars() = default; auto InternalVarToUser(const QString &var) const -> QString; auto VarToUser(const QString &var) const -> QString; auto VarFromUser(const QString &var) const -> QString; auto FormulaFromUser(const QString &formula, bool osSeparator) const -> QString; static auto TryFormulaFromUser(const QString &formula, bool osSeparator) -> QString; auto FormulaToUser(const QString &formula, bool osSeparator) const -> QString; static auto TryFormulaToUser(const QString &formula, bool osSeparator) -> QString; void Retranslate(); auto GetTranslatedFunctions() const -> QMap; auto GetFunctions() const -> QMap; auto GetFunctionsDescriptions() const -> QMap; auto GetFunctionsArguments() const -> QMap; static void BiasTokens(vsizetype position, vsizetype bias, QMap &tokens); private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VTranslateVars) // NOLINT QMap variables{}; QMap functions{}; QMap functionsDescriptions{}; QMap functionsArguments{}; QMap stDescriptions{}; QMap translatedFunctions{}; void InitVariables(); void InitFunctions(); auto VariablesFromUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const -> bool; auto FunctionsFromUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const -> bool; auto VariablesToUser(QString &newFormula, vsizetype position, const QString &token, vsizetype &bias) const -> bool; void PrepareFunctionTranslations(); static void CorrectionsPositions(vsizetype position, vsizetype bias, QMap &tokens, QMap &numbers); void TranslateVarsFromUser(QString &newFormula, QMap &tokens, QMap &numbers) const; static void TranslateNumbersFromUser(QString &newFormula, QMap &tokens, QMap &numbers, bool osSeparator); void TranslateVarsToUser(QString &newFormula, QMap &tokens, QMap &numbers) const; static void TranslateNumbersToUser(QString &newFormula, QMap &tokens, QMap &numbers, bool osSeparator); }; #endif // VTRANSLATEVARS_H