Cppcheck
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Private Member Functions | Friends | List of all members
CppCheckExecutor Class Reference

This class works as an example of how CppCheck can be used in external programs without very little knowledge of the internal parts of the program itself. More...

#include <cppcheckexecutor.h>

Public Member Functions

 CppCheckExecutor ()=default
 Constructor. More...
 
 CppCheckExecutor (const CppCheckExecutor &)=delete
 
CppCheckExecutoroperator= (const CppCheckExecutor &)=delete
 
int check (int argc, const char *const argv[])
 Starts the checking. More...
 

Static Public Member Functions

static void setExceptionOutput (FILE *exceptionOutput)
 
static FILE * getExceptionOutput ()
 

Protected Member Functions

int check_wrapper (const Settings &settings)
 Wrapper around check_internal. More...
 
int check_internal (const Settings &settings) const
 Starts the checking. More...
 

Static Protected Member Functions

static bool reportSuppressions (const Settings &settings, const SuppressionList &suppressions, bool unusedFunctionCheckEnabled, const std::list< FileWithDetails > &files, const std::list< FileSettings > &fileSettings, ErrorLogger &errorLogger)
 

Protected Attributes

std::list< FileWithDetailsmFiles
 Filename associated with size of file. More...
 
std::list< FileSettingsmFileSettings
 

Static Private Member Functions

static int executeCommand (std::string exe, std::vector< std::string > args, std::string redirect, std::string &output_)
 Execute a shell command and read the output from it. More...
 

Friends

class TestSuppressions
 

Detailed Description

This class works as an example of how CppCheck can be used in external programs without very little knowledge of the internal parts of the program itself.

If you wish to use cppcheck e.g. as a part of IDE, just rewrite this class for your needs and possibly use other methods from CppCheck class instead the ones used here.

Definition at line 43 of file cppcheckexecutor.h.

Constructor & Destructor Documentation

◆ CppCheckExecutor() [1/2]

CppCheckExecutor::CppCheckExecutor ( )
default

Constructor.

◆ CppCheckExecutor() [2/2]

CppCheckExecutor::CppCheckExecutor ( const CppCheckExecutor )
delete

Member Function Documentation

◆ check()

int CppCheckExecutor::check ( int  argc,
const char *const  argv[] 
)

Starts the checking.

Parameters
argcfrom main()
argvfrom main()
Returns
EXIT_FAILURE if arguments are invalid or no input files were found. If errors are found and –error-exitcode is used, given value is returned instead of default 0. If no errors are found, 0 is returned.

Definition at line 185 of file cppcheckexecutor.cpp.

References check_wrapper(), executeCommand(), CmdLineParser::fillSettingsFromArgs(), CmdLineParser::getFiles(), CmdLineParser::getFileSettings(), Settings::loadSummaries(), mFiles, mFileSettings, Settings::setMisraRuleTexts(), Settings::supprs, and Settings::terminated().

Referenced by main().

◆ check_internal()

int CppCheckExecutor::check_internal ( const Settings settings) const
protected

◆ check_wrapper()

int CppCheckExecutor::check_wrapper ( const Settings settings)
protected

Wrapper around check_internal.

  • installs optional platform dependent signal handling
Parameters
settingsthe settings

Definition at line 209 of file cppcheckexecutor.cpp.

References check_internal().

Referenced by check().

◆ executeCommand()

int CppCheckExecutor::executeCommand ( std::string  exe,
std::vector< std::string >  args,
std::string  redirect,
std::string &  output_ 
)
staticprivate

Execute a shell command and read the output from it.

Returns exitcode of the executed command,.

Returns true if command terminated successfully.

Definition at line 475 of file cppcheckexecutor.cpp.

Referenced by check(), and check_internal().

◆ getExceptionOutput()

static FILE* CppCheckExecutor::getExceptionOutput ( )
static
Returns
file name to be used for output from exception handler. Has to be either "stdout" or "stderr".

◆ operator=()

CppCheckExecutor& CppCheckExecutor::operator= ( const CppCheckExecutor )
delete

◆ reportSuppressions()

bool CppCheckExecutor::reportSuppressions ( const Settings settings,
const SuppressionList suppressions,
bool  unusedFunctionCheckEnabled,
const std::list< FileWithDetails > &  files,
const std::list< FileSettings > &  fileSettings,
ErrorLogger errorLogger 
)
staticprotected

◆ setExceptionOutput()

static void CppCheckExecutor::setExceptionOutput ( FILE *  exceptionOutput)
static
Parameters
exceptionOutputOutput file

Referenced by CmdLineParser::parseFromArgs().

Friends And Related Function Documentation

◆ TestSuppressions

friend class TestSuppressions
friend

Definition at line 45 of file cppcheckexecutor.h.

Member Data Documentation

◆ mFiles

std::list<FileWithDetails> CppCheckExecutor::mFiles
protected

Filename associated with size of file.

Definition at line 110 of file cppcheckexecutor.h.

Referenced by check(), and check_internal().

◆ mFileSettings

std::list<FileSettings> CppCheckExecutor::mFileSettings
protected

Definition at line 112 of file cppcheckexecutor.h.

Referenced by check(), and check_internal().


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