Functions providing additional methods to work with strings.
More...
|
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') |
|
Group of functions that allows you to freely manipulate and analyze strings
◆ 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
-
text | Your string to modify |
substring | Your substring to find in the string |
replacement | Replacement 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
-
text | Your string to test |
substring | Your 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
-
charString | Your char string to compare |
string1 | Your std::string to compare |
- Returns
- True if strings are equal, false otherwise
◆ hasPrefix()
bool ai::hasPrefix |
( |
const std::string & |
text, |
|
|
const std::string & |
prefix |
|
) |
| |
This function checks if a string begins with a substring
- Parameters
-
text | Your string to test |
prefix | Your substring |
- Returns
- True if string begins with a substring, false otherwise
◆ hasSuffix()
bool ai::hasSuffix |
( |
const std::string & |
text, |
|
|
const std::string & |
suffix |
|
) |
| |
This function checks if a string ends with a substring
- Parameters
-
text | Your string to test |
suffix | Your 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' |
|
) |
| |
◆ 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
-
text | Your string to modify |
substring | Your substring to find in the string |
replacement | Replacement 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
-
- Parameters
-
value | Your variable to convert |
- Returns
- std::string copy of your input
◆ toLowerCase()
std::string ai::toLowerCase |
( |
std::string |
input | ) |
|
This function converts the given string to lower case and returns the result
- Parameters
-
- Returns
- Lowercase string
◆ toUpperCase()
std::string ai::toUpperCase |
( |
std::string |
input | ) |
|
This function converts the given string to upper case and returns the result
- Parameters
-
- Returns
- Uppercase string