Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
TextUtilities Class Reference

Provides utilities process strings. More...

#include <TextUtilities.hpp>

Static Public Member Functions

static std::string trim (const std::string &str, const std::string &del)
 
static std::string splitExtension (std::string &str)
 
static std::string extractFilename (const std::string &str)
 
static void replace (std::string &source, const std::string &fromString, const std::string &toString)
 
static void replace (std::string &source, const std::string &fromChars, const char toChar)
 
static bool hasPrefix (const std::string &source, const std::string &prefix)
 
static bool hasSuffix (const std::string &source, const std::string &suffix)
 
static std::string join (const std::vector< std::string > &tokens, const std::string &delimiter)
 
static std::vector< std::string > split (const std::string &str, const std::string &delimiter, bool skipEmpty)
 
static std::vector< std::string > splitLines (const std::string &str, bool skipEmpty)
 
static std::string padInt (uint number, uint padding)
 
static std::string lowercase (const std::string &src)
 
static std::string uppercase (const std::string &src)
 

Detailed Description

Provides utilities process strings.

Member Function Documentation

◆ extractFilename()

std::string TextUtilities::extractFilename ( const std::string &  str)
static

Extract the filename from the end of a string (extension will be included).

Parameters
strthe string to extract the filename from
Returns
the filename string

◆ hasPrefix()

bool TextUtilities::hasPrefix ( const std::string &  source,
const std::string &  prefix 
)
static

Test if a string is a prefix of another string.

Parameters
sourcethe string to examine
prefixthe prefix string to test
Returns
true if the prefix is here

◆ hasSuffix()

bool TextUtilities::hasSuffix ( const std::string &  source,
const std::string &  suffix 
)
static

Test if a string is a suffix of another string.

Parameters
sourcethe string to examine
suffixthe suffix string to test
Returns
true if the suffix is here

◆ join()

std::string TextUtilities::join ( const std::vector< std::string > &  tokens,
const std::string &  delimiter 
)
static

Join a list of strings together using a custom delimiter.

Parameters
tokensthe list of strings to join
delimiterthe string that will be inserted between each pair of strings
Returns
the result of the join

◆ lowercase()

std::string TextUtilities::lowercase ( const std::string &  src)
static

Convert all upper case characters in a string to lower case.

Parameters
srcthe string to convert
Returns
the converted string

◆ padInt()

std::string TextUtilities::padInt ( uint  number,
uint  padding 
)
static

Generate a zero-padded string representation of an unsigned integer.

Parameters
numberthe number to represent as a string
paddingthe length to pad the number string to
Returns
the number string padded representation

◆ replace() [1/2]

void TextUtilities::replace ( std::string &  source,
const std::string &  fromChars,
const char  toChar 
)
static

Replace all listed characters by another character in a string.

Parameters
sourcethe string in which substitutions should happen
fromCharslist of characters
toCharnew character to insert

◆ replace() [2/2]

void TextUtilities::replace ( std::string &  source,
const std::string &  fromString,
const std::string &  toString 
)
static

Replace all occurences of a substring in a string by another string.

Parameters
sourcethe string in which substitutions should happen
fromStringsubstring to replace
toStringnew substring to insert

◆ split()

std::vector< std::string > TextUtilities::split ( const std::string &  str,
const std::string &  delimiter,
bool  skipEmpty 
)
static

Split a string into a list of tokens based on a given delimiter.

Parameters
strthe string to split
delimiterthe string that will be used as a splitting point
skipEmptyshould empty tokens be ignored
Returns
a list of tokens

◆ splitExtension()

std::string TextUtilities::splitExtension ( std::string &  str)
static

Remove file extension from the end of a string and extract it.

Parameters
strthe string to remove the extension from
Returns
the extension string

◆ splitLines()

std::vector< std::string > TextUtilities::splitLines ( const std::string &  str,
bool  skipEmpty 
)
static

Split a string into a list of lines. This function supports both '\n' and '\r\n'.

Parameters
strthe string to split
skipEmptyshould empty lines be ignored
Returns
a list of lines

◆ trim()

std::string TextUtilities::trim ( const std::string &  str,
const std::string &  del 
)
static

Trim characters from both ends of a string.

Parameters
strthe string to trim from
delthe characters to delete
Returns
the trimmed string

◆ uppercase()

std::string TextUtilities::uppercase ( const std::string &  src)
static

Convert all lower case characters in a string to upper case.

Parameters
srcthe string to convert
Returns
the converted string

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