Cppcheck
Functions
utils.cpp File Reference
#include "utils.h"
#include <algorithm>
#include <cctype>
#include <iterator>
#include <stack>
#include <utility>

Go to the source code of this file.

Functions

int caseInsensitiveStringCompare (const std::string &lhs, const std::string &rhs)
 
bool isValidGlobPattern (const std::string &pattern)
 
bool matchglob (const std::string &pattern, const std::string &name)
 
bool matchglobs (const std::vector< std::string > &patterns, const std::string &name)
 
void strTolower (std::string &str)
 
std::string trim (const std::string &s, const std::string &t)
 Remove heading and trailing whitespaces from the input parameter. More...
 
void findAndReplace (std::string &source, const std::string &searchFor, const std::string &replaceWith)
 Replace all occurrences of searchFor with replaceWith in the given source. More...
 

Function Documentation

◆ caseInsensitiveStringCompare()

int caseInsensitiveStringCompare ( const std::string &  lhs,
const std::string &  rhs 
)

Definition at line 28 of file utils.cpp.

Referenced by cppcheck::stricmp::operator()(), and Path::sameFileName().

◆ findAndReplace()

void findAndReplace ( std::string &  source,
const std::string &  searchFor,
const std::string &  replaceWith 
)

Replace all occurrences of searchFor with replaceWith in the given source.

Parameters
sourceThe string to modify
searchForWhat should be searched for
replaceWithWhat will replace the found item

Definition at line 142 of file utils.cpp.

Referenced by ErrorMessage::toString().

◆ isValidGlobPattern()

bool isValidGlobPattern ( const std::string &  pattern)

Definition at line 41 of file utils.cpp.

Referenced by SuppressionList::addSuppression(), and ImportProject::ignorePaths().

◆ matchglob()

bool matchglob ( const std::string &  pattern,
const std::string &  name 
)

◆ matchglobs()

bool matchglobs ( const std::vector< std::string > &  patterns,
const std::string &  name 
)

Definition at line 118 of file utils.cpp.

References matchglob().

Referenced by ImportProject::importVcxproj().

◆ strTolower()

void strTolower ( std::string &  str)

◆ trim()

std::string trim ( const std::string &  s,
const std::string &  t = " \t" 
)

Remove heading and trailing whitespaces from the input parameter.

If string is all spaces/tabs, return empty string.

Parameters
sThe string to trim.
tThe characters to trim.

Definition at line 133 of file utils.cpp.