Cppcheck
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | List of all members
Platform Class Reference

Platform settings. More...

#include <platform.h>

Public Types

enum  Type {
  Unspecified , Native , Win32A , Win32W ,
  Win64 , Unix32 , Unix64 , File
}
 

Public Member Functions

 Platform ()
 
bool isIntValue (long long value) const
 
bool isIntValue (unsigned long long value) const
 
bool isLongValue (long long value) const
 
bool isLongValue (unsigned long long value) const
 
bool isLongLongValue (unsigned long long value) const
 
bool set (Type t)
 set the platform type for predefined platforms - deprecated use set(const std::string&, std::string&) instead More...
 
bool set (const std::string &platformstr, std::string &errstr, const std::vector< std::string > &paths={}, bool verbose=false)
 set the platform type More...
 
bool loadFromFile (const char exename[], const std::string &filename, bool verbose=false)
 load platform file More...
 
bool loadFromXmlDocument (const tinyxml2::XMLDocument *doc)
 load platform from xml document, primarily for testing More...
 
bool isWindows () const
 Returns true if platform type is Windows. More...
 
const char * toString () const
 
long long unsignedCharMax () const
 
long long signedCharMax () const
 
long long signedCharMin () const
 
std::string getLimitsDefines (Standards::cstd_t cstd) const
 provides list of defines specified by the limit.h/climits includes More...
 
std::string getLimitsDefines (Standards::cppstd_t cppstd) const
 provides list of defines specified by the limit.h/climits includes More...
 

Static Public Member Functions

static const char * toString (Type pt)
 

Public Attributes

nonneg int char_bit
 
nonneg int short_bit
 bits in char More...
 
nonneg int int_bit
 bits in short More...
 
nonneg int long_bit
 bits in int More...
 
nonneg int long_long_bit
 bits in long More...
 
std::size_t sizeof_bool
 bits in long long More...
 
std::size_t sizeof_short
 
std::size_t sizeof_int
 
std::size_t sizeof_long
 
std::size_t sizeof_long_long
 
std::size_t sizeof_float
 
std::size_t sizeof_double
 
std::size_t sizeof_long_double
 
std::size_t sizeof_wchar_t
 
std::size_t sizeof_size_t
 
std::size_t sizeof_pointer
 
char defaultSign
 
Type type
 platform type More...
 

Private Member Functions

std::string getLimitsDefines (bool c99) const
 provides list of defines specified by the limit.h/climits includes More...
 

Static Private Member Functions

static long long min_value (int bit)
 
static long long max_value (int bit)
 

Detailed Description

Platform settings.

Definition at line 43 of file platform.h.

Member Enumeration Documentation

◆ Type

Enumerator
Unspecified 
Native 
Win32A 
Win32W 
Win64 
Unix32 
Unix64 
File 

Definition at line 106 of file platform.h.

Constructor & Destructor Documentation

◆ Platform()

Platform::Platform ( )

Definition at line 30 of file platform.cpp.

References set().

Member Function Documentation

◆ getLimitsDefines() [1/3]

std::string Platform::getLimitsDefines ( bool  c99) const
private

provides list of defines specified by the limit.h/climits includes

Definition at line 298 of file platform.cpp.

References char_bit, defaultSign, int_bit, long_bit, long_long_bit, max_value(), min_value(), and short_bit.

Referenced by createDUI(), and getLimitsDefines().

◆ getLimitsDefines() [2/3]

std::string Platform::getLimitsDefines ( Standards::cppstd_t  cppstd) const

provides list of defines specified by the limit.h/climits includes

Definition at line 443 of file platform.cpp.

References getLimitsDefines().

◆ getLimitsDefines() [3/3]

std::string Platform::getLimitsDefines ( Standards::cstd_t  cstd) const

provides list of defines specified by the limit.h/climits includes

Definition at line 438 of file platform.cpp.

References getLimitsDefines().

◆ isIntValue() [1/2]

bool Platform::isIntValue ( long long  value) const
inline

◆ isIntValue() [2/2]

bool Platform::isIntValue ( unsigned long long  value) const
inline

Definition at line 66 of file platform.h.

◆ isLongLongValue()

bool Platform::isLongLongValue ( unsigned long long  value) const
inline

Definition at line 80 of file platform.h.

Referenced by SymbolDatabase::setValueTypeInTokenList().

◆ isLongValue() [1/2]

bool Platform::isLongValue ( long long  value) const
inline

Definition at line 71 of file platform.h.

Referenced by getEnumType(), and SymbolDatabase::setValueTypeInTokenList().

◆ isLongValue() [2/2]

bool Platform::isLongValue ( unsigned long long  value) const
inline

Definition at line 75 of file platform.h.

◆ isWindows()

bool Platform::isWindows ( ) const
inline

Returns true if platform type is Windows.

Returns
true if Windows platform type.

Definition at line 142 of file platform.h.

Referenced by CheckIO::checkFileUsage(), CheckIO::checkFormatString(), CheckOther::checkInterlockedDecrement(), CheckIO::checkWrongPrintfScanfArguments(), and Tokenizer::combineStringAndCharLiterals().

◆ loadFromFile()

bool Platform::loadFromFile ( const char  exename[],
const std::string &  filename,
bool  verbose = false 
)

load platform file

Parameters
exenameapplication path
filenameplatform filename
verboselog verbose information about the lookup
Returns
returns true if file was loaded successfully

Definition at line 192 of file platform.cpp.

References Path::fromNativeSeparators(), Path::getPathFromFilename(), and loadFromXmlDocument().

Referenced by MainWindow::getCppcheckSettings(), ProjectFileDialog::ProjectFileDialog(), and set().

◆ loadFromXmlDocument()

bool Platform::loadFromXmlDocument ( const tinyxml2::XMLDocument *  doc)

◆ max_value()

static long long Platform::max_value ( int  bit)
inlinestaticprivate

Definition at line 51 of file platform.h.

Referenced by getLimitsDefines().

◆ min_value()

static long long Platform::min_value ( int  bit)
inlinestaticprivate

Definition at line 45 of file platform.h.

Referenced by getLimitsDefines().

◆ set() [1/2]

bool Platform::set ( const std::string &  platformstr,
std::string &  errstr,
const std::vector< std::string > &  paths = {},
bool  verbose = false 
)

set the platform type

Definition at line 153 of file platform.cpp.

References loadFromFile(), and set().

◆ set() [2/2]

bool Platform::set ( Type  t)

set the platform type for predefined platforms - deprecated use set(const std::string&, std::string&) instead

Definition at line 36 of file platform.cpp.

References char_bit, defaultSign, int_bit, long_bit, long_long_bit, short_bit, sizeof_bool, sizeof_double, sizeof_float, sizeof_int, sizeof_long, sizeof_long_double, sizeof_long_long, sizeof_pointer, sizeof_short, sizeof_size_t, sizeof_wchar_t, and type.

Referenced by CppCheck::check(), MainWindow::getCppcheckSettings(), CmdLineParser::parseFromArgs(), Platform(), and set().

◆ signedCharMax()

long long Platform::signedCharMax ( ) const
inline

Definition at line 179 of file platform.h.

Referenced by setTokenValueCast().

◆ signedCharMin()

long long Platform::signedCharMin ( ) const
inline

Definition at line 183 of file platform.h.

Referenced by CheckFunctions::memsetInvalid2ndParam(), and setTokenValueCast().

◆ toString() [1/2]

const char* Platform::toString ( ) const
inline

◆ toString() [2/2]

static const char* Platform::toString ( Type  pt)
inlinestatic

Definition at line 152 of file platform.h.

◆ unsignedCharMax()

long long Platform::unsignedCharMax ( ) const
inline

Definition at line 175 of file platform.h.

Referenced by CheckFunctions::memsetInvalid2ndParam().

Member Data Documentation

◆ char_bit

nonneg int Platform::char_bit

◆ defaultSign

char Platform::defaultSign

◆ int_bit

nonneg int Platform::int_bit

◆ long_bit

nonneg int Platform::long_bit

◆ long_long_bit

nonneg int Platform::long_long_bit

◆ short_bit

nonneg int Platform::short_bit

◆ sizeof_bool

std::size_t Platform::sizeof_bool

bits in long long

size of standard types

Definition at line 92 of file platform.h.

Referenced by Tokenizer::fillTypeSizes(), loadFromXmlDocument(), set(), Preprocessor::setPlatformInfo(), and ValueType::typeSize().

◆ sizeof_double

std::size_t Platform::sizeof_double

◆ sizeof_float

std::size_t Platform::sizeof_float

◆ sizeof_int

std::size_t Platform::sizeof_int

◆ sizeof_long

std::size_t Platform::sizeof_long

◆ sizeof_long_double

std::size_t Platform::sizeof_long_double

◆ sizeof_long_long

std::size_t Platform::sizeof_long_long

◆ sizeof_pointer

std::size_t Platform::sizeof_pointer

◆ sizeof_short

std::size_t Platform::sizeof_short

◆ sizeof_size_t

std::size_t Platform::sizeof_size_t

◆ sizeof_wchar_t

std::size_t Platform::sizeof_wchar_t

◆ type

Type Platform::type

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