Cppcheck
Public Member Functions | Private Member Functions | Private Attributes
PreprocessorMacro Class Reference

Class that the preprocessor uses when it expands macros. More...

List of all members.

Public Member Functions

 PreprocessorMacro (const std::string &macro)
 Constructor for PreprocessorMacro.
const Tokentokens () const
 return tokens of this macro
const std::vector< std::string > & params () const
 read parameters of this macro
bool variadic () const
 check if this is macro has a variable number of parameters
bool nopar () const
 Check if this macro has parentheses but no parameters.
const std::string & name () const
 name of macro
bool code (const std::vector< std::string > &params2, const std::map< std::string, PreprocessorMacro * > &macros, std::string &macrocode) const
 get expanded code for this macro

Private Member Functions

void operator= (const PreprocessorMacro &)
 disabled assignment operator
std::vector< std::string > expandInnerMacros (const std::vector< std::string > &params1, const std::map< std::string, PreprocessorMacro * > &macros) const
 expand inner macro

Private Attributes

Settings settings
Tokenizer tokenizer
 tokens of this macro
std::vector< std::string > _params
 macro parameters
std::string _name
 name of macro
const std::string _macro
 macro definition in plain text
const std::string _prefix
 prefix that is used by cppcheck to separate macro parameters.
bool _variadic
 does this macro take a variable number of parameters?
bool _nopar
 The macro has parentheses but no parameters.

Detailed Description

Class that the preprocessor uses when it expands macros.

This class represents a preprocessor macro

Definition at line 2349 of file preprocessor.cpp.


Constructor & Destructor Documentation

PreprocessorMacro::PreprocessorMacro ( const std::string &  macro) [inline, explicit]

Constructor for PreprocessorMacro.

This is the "setter" for this class - everything is setup here.

Parameters:
macroThe code after define, until end of line, e.g. "A(x) foo(x);"

Definition at line 2436 of file preprocessor.cpp.

References _name, _nopar, _params, _variadic, TokenList::createTokens(), Tokenizer::list, Token::Match(), Token::next(), Tokenizer::setSettings(), settings, Token::simpleMatch(), Token::str(), tokenizer, and tokens().


Member Function Documentation

bool PreprocessorMacro::code ( const std::vector< std::string > &  params2,
const std::map< std::string, PreprocessorMacro * > &  macros,
std::string &  macrocode 
) const [inline]

get expanded code for this macro

Parameters:
params2macro parameters
macrosmacro definitions (recursion)
macrocodeoutput string
Returns:
true if the expanding was successful

Definition at line 2509 of file preprocessor.cpp.

References _macro, _nopar, _params, _variadic, expandInnerMacros(), Token::isName(), Token::Match(), Token::next(), Token::simpleMatch(), Token::str(), Token::strAt(), and tokens().

Referenced by expandInnerMacros(), and Preprocessor::expandMacros().

std::vector<std::string> PreprocessorMacro::expandInnerMacros ( const std::vector< std::string > &  params1,
const std::map< std::string, PreprocessorMacro * > &  macros 
) const [inline, private]

expand inner macro

Definition at line 2378 of file preprocessor.cpp.

References code(), Token::findsimplematch(), getparams(), Token::Match(), Token::strAt(), Token::tokAt(), and tokens().

Referenced by code().

const std::string& PreprocessorMacro::name ( ) const [inline]

name of macro

Definition at line 2498 of file preprocessor.cpp.

References _name.

Referenced by Preprocessor::expandMacros().

bool PreprocessorMacro::nopar ( ) const [inline]

Check if this macro has parentheses but no parameters.

Definition at line 2493 of file preprocessor.cpp.

References _nopar.

Referenced by Preprocessor::expandMacros().

void PreprocessorMacro::operator= ( const PreprocessorMacro ) [private]

disabled assignment operator

const std::vector<std::string>& PreprocessorMacro::params ( ) const [inline]

read parameters of this macro

Definition at line 2483 of file preprocessor.cpp.

References _params.

Referenced by Preprocessor::expandMacros().

const Token* PreprocessorMacro::tokens ( ) const [inline]

return tokens of this macro

Definition at line 2478 of file preprocessor.cpp.

References tokenizer, and Tokenizer::tokens().

Referenced by code(), expandInnerMacros(), and PreprocessorMacro().

bool PreprocessorMacro::variadic ( ) const [inline]

check if this is macro has a variable number of parameters

Definition at line 2488 of file preprocessor.cpp.

References _variadic.

Referenced by Preprocessor::expandMacros().


Member Data Documentation

const std::string PreprocessorMacro::_macro [private]

macro definition in plain text

Definition at line 2363 of file preprocessor.cpp.

Referenced by code().

std::string PreprocessorMacro::_name [private]

name of macro

Definition at line 2360 of file preprocessor.cpp.

Referenced by name(), and PreprocessorMacro().

bool PreprocessorMacro::_nopar [private]

The macro has parentheses but no parameters.

. "AAA()"

Definition at line 2372 of file preprocessor.cpp.

Referenced by code(), nopar(), and PreprocessorMacro().

std::vector<std::string> PreprocessorMacro::_params [private]

macro parameters

Definition at line 2357 of file preprocessor.cpp.

Referenced by code(), params(), and PreprocessorMacro().

const std::string PreprocessorMacro::_prefix [private]

prefix that is used by cppcheck to separate macro parameters.

Always "__cppcheck__"

Definition at line 2366 of file preprocessor.cpp.

does this macro take a variable number of parameters?

Definition at line 2369 of file preprocessor.cpp.

Referenced by code(), PreprocessorMacro(), and variadic().

Definition at line 2351 of file preprocessor.cpp.

Referenced by PreprocessorMacro().

tokens of this macro

Definition at line 2354 of file preprocessor.cpp.

Referenced by PreprocessorMacro(), and tokens().


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