|
Krita Source Code Documentation
|
#include "kis_num_parser.h"#include <qnumeric.h>#include <qmath.h>#include <QVector>#include <QRegExp>#include <QStringList>#include <QVariant>#include <QLocale>#include <iostream>Go to the source code of this file.
Namespaces | |
| namespace | KisNumericParser |
| the namespace contains functions to transform math expression written as QString in numbers. | |
Functions | |
| QString | extractSubExprLevel1 (QString &expr, char &nextOp, bool &noProblem) |
| extractSubExprLevel1 extract from an expression the part of an expression that need to be treated recursively before computing level 1 operations (+, -). | |
| QString | extractSubExprLevel2 (QString &expr, char &nextOp, bool &noProblem) |
| extractSubExprLevel2 extract from an expression the part of an expression that need to be treated recursively before computing level 2 operations (*, /). | |
| const QRegExp | funcExpr ("(-)?([a-zA-Z]*[0-9]*)?\\((.+)\\)") |
| const QRegExp | funcExprInteger ("(-)?\\((.+)\\)") |
| const QRegExp | integerExpr ("(-)?([0-9]+)") |
| const QRegExp | numberExpr ("(-)?([0-9]+\\.?[0-9]*(e[0-9]*)?)") |
| int | KisNumericParser::parseIntegerMathExpr (QString const &expr, bool *noProblem=0) |
| parse an expression to an int. | |
| double | KisNumericParser::parseSimpleMathExpr (QString const &expr, bool *noProblem=0) |
| parse an expression to a double. | |
| double | treatFuncs (QString const &expr, bool &noProblem) |
| treatFuncs treat the last level of recursion: parenthesis and functions. | |
| double | treatFuncsInt (QString const &expr, bool &noProblem) |
| treatFuncs treat the last level of recursion: parenthesis | |
| double | treatLevel1 (const QString &expr, bool &noProblem) |
| treatLevel1 treat an expression at the first level of recursion. | |
| double | treatLevel1Int (QString const &expr, bool &noProblem) |
| treatLevel1 treat an expression at the first level of recursion. | |
| double | treatLevel2 (QString const &expr, bool &noProblem) |
| treatLevel2 treat a subexpression at the second level of recursion. | |
| double | treatLevel2Int (const QString &expr, bool &noProblem) |
| treatLevel2 treat a subexpression at the second level of recursion. | |
| double | treatLevel3 (const QString &expr, bool &noProblem) |
| treatLevel3 treat a subexpression at the third level of recursion. | |
Variables | |
| const QVector< char > | opLevel1 = {'+', '-'} |
| const QVector< char > | opLevel2 = {'*', '/'} |
| const QStringList | supportedFuncs = {"", "cos", "sin", "tan", "acos", "asin", "atan", "exp", "ln", "log10", "abs"} |
|
inline |
extractSubExprLevel1 extract from an expression the part of an expression that need to be treated recursively before computing level 1 operations (+, -).
| expr | The expression to treat, the part returned will be removed. |
| nextOp | This reference, in case of success, will hold the first level operation identified as separator ('+' or '-') |
| noProblem | A reference to a bool, set to true if there was no problem, false otherwise. |
Definition at line 94 of file kis_num_parser.cpp.
|
inline |
extractSubExprLevel2 extract from an expression the part of an expression that need to be treated recursively before computing level 2 operations (*, /).
| expr | The expression to treat, the part returned will be removed. |
| nextOp | This reference, in case of success, will hold the first level operation identified as separator ('*' or '/') |
| noProblem | A reference to a bool, set to true if there was no problem, false otherwise. |
Definition at line 165 of file kis_num_parser.cpp.
| const QRegExp funcExpr | ( | "(-)?([a-zA-Z]*[0-9]*)?\\((.+)\\)" | ) |
| const QRegExp funcExprInteger | ( | "(-)?\\((.+)\\)" | ) |
| const QRegExp integerExpr | ( | "(-)?([0-9]+)" | ) |
| const QRegExp numberExpr | ( | "(-)?([0-9]+\\.?[0-9]*(e[0-9]*)?)" | ) |
| double treatFuncs | ( | QString const & | expr, |
| bool & | noProblem ) |
treatFuncs treat the last level of recursion: parenthesis and functions.
| expr | The expression to parse. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
The expression should not contain operators not nested anymore. The subexpressions within parenthesis will be treated by recalling the level 1 function.
Definition at line 362 of file kis_num_parser.cpp.
References funcExpr(), numberExpr(), sign(), supportedFuncs, and treatLevel1().
| double treatFuncsInt | ( | QString const & | expr, |
| bool & | noProblem ) |
treatFuncs treat the last level of recursion: parenthesis
| expr | The expression to parse. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
The expression should not contain operators not nested anymore. The subexpressions within parenthesis will be treated by recalling the level 1 function.
Definition at line 532 of file kis_num_parser.cpp.
References funcExprInteger(), integerExpr(), numberExpr(), sign(), treatLevel1Int(), and value().
| double treatLevel1 | ( | const QString & | expr, |
| bool & | noProblem ) |
treatLevel1 treat an expression at the first level of recursion.
| expr | The expression to treat. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
Definition at line 214 of file kis_num_parser.cpp.
References extractSubExprLevel1(), part(), sign(), and treatLevel2().
| double treatLevel1Int | ( | QString const & | expr, |
| bool & | noProblem ) |
treatLevel1 treat an expression at the first level of recursion.
| expr | The expression to treat. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
Definition at line 437 of file kis_num_parser.cpp.
References extractSubExprLevel1(), part(), sign(), and treatLevel2Int().
| double treatLevel2 | ( | QString const & | expr, |
| bool & | noProblem ) |
treatLevel2 treat a subexpression at the second level of recursion.
| expr | The subexpression to treat. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
The expression should not contain first level operations not nested in parenthesis.
Definition at line 256 of file kis_num_parser.cpp.
References extractSubExprLevel2(), part(), and treatLevel3().
| double treatLevel2Int | ( | const QString & | expr, |
| bool & | noProblem ) |
treatLevel2 treat a subexpression at the second level of recursion.
| expr | The subexpression to treat. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
The expression should not contain first level operations not nested in parenthesis.
Definition at line 479 of file kis_num_parser.cpp.
References extractSubExprLevel2(), part(), and treatFuncsInt().
| double treatLevel3 | ( | const QString & | expr, |
| bool & | noProblem ) |
treatLevel3 treat a subexpression at the third level of recursion.
| expr | The subexpression to treat. |
| noProblem | A reference to a bool set to true if no problem happened, false otherwise. |
The expression should not contain first or second level operations not nested in parenthesis.
Definition at line 300 of file kis_num_parser.cpp.
References treatFuncs().
| const QVector<char> opLevel1 = {'+', '-'} |
Definition at line 21 of file kis_num_parser.cpp.
| const QVector<char> opLevel2 = {'*', '/'} |
Definition at line 22 of file kis_num_parser.cpp.
| const QStringList supportedFuncs = {"", "cos", "sin", "tan", "acos", "asin", "atan", "exp", "ln", "log10", "abs"} |
Definition at line 24 of file kis_num_parser.cpp.