Loading...
Searching...
No Matches
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. More...
static const bool | isNumeric (const std::string &str)
| Checks whether a string only contains numeric characters. More...
static const bool | isNumeric (const unsigned char &chr)
| Checks whether character is numeric. More...
static const bool | isAlphabetic (const std::string &str)
| Checks whether a string only contains alphabetic characters. More...
static const bool | isAlphabetic (const unsigned char &chr)
| Checks whether a character is alphabetic. More...
static const bool | isAlnum (const std::string &str)
| Checks whether a string only contains alpha-numeric characters. More...
static const bool | isAlnum (const unsigned char &chr)
| Checks whether a character is alpha-numeric. More...
static const bool | isHex (const unsigned char &chr)
| Checks whether a string only contains hexadecimal characters. More...
static const bool | isIP (const std::string &str)
| Checks whether a string could be a valid IPv4/IPv6. More...
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. More...
static const bool | startsWith (const std::string &str, const std::string &flag)
| Checks if a string starts with the given sequence. More...
static const bool | endsWith (const std::string &str, const std::string &flag)
| Checks if a string ends with the given sequence. More...
static const bool | contains (const std::string &str, const std::string &flag)
| Checks if a string contains the given sequence. More...
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. More...
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. More...
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. More...
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) More...
static void | split (std::vector< std::string > &list, const std::string &target_str, const std::string &separator="\n")
| Splits a string using a separator. More...
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. More...
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. More...
static const std::string | toUpper (const std::string &str)
| Converts a string to upper case. More...
static const std::string | toLower (const std::string &str)
| Converts a string to lower case. More...

## 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

  str | The target string
  flag | The 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

  str | The 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

  str | The target string
  flag | The 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

  str | The target string
  flag | The sequence to search for

Returns
  The position of the last occurrence

## isAlnum() [1/2]

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

static

Checks whether a string only contains alpha-numeric characters.

Parameters

  str | The target string

Returns
  The result of the check

## isAlnum() [2/2]

const bool StringOps::isAlnum | ( | const unsigned char & | chr | ) |

static

Checks whether a character is alpha-numeric.

Parameters

  str | The target character

Returns
  The result of the check

See also
  isAlnum

## isAlphabetic() [1/2]

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

static

Checks whether a string only contains alphabetic characters.

Parameters

  str | The target string

Returns
  The result of the check

## isAlphabetic() [2/2]

const bool StringOps::isAlphabetic | ( | const unsigned char & | chr | ) |

static

Checks whether a character is alphabetic.

Parameters

  str | The target character

Returns
  The result of the check

See also
  isAlphabetic()

## isHex()

const bool StringOps::isHex | ( | const unsigned char & | chr | ) |

static

Checks whether a string only contains hexadecimal characters.

Parameters

  str | The 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

  str | The target string

Returns
  The result of the check

## isNumeric() [1/2]

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

static

Checks whether a string only contains numeric characters.

Parameters

  str | The target string

Returns
  The result of the check

## isNumeric() [2/2]

const bool StringOps::isNumeric | ( | const unsigned char & | chr | ) |

static

Checks whether character is numeric.

Parameters

  str | The target character

Returns
  The result of the check

See also
  isNumeric()

## 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

  str | The target string
  chars | The 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

  str | The target string
  chr | The delimiter
  inclusive | Whether to also strip the delimiter or not
  consecutives | Whether 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

  str | The target string
  target | The sequence which will be replaced
  replace | The 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

  str | The target string
  chars | The 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

  list | Will hold the splitted content
  target_str | The target string
  separator | The 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

  list | Will hold the splitted content
  target_str | The target string
  separator | The sequence to use as separator
  strip | The 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

  str | The target string
  flag | The 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

  str | The target string
  chars | The 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

  str | The target string

Returns
  The result string

## toUpper()

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

static

Converts a string to upper case.

Parameters

  str | The target string

Returns
  The result string

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

- logdoctor/utilities/strings.h
- logdoctor/utilities/strings.cpp