1 /* 2 * Copyright (c) 2016 Laurent Valentin Jospin <laurent.valentin@famillejospin.ch> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef KIS_NUMPARSER_H 20 #define KIS_NUMPARSER_H 21 22 #include <QString> 23 24 #include "kritawidgetutils_export.h" 25 26 /*! 27 * \brief the namespace contains functions to transform math expression written as QString in numbers. 28 * 29 * Computation is done in a recursive way, maybe not the most efficient way compared to infix to postfix conversion before parsing. 30 * (TODO: look if it need to be changed). 31 */ 32 namespace KisNumericParser { 33 34 //! \brief parse an expression to a double. 35 KRITAWIDGETUTILS_EXPORT double parseSimpleMathExpr(QString const& expr, bool* noProblem = 0); 36 37 //! \brief parse an expression to an int. 38 KRITAWIDGETUTILS_EXPORT int parseIntegerMathExpr(QString const& expr, bool* noProblem = 0); 39 } 40 41 #endif // KIS_NUMPARSER_H 42 43