|
Cppcheck
|
simple math functions that uses operands stored in std::string. More...
#include <mathlib.h>
Public Types | |
| typedef long long | bigint |
Static Public Member Functions | |
| static bigint | toLongNumber (const std::string &str) |
| static std::string | longToString (const bigint value) |
| static double | toDoubleNumber (const std::string &str) |
| static std::string | doubleToString (const double value) |
| static bool | isInt (const std::string &str) |
| static bool | isFloat (const std::string &str) |
| static bool | isNegative (const std::string &str) |
| static bool | isHex (const std::string &str) |
| static bool | isOct (const std::string &str) |
| static bool | isBin (const std::string &str) |
| static std::string | add (const std::string &first, const std::string &second) |
| static std::string | subtract (const std::string &first, const std::string &second) |
| static std::string | multiply (const std::string &first, const std::string &second) |
| static std::string | divide (const std::string &first, const std::string &second) |
| static std::string | mod (const std::string &first, const std::string &second) |
| static std::string | calculate (const std::string &first, const std::string &second, char action) |
| static std::string | sin (const std::string &tok) |
| static std::string | cos (const std::string &tok) |
| static std::string | tan (const std::string &tok) |
| static std::string | abs (const std::string &tok) |
| static bool | isEqual (const std::string &first, const std::string &second) |
| static bool | isNotEqual (const std::string &first, const std::string &second) |
| static bool | isGreater (const std::string &first, const std::string &second) |
| static bool | isGreaterEqual (const std::string &first, const std::string &second) |
| static bool | isLess (const std::string &first, const std::string &second) |
| static bool | isLessEqual (const std::string &first, const std::string &second) |
| static bool | isNullValue (const std::string &tok) |
| static bool | isOctalDigit (char c) |
| Return true if given character is 0,1,2,3,4,5,6 or 7. | |
simple math functions that uses operands stored in std::string.
useful when performing math on tokens.
| typedef long long MathLib::bigint |
| std::string MathLib::abs | ( | const std::string & | tok | ) | [static] |
Definition at line 363 of file mathlib.cpp.
References doubleToString(), and toDoubleNumber().
| std::string MathLib::add | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 242 of file mathlib.cpp.
References doubleToString(), isInt(), longToString(), toDoubleNumber(), and toLongNumber().
Referenced by calculate(), and TemplateSimplifier::simplifyNumericCalculations().
| std::string MathLib::calculate | ( | const std::string & | first, |
| const std::string & | second, | ||
| char | action | ||
| ) | [static] |
Definition at line 314 of file mathlib.cpp.
References add(), divide(), longToString(), mod(), multiply(), subtract(), and toLongNumber().
Referenced by CheckBufferOverrun::parse_for_body(), and TemplateSimplifier::simplifyNumericCalculations().
| std::string MathLib::cos | ( | const std::string & | tok | ) | [static] |
Definition at line 352 of file mathlib.cpp.
References doubleToString(), and toDoubleNumber().
| std::string MathLib::divide | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 281 of file mathlib.cpp.
References doubleToString(), isInt(), longToString(), toDoubleNumber(), and toLongNumber().
Referenced by calculate(), TemplateSimplifier::simplifyCalculations(), and TemplateSimplifier::simplifyNumericCalculations().
| std::string MathLib::doubleToString | ( | const double | value | ) | [static] |
Definition at line 99 of file mathlib.cpp.
Referenced by abs(), add(), cos(), divide(), isEqual(), mod(), multiply(), sin(), subtract(), and tan().
| bool MathLib::isBin | ( | const std::string & | str | ) | [static] |
Definition at line 143 of file mathlib.cpp.
Referenced by TokenList::addtoken(), and toLongNumber().
| bool MathLib::isEqual | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 368 of file mathlib.cpp.
References doubleToString(), and toDoubleNumber().
Referenced by analyzeLogicOperatorCondition(), and isNotEqual().
| bool MathLib::isFloat | ( | const std::string & | str | ) | [static] |
Definition at line 111 of file mathlib.cpp.
Referenced by CheckOther::checkMathFunctions(), and isOct().
| bool MathLib::isGreater | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 380 of file mathlib.cpp.
References toDoubleNumber().
Referenced by analyzeLogicOperatorCondition(), and CheckOther::checkCharVariable().
| bool MathLib::isGreaterEqual | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 385 of file mathlib.cpp.
References toDoubleNumber().
Referenced by analyzeLogicOperatorCondition().
| bool MathLib::isHex | ( | const std::string & | str | ) | [static] |
Definition at line 137 of file mathlib.cpp.
Referenced by TokenList::addtoken(), TokenList::createTokens(), isInt(), toDoubleNumber(), and toLongNumber().
| bool MathLib::isInt | ( | const std::string & | str | ) | [static] |
Definition at line 149 of file mathlib.cpp.
References isHex(), isOct(), and isOctalDigit().
Referenced by add(), CheckOther::checkMathFunctions(), CheckOther::checkZeroDivision(), divide(), for_maxvalue(), mod(), multiply(), TemplateSimplifier::simplifyCalculations(), Tokenizer::simplifyConditions(), Tokenizer::simplifyKnownVariablesSimplify(), Tokenizer::simplifyMathFunctions(), Tokenizer::simplifyNull(), and subtract().
| bool MathLib::isLess | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 390 of file mathlib.cpp.
References toDoubleNumber().
Referenced by analyzeLogicOperatorCondition().
| bool MathLib::isLessEqual | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 395 of file mathlib.cpp.
References toDoubleNumber().
Referenced by analyzeLogicOperatorCondition(), and CheckOther::checkModuloAlwaysTrueFalse().
| bool MathLib::isNegative | ( | const std::string & | str | ) | [static] |
Definition at line 121 of file mathlib.cpp.
Referenced by CheckOther::checkCCTypeFunctions(), and CheckOther::checkMathFunctions().
| bool MathLib::isNotEqual | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 375 of file mathlib.cpp.
References isEqual().
Referenced by analyzeLogicOperatorCondition().
| bool MathLib::isNullValue | ( | const std::string & | tok | ) | [static] |
Definition at line 400 of file mathlib.cpp.
Referenced by CheckOther::checkMathFunctions(), and toDoubleNumber().
| bool MathLib::isOct | ( | const std::string & | str | ) | [static] |
Definition at line 131 of file mathlib.cpp.
References isFloat(), and isOctalDigit().
Referenced by TokenList::addtoken(), isInt(), and toLongNumber().
| bool MathLib::isOctalDigit | ( | char | c | ) | [static] |
Return true if given character is 0,1,2,3,4,5,6 or 7.
| c | The character to check |
Definition at line 410 of file mathlib.cpp.
Referenced by isInt(), isOct(), and Tokenizer::simplifyString().
| std::string MathLib::longToString | ( | const bigint | value | ) | [static] |
Definition at line 78 of file mathlib.cpp.
Referenced by add(), Tokenizer::arraySize(), calculate(), CheckOther::checkPipeParameterSize(), divide(), for_condition(), for_maxvalue(), mod(), multiply(), Tokenizer::removeRedundantFor(), TemplateSimplifier::simplifyCalculations(), Tokenizer::simplifyEnum(), Tokenizer::simplifyFileAndLineMacro(), Tokenizer::simplifyFuncInWhile(), Tokenizer::simplifyKnownVariablesGetData(), Tokenizer::simplifyMathFunctions(), TemplateSimplifier::simplifyNumericCalculations(), Tokenizer::simplifySizeof(), Tokenizer::simplifyStructDecl(), Tokenizer::simplifyTemplates(), splitDefinitionFromTypedef(), subtract(), and CheckBufferOverrun::writeOutsideBufferSizeError().
| std::string MathLib::mod | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 303 of file mathlib.cpp.
References doubleToString(), isInt(), longToString(), toDoubleNumber(), and toLongNumber().
Referenced by calculate().
| std::string MathLib::multiply | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 295 of file mathlib.cpp.
References doubleToString(), isInt(), longToString(), toDoubleNumber(), and toLongNumber().
Referenced by calculate(), CheckBufferOverrun::checkFunctionParameter(), TemplateSimplifier::simplifyCalculations(), and TemplateSimplifier::simplifyNumericCalculations().
| std::string MathLib::sin | ( | const std::string & | tok | ) | [static] |
Definition at line 346 of file mathlib.cpp.
References doubleToString(), and toDoubleNumber().
| std::string MathLib::subtract | ( | const std::string & | first, |
| const std::string & | second | ||
| ) | [static] |
Definition at line 260 of file mathlib.cpp.
References doubleToString(), isInt(), longToString(), toDoubleNumber(), and toLongNumber().
Referenced by calculate(), for_init(), and TemplateSimplifier::simplifyNumericCalculations().
| std::string MathLib::tan | ( | const std::string & | tok | ) | [static] |
Definition at line 357 of file mathlib.cpp.
References doubleToString(), and toDoubleNumber().
| double MathLib::toDoubleNumber | ( | const std::string & | str | ) | [static] |
Definition at line 85 of file mathlib.cpp.
References isHex(), isNullValue(), and toLongNumber().
Referenced by abs(), add(), CheckOther::checkMathFunctions(), cos(), divide(), isEqual(), isGreater(), isGreaterEqual(), isLess(), isLessEqual(), mod(), multiply(), Tokenizer::simplifyConditions(), sin(), subtract(), and tan().
| MathLib::bigint MathLib::toLongNumber | ( | const std::string & | str | ) | [static] |
Definition at line 31 of file mathlib.cpp.
References isBin(), isHex(), and isOct().
Referenced by add(), TokenList::addtoken(), Variable::arrayDimensions(), CheckBufferOverrun::arrayIndexInForLoop(), ExecutionPathBufferOverrun::assign_value(), CheckAssignIf::assignIf(), CheckAssignIf::assignIfParseScope(), calculate(), CheckBool::checkComparisonOfBoolWithInt(), CheckBufferOverrun::checkFunctionCall(), CheckBufferOverrun::checkFunctionParameter(), CheckBufferOverrun::checkGlobalAndLocalVariable(), CheckOther::checkIncompleteArrayFill(), CheckOther::checkIncorrectStringCompare(), CheckOther::checkMathFunctions(), CheckBufferOverrun::checkReadlinkBufferUsage(), CheckLeakAutoVar::checkScope(), CheckBufferOverrun::checkScope(), CheckBufferOverrun::checkScopeForBody(), CheckUninitVar::checkScopeForVariable(), CheckOther::checkSleepTimeInterval(), CheckBufferOverrun::checkStructVariable(), CheckOther::checkZeroDivision(), CheckAssignIf::comparison(), conditionAlwaysTrueOrFalse(), divide(), for3(), for_condition(), for_maxvalue(), CheckMemoryLeakInFunction::getcode(), CheckOther::invalidFunctionUsage(), mod(), CheckAssignIf::multiCondition(), multiply(), CheckBufferOverrun::negativeIndex(), UninitVar::parse(), Tokenizer::removeRedundantFor(), TemplateSimplifier::simplifyCalculations(), Tokenizer::simplifyCasts(), Tokenizer::simplifyCharAt(), Tokenizer::simplifyConditions(), Tokenizer::simplifyEnum(), Tokenizer::simplifyKnownVariablesGetData(), Tokenizer::simplifyMathFunctions(), Tokenizer::simplifyNull(), TemplateSimplifier::simplifyNumericCalculations(), Tokenizer::simplifySizeof(), subtract(), toDoubleNumber(), and CheckBufferOverrun::writeOutsideBufferSize().
1.7.6.1