AiLibrary  v1.3.0
A single-header C++ Library from Ailurus Studio
String Functions

Functions providing additional methods to work with strings. More...

Functions

template<typename T >
INLINE std::string ai::string (const T value)
 Converts input into a string. More...
 
INLINE bool ai::hasPrefix (const std::string &text, const std::string &prefix)
 Checks if a string begins with a substring. More...
 
INLINE bool ai::hasSuffix (const std::string &text, const std::string &suffix)
 Checks if a string ends with a substring. More...
 
INLINE bool ai::contains (const std::string &text, const std::string &substring)
 Checks if a string contains a substring. More...
 
INLINE std::string ai::replace (std::string text, const std::string &substring, const std::string &replacement)
 Replaces all occurrences of a substring in a copy of the initial string with your text. More...
 
INLINE void ai::applyReplace (std::string &text, const std::string &substring, const std::string &replacement)
 Modifies your string by replacing all occurrences of a substring string with your text. More...
 
INLINE bool ai::equal (const char *charString, const std::string string1)
 Checks if a char string is equal to a std::string. More...
 
INLINE std::string ai::toUpperCase (std::string input)
 Convert a string to upper case. More...
 
INLINE std::string ai::toLowerCase (std::string input)
 Convert a string to lower case. More...
 
template<typename T >
INLINE std::string ai::prependNumber (const T value, const std::size_t symbolsBeforePoint, const char symbolToPrepend='0')
 

Detailed Description

Group of functions that allows you to freely manipulate and analyze strings

Function Documentation

◆ applyReplace()

void ai::applyReplace ( std::string &  text,
const std::string &  substring,
const std::string &  replacement 
)

This function replaces all occurrences of a substring in a string with your text (modifies the initial string)

Parameters
textYour string to modify
substringYour substring to find in the string
replacementReplacement for all the substring occurrences

◆ contains()

bool ai::contains ( const std::string &  text,
const std::string &  substring 
)

This function checks if a string contains a substring

Parameters
textYour string to test
substringYour substring
Returns
True if string contains a substring, false otherwise

◆ equal()

bool ai::equal ( const char *  charString,
const std::string  string1 
)

This function compares a char string with a std::string

Parameters
charStringYour char string to compare
string1Your std::string to compare
Returns
True if strings are equal, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasPrefix()

bool ai::hasPrefix ( const std::string &  text,
const std::string &  prefix 
)

This function checks if a string begins with a substring

Parameters
textYour string to test
prefixYour substring
Returns
True if string begins with a substring, false otherwise
Here is the caller graph for this function:

◆ hasSuffix()

bool ai::hasSuffix ( const std::string &  text,
const std::string &  suffix 
)

This function checks if a string ends with a substring

Parameters
textYour string to test
suffixYour substring
Returns
True if string ends with a substring, false otherwise

◆ prependNumber()

template<typename T >
INLINE std::string ai::prependNumber ( const T  value,
const std::size_t  symbolsBeforePoint,
const char  symbolToPrepend = '0' 
)
Here is the call graph for this function:

◆ replace()

std::string ai::replace ( std::string  text,
const std::string &  substring,
const std::string &  replacement 
)

This function replaces all occurrences of a substring in a string with your text and return the result. Initial string stays the same

Parameters
textYour string to modify
substringYour substring to find in the string
replacementReplacement for all the substring occurrences
Returns
Modified copy of the initial string

◆ string()

template<typename T >
std::string ai::string ( const T  value)

This function converts your variable into std::string using std::ostringstream

Template Parameters
TAny printable type
Parameters
valueYour variable to convert
Returns
std::string copy of your input
Here is the caller graph for this function:

◆ toLowerCase()

std::string ai::toLowerCase ( std::string  input)

This function converts the given string to lower case and returns the result

Parameters
inputString to convert
Returns
Lowercase string
Here is the caller graph for this function:

◆ toUpperCase()

std::string ai::toUpperCase ( std::string  input)

This function converts the given string to upper case and returns the result

Parameters
inputString to convert
Returns
Uppercase string
Here is the caller graph for this function: