Cppcheck
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | List of all members
ErrorMessage Class Reference

Wrapper for error messages, provided by reportErr() More...

#include <errorlogger.h>

Classes

class  FileLocation
 File name and line number. More...
 

Public Member Functions

 ErrorMessage (std::list< FileLocation > callStack, std::string file1, Severity severity, const std::string &msg, std::string id, Certainty certainty)
 
 ErrorMessage (std::list< FileLocation > callStack, std::string file1, Severity severity, const std::string &msg, std::string id, const CWE &cwe, Certainty certainty)
 
 ErrorMessage (const std::list< const Token * > &callstack, const TokenList *list, Severity severity, std::string id, const std::string &msg, Certainty certainty)
 
 ErrorMessage (const std::list< const Token * > &callstack, const TokenList *list, Severity severity, std::string id, const std::string &msg, const CWE &cwe, Certainty certainty)
 
 ErrorMessage (const ErrorPath &errorPath, const TokenList *tokenList, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
 
 ErrorMessage ()
 
 ErrorMessage (const tinyxml2::XMLElement *const errmsg)
 
std::string toXML () const
 Format the error message in XML format. More...
 
std::string toString (bool verbose, const std::string &templateFormat=emptyString, const std::string &templateLocation=emptyString) const
 Format the error message into a string. More...
 
std::string serialize () const
 
void deserialize (const std::string &data)
 
void setmsg (const std::string &msg)
 set short and verbose messages More...
 
const std::string & shortMessage () const
 Short message (single line short message) More...
 
const std::string & verboseMessage () const
 Verbose message (may be the same as the short message) More...
 
const std::string & symbolNames () const
 Symbol names. More...
 

Static Public Member Functions

static std::string getXMLHeader (std::string productName)
 
static std::string getXMLFooter ()
 
static ErrorMessage fromInternalError (const InternalError &internalError, const TokenList *tokenList, const std::string &filename, const std::string &msg=emptyString)
 

Public Attributes

std::list< FileLocationcallStack
 
std::string id
 
std::string file0
 For GUI rechecking; source file (not header) More...
 
Severity severity
 
CWE cwe
 
Certainty certainty
 
std::size_t hash
 Warning hash. More...
 

Static Private Member Functions

static std::string fixInvalidChars (const std::string &raw)
 

Private Attributes

std::string mShortMessage
 Short message. More...
 
std::string mVerboseMessage
 Verbose message. More...
 
std::string mSymbolNames
 symbol names More...
 

Detailed Description

Wrapper for error messages, provided by reportErr()

Definition at line 48 of file errorlogger.h.

Constructor & Destructor Documentation

◆ ErrorMessage() [1/7]

ErrorMessage::ErrorMessage ( std::list< FileLocation callStack,
std::string  file1,
Severity  severity,
const std::string &  msg,
std::string  id,
Certainty  certainty 
)

Definition at line 63 of file errorlogger.cpp.

References setmsg().

◆ ErrorMessage() [2/7]

ErrorMessage::ErrorMessage ( std::list< FileLocation callStack,
std::string  file1,
Severity  severity,
const std::string &  msg,
std::string  id,
const CWE cwe,
Certainty  certainty 
)

Definition at line 78 of file errorlogger.cpp.

References setmsg().

◆ ErrorMessage() [3/7]

ErrorMessage::ErrorMessage ( const std::list< const Token * > &  callstack,
const TokenList list,
Severity  severity,
std::string  id,
const std::string &  msg,
Certainty  certainty 
)

Definition at line 91 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), and setmsg().

◆ ErrorMessage() [4/7]

ErrorMessage::ErrorMessage ( const std::list< const Token * > &  callstack,
const TokenList list,
Severity  severity,
std::string  id,
const std::string &  msg,
const CWE cwe,
Certainty  certainty 
)

Definition at line 110 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), hash, and setmsg().

◆ ErrorMessage() [5/7]

ErrorMessage::ErrorMessage ( const ErrorPath errorPath,
const TokenList tokenList,
Severity  severity,
const char  id[],
const std::string &  msg,
const CWE cwe,
Certainty  certainty 
)

Definition at line 130 of file errorlogger.cpp.

References callStack, file0, TokenList::getFiles(), hash, replaceStr(), setmsg(), and startsWith().

◆ ErrorMessage() [6/7]

ErrorMessage::ErrorMessage ( )

Definition at line 58 of file errorlogger.cpp.

References none, and normal.

◆ ErrorMessage() [7/7]

ErrorMessage::ErrorMessage ( const tinyxml2::XMLElement *const  errmsg)
explicit

Member Function Documentation

◆ deserialize()

void ErrorMessage::deserialize ( const std::string &  data)

◆ fixInvalidChars()

std::string ErrorMessage::fixInvalidChars ( const std::string &  raw)
staticprivate

Definition at line 461 of file errorlogger.cpp.

Referenced by serialize(), and toXML().

◆ fromInternalError()

ErrorMessage ErrorMessage::fromInternalError ( const InternalError internalError,
const TokenList tokenList,
const std::string &  filename,
const std::string &  msg = emptyString 
)
static

◆ getXMLFooter()

std::string ErrorMessage::getXMLFooter ( )
static

◆ getXMLHeader()

std::string ErrorMessage::getXMLHeader ( std::string  productName)
static

◆ serialize()

std::string ErrorMessage::serialize ( ) const

◆ setmsg()

void ErrorMessage::setmsg ( const std::string &  msg)

set short and verbose messages

Definition at line 210 of file errorlogger.cpp.

References endsWith(), mShortMessage, mSymbolNames, mVerboseMessage, replaceStr(), and startsWith().

Referenced by CppCheck::analyseClangTidy(), and ErrorMessage().

◆ shortMessage()

const std::string& ErrorMessage::shortMessage ( ) const
inline

Short message (single line short message)

Definition at line 181 of file errorlogger.h.

Referenced by ErrorLogger::plistData().

◆ symbolNames()

const std::string& ErrorMessage::symbolNames ( ) const
inline

Symbol names.

Definition at line 191 of file errorlogger.h.

◆ toString()

std::string ErrorMessage::toString ( bool  verbose,
const std::string &  templateFormat = emptyString,
const std::string &  templateLocation = emptyString 
) const

Format the error message into a string.

Parameters
verboseuse verbose message
templateFormatEmpty string to use default output format or template to be used. E.g. "{file}:{line},{severity},{id},{message}"
templateLocationFormat Empty string to use default output format or template to be used. E.g. "{file}:{line},{info}"
Returns
formatted string

Definition at line 604 of file errorlogger.cpp.

References callStack, ErrorLogger::callStackToString(), certainty, cwe, findAndReplace(), CWE::id, inconclusive, mShortMessage, mVerboseMessage, none, readCode(), replace(), severity, and severityToString().

Referenced by Executor::hasToLog(), and CppCheck::reportErr().

◆ toXML()

std::string ErrorMessage::toXML ( ) const

◆ verboseMessage()

const std::string& ErrorMessage::verboseMessage ( ) const
inline

Verbose message (may be the same as the short message)

Definition at line 186 of file errorlogger.h.

Member Data Documentation

◆ callStack

std::list<FileLocation> ErrorMessage::callStack

◆ certainty

Certainty ErrorMessage::certainty

Definition at line 172 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), toString(), and toXML().

◆ cwe

CWE ErrorMessage::cwe

Definition at line 171 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), toString(), and toXML().

◆ file0

std::string ErrorMessage::file0

For GUI rechecking; source file (not header)

Definition at line 168 of file errorlogger.h.

Referenced by CppCheck::analyseClangTidy(), deserialize(), ErrorMessage(), Executor::hasToLog(), CppCheck::reportErr(), serialize(), and toXML().

◆ hash

std::size_t ErrorMessage::hash

Warning hash.

Definition at line 175 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), and toXML().

◆ id

std::string ErrorMessage::id

◆ mShortMessage

std::string ErrorMessage::mShortMessage
private

Short message.

Definition at line 201 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), serialize(), setmsg(), toString(), and toXML().

◆ mSymbolNames

std::string ErrorMessage::mSymbolNames
private

symbol names

Definition at line 207 of file errorlogger.h.

Referenced by ErrorMessage(), setmsg(), and toXML().

◆ mVerboseMessage

std::string ErrorMessage::mVerboseMessage
private

Verbose message.

Definition at line 204 of file errorlogger.h.

Referenced by deserialize(), ErrorMessage(), fromInternalError(), serialize(), setmsg(), toString(), and toXML().

◆ severity

Severity ErrorMessage::severity

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