LogDoctor 2.00
Parse Apache2/Nginx/IIS logs and create statistics
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
StringOps Class Reference

StringOps. More...

#include <strings.h>

Static Public Member Functions

static const int count (const std::string &str, const std::string &flag, const bool consecutives=true)
 Count the occurrences of the given sequence in the given string.
 
static const bool isNumeric (const std::string &str)
 Checks whether a string only contains numeric characters.
 
static const bool isNumeric (const char &chr)
 Checks whether character is numeric.
 
static const bool isAlphabetic (const std::string &str)
 Checks whether a string only contains alphabetic characters.
 
static const bool isAlphabetic (const char &chr)
 Checks whether a character is alphabetic.
 
static const bool isAlnum (const std::string &str)
 Checks whether a string only contains alpha-numeric characters.
 
static const bool isAlnum (const char &chr)
 Checks whether a character is alpha-numeric.
 
static const bool isHex (const char &chr)
 Checks whether a string only contains hexadecimal characters.
 
static const bool isIP (const std::string &str)
 Checks whether a string could be a valid IPv4/IPv6.
 
static const size_t findLast (const std::string &str, const std::string &flag)
 Finds the last occurrence of the given sequence in the given string.
 
static const bool startsWith (const std::string &str, const std::string &flag)
 Checks if a string starts with the given sequence.
 
static const bool endsWith (const std::string &str, const std::string &flag)
 Checks if a string ends with the given sequence.
 
static const bool contains (const std::string &str, const std::string &flag)
 Checks if a string contains the given sequence.
 
static std::string strip (const std::string &str, const std::string &chars=" \n\t\b\r\v")
 Strips the given characters from both the left and the right side of a string.
 
static std::string lstrip (const std::string &str, const std::string &chars=" \n\t\b\r\v")
 Strips the given characters from the left side of a string.
 
static std::string rstrip (const std::string &str, const std::string &chars=" \n\t\b\r\v")
 Strips the given characters from the right side of a string.
 
static std::string lstripUntil (const std::string &str, const std::string &chr, const bool &inclusive=true, const bool &consecutives=true)
 Strips everything from a string starting from the left side untill the delimiter is found (a.k.a. cut)
 
static void split (std::vector< std::string > &list, const std::string &target_str, const std::string &separator="\n")
 Splits a string using a separator.
 
static void splitrip (std::vector< std::string > &list, const std::string &target_str, const std::string &separator="\n", const std::string &strip=" \n\t\b\r\v")
 Splits a string and strips all the splitted items.
 
static const std::string replace (const std::string &str, const std::string &target, const std::string &replace)
 Replaces all the occurrences of a sequence with another.
 
static const std::string toUpper (const std::string &str)
 Converts a string to upper case.
 
static const std::string toLower (const std::string &str)
 Converts a string to lower case.
 

Detailed Description

StringOps.

Utilities for the strings

Member Function Documentation

◆ contains()

const bool StringOps::contains ( const std::string &  str,
const std::string &  flag 
)
static

Checks if a string contains the given sequence.

Parameters
strThe target string
flagThe sequence to search for
Returns
The result of the check

◆ count()

const int StringOps::count ( const std::string &  str,
const std::string &  flag,
const bool  consecutives = true 
)
static

Count the occurrences of the given sequence in the given string.

Parameters
strThe target string
Returns
The number of occurrences

◆ endsWith()

const bool StringOps::endsWith ( const std::string &  str,
const std::string &  flag 
)
static

Checks if a string ends with the given sequence.

Parameters
strThe target string
flagThe sequence to search for
Returns
The result of the check

◆ findLast()

const size_t StringOps::findLast ( const std::string &  str,
const std::string &  flag 
)
static

Finds the last occurrence of the given sequence in the given string.

Parameters
strThe target string
flagThe sequence to search for
Returns
The position of the last occurrence

◆ isAlnum() [1/2]

const bool StringOps::isAlnum ( const char &  chr)
static

Checks whether a character is alpha-numeric.

Parameters
strThe target character
Returns
The result of the check
See also
isAlnum

◆ isAlnum() [2/2]

const bool StringOps::isAlnum ( const std::string &  str)
static

Checks whether a string only contains alpha-numeric characters.

Parameters
strThe target string
Returns
The result of the check

◆ isAlphabetic() [1/2]

const bool StringOps::isAlphabetic ( const char &  chr)
static

Checks whether a character is alphabetic.

Parameters
strThe target character
Returns
The result of the check
See also
isAlphabetic()

◆ isAlphabetic() [2/2]

const bool StringOps::isAlphabetic ( const std::string &  str)
static

Checks whether a string only contains alphabetic characters.

Parameters
strThe target string
Returns
The result of the check

◆ isHex()

const bool StringOps::isHex ( const char &  chr)
static

Checks whether a string only contains hexadecimal characters.

Parameters
strThe target character
Returns
The result of the check

◆ isIP()

const bool StringOps::isIP ( const std::string &  str)
static

Checks whether a string could be a valid IPv4/IPv6.

Parameters
strThe target string
Returns
The result of the check

◆ isNumeric() [1/2]

const bool StringOps::isNumeric ( const char &  chr)
static

Checks whether character is numeric.

Parameters
strThe target character
Returns
The result of the check
See also
isNumeric()

◆ isNumeric() [2/2]

const bool StringOps::isNumeric ( const std::string &  str)
static

Checks whether a string only contains numeric characters.

Parameters
strThe target string
Returns
The result of the check

◆ lstrip()

std::string StringOps::lstrip ( const std::string &  str,
const std::string &  chars = " \n\t\b\r\v" 
)
static

Strips the given characters from the left side of a string.

Parameters
strThe target string
charsThe characters to strip away
Returns
The result string

◆ lstripUntil()

std::string StringOps::lstripUntil ( const std::string &  str,
const std::string &  chr,
const bool &  inclusive = true,
const bool &  consecutives = true 
)
static

Strips everything from a string starting from the left side untill the delimiter is found (a.k.a. cut)

Parameters
strThe target string
chrThe delimiter
inclusiveWhether to also strip the delimiter or not
consecutivesWhether to strip all the occurrences of the delimiter if they're consecutive
Returns
The result string

◆ replace()

const std::string StringOps::replace ( const std::string &  str,
const std::string &  target,
const std::string &  replace 
)
static

Replaces all the occurrences of a sequence with another.

Parameters
strThe target string
targetThe sequence which will be replaced
replaceThe sequence to be used to replace the target
Returns
The result string

◆ rstrip()

std::string StringOps::rstrip ( const std::string &  str,
const std::string &  chars = " \n\t\b\r\v" 
)
static

Strips the given characters from the right side of a string.

Parameters
strThe target string
charsThe characters to strip away
Returns
The result string

◆ split()

void StringOps::split ( std::vector< std::string > &  list,
const std::string &  target_str,
const std::string &  separator = "\n" 
)
static

Splits a string using a separator.

Parameters
listWill hold the splitted content
target_strThe target string
separatorThe sequence to use as separator

◆ splitrip()

void StringOps::splitrip ( std::vector< std::string > &  list,
const std::string &  target_str,
const std::string &  separator = "\n",
const std::string &  strip = " \n\t\b\r\v" 
)
static

Splits a string and strips all the splitted items.

Parameters
listWill hold the splitted content
target_strThe target string
separatorThe sequence to use as separator
stripThe characters to strip away

◆ startsWith()

const bool StringOps::startsWith ( const std::string &  str,
const std::string &  flag 
)
static

Checks if a string starts with the given sequence.

Parameters
strThe target string
flagThe sequence to search for
Returns
The result of the check

◆ strip()

std::string StringOps::strip ( const std::string &  str,
const std::string &  chars = " \n\t\b\r\v" 
)
static

Strips the given characters from both the left and the right side of a string.

Parameters
strThe target string
charsThe characters to strip away
Returns
The result string

◆ toLower()

const std::string StringOps::toLower ( const std::string &  str)
static

Converts a string to lower case.

Parameters
strThe target string
Returns
The result string

◆ toUpper()

const std::string StringOps::toUpper ( const std::string &  str)
static

Converts a string to upper case.

Parameters
strThe target string
Returns
The result string

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