Cppcheck
Public Types | Static Public Member Functions
MathLib Class Reference

simple math functions that uses operands stored in std::string. More...

#include <mathlib.h>

List of all members.

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.

Detailed Description

simple math functions that uses operands stored in std::string.

useful when performing math on tokens.

Definition at line 32 of file mathlib.h.


Member Typedef Documentation

typedef long long MathLib::bigint

Definition at line 34 of file mathlib.h.


Member Function Documentation

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]
std::string MathLib::calculate ( const std::string &  first,
const std::string &  second,
char  action 
) [static]
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]
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]
bool MathLib::isInt ( const std::string &  str) [static]
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]
bool MathLib::isNegative ( const std::string &  str) [static]
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.

Parameters:
cThe character to check
Returns:
true if given character is octal digit.

Definition at line 410 of file mathlib.cpp.

Referenced by isInt(), isOct(), and Tokenizer::simplifyString().

std::string MathLib::longToString ( const bigint  value) [static]
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]
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]
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]
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().


The documentation for this class was generated from the following files: