namespace
StringString utilities.
Contents
- Reference
This library is built if WITH_UTILITY
is enabled when building Corrade. To use this library with CMake, you need to request the Utility
component of the Corrade
package and link to the Corrade::Utility
target.
find_package(Corrade REQUIRED Utility) # ... target_link_libraries(your-app Corrade::Utility)
See also Downloading and building Corrade and Using Corrade with CMake for more information.
Functions
-
auto ltrim(std::
string string) -> std:: string - Trim leading whitespace from string.
-
auto rtrim(std::
string string) -> std:: string - Trim trailing whitespace from string.
-
auto trim(std::
string string) -> std:: string - Trim leading and trailing whitespace from string.
-
void ltrimInPlace(std::
string& string) - Trim leading whitespace from string.
-
void rtrimInPlace(std::
string& string) - Trim trailing whitespace from string.
-
void trimInPlace(std::
string& string) - Trim leading and trailing whitespace from string.
-
auto splitWithoutEmptyParts(const std::
string& string) -> std:: vector<std:: string> - Split string on whitespaces and remove empty parts.
-
auto split(const std::
string& string, char delimiter) -> std:: vector<std:: string> - Split string on given character.
-
auto splitWithoutEmptyParts(const std::
string& string, char delimiter) -> std:: vector<std:: string> - Split string on given character and remove empty parts.
-
auto join(const std::
vector<std:: string>& strings, char delimiter) -> std:: string - Join strings with given character.
-
auto joinWithoutEmptyParts(const std::
vector<std:: string>& strings, char delimiter) -> std:: string - Join strings with given character and remove empty parts.
-
auto lowercase(std::
string string) -> std:: string - Convert string to lowercase.
-
auto uppercase(std::
string string) -> std:: string - Convert string to uppercase.
-
auto fromArray(const char* string) -> std::
string - Safely construct string from char array.
-
auto fromArray(const char* string,
std::
size_t length) -> std:: string - Safely construct string from char array with explicit length.
-
auto ltrim(std::
string string, const std:: string& characters) -> std:: string - Trim leading characters from string.
-
template<std::auto ltrim(std::
size_t size> string string, const char(&characters)[size]) -> std:: string -
auto rtrim(std::
string string, const std:: string& characters) -> std:: string - Trim trailing characters from string.
-
template<std::auto rtrim(std::
size_t size> string string, const char(&characters)[size]) -> std:: string -
auto trim(std::
string string, const std:: string& characters) -> std:: string - Trim leading and trailing characters from string.
-
template<std::auto trim(std::
size_t size> string string, const char(&characters)[size]) -> std:: string -
void ltrimInPlace(std::
string& string, const std:: string& characters) - Trim leading characters from string, in place.
-
template<std::void ltrimInPlace(std::
size_t size> string& string, const char(&characters)[size]) -
void rtrimInPlace(std::
string& string, const std:: string& characters) - Trim trailing characters from string.
-
template<std::void rtrimInPlace(std::
size_t size> string& string, const char(&characters)[size]) -
void trimInPlace(std::
string& string, const std:: string& characters) - Trim leading and trailing characters from string.
-
template<std::void trimInPlace(std::
size_t size> string& string, const char(&characters)[size]) -
auto splitWithoutEmptyParts(const std::
string& string, const std:: string& delimiters) -> std:: vector<std:: string> - Split string on any character from given set and remove empty parts.
-
template<std::auto splitWithoutEmptyParts(const std::
size_t size> string& string, const char(&delimiters)[size]) -> std:: vector<std:: string> -
auto beginsWith(const std::
string& string, const std:: string& prefix) -> bool - Whether the string has given prefix.
-
template<std::auto beginsWith(const std::
size_t size> string& string, const char(&prefix)[size]) -> bool -
auto beginsWith(const std::
string& string, char prefix) -> bool -
auto endsWith(const std::
string& string, const std:: string& suffix) -> bool - Whether the string has given suffix.
-
template<std::auto endsWith(const std::
size_t size> string& string, const char(&suffix)[size]) -> bool -
auto endsWith(const std::
string& string, char suffix) -> bool -
auto stripPrefix(std::
string string, const std:: string& prefix) -> std:: string - Strip given prefix from a string.
-
template<std::auto stripPrefix(const std::
size_t size> string& string, const char(&prefix)[size]) -> std:: string -
auto stripPrefix(const std::
string& string, char prefix) -> std:: string -
auto stripSuffix(const std::
string& string, const std:: string& suffix) -> std:: string - Strip given suffix from a string.
-
template<std::auto stripSuffix(const std::
size_t size> string& string, const char(&suffix)[size]) -> std:: string -
auto stripSuffix(const std::
string& string, char suffix) -> std:: string
Function documentation
std:: string Corrade:: Utility:: String:: ltrim(std:: string string)
Trim leading whitespace from string.
Equivalent to calling ltrim(std::" \t\f\v\r\n"
as second parameter. Implemented using ltrimInPlace().
std:: string Corrade:: Utility:: String:: rtrim(std:: string string)
Trim trailing whitespace from string.
Equivalent to calling rtrim(std::string, const char(&)[size] with " \t\f\v\r\n"
as second parameter. Implemented using trimInPlace().
std:: string Corrade:: Utility:: String:: trim(std:: string string)
Trim leading and trailing whitespace from string.
Equivalent to calling trim(std::" \t\f\v\r\n"
as second parameter. Implemented using trimInPlace().
void Corrade:: Utility:: String:: ltrimInPlace(std:: string& string)
Trim leading whitespace from string.
Equivalent to calling ltrimInPlace(std::" \t\f\v\r\n"
as second parameter.
void Corrade:: Utility:: String:: rtrimInPlace(std:: string& string)
Trim trailing whitespace from string.
Equivalent to calling rtrimInPlace(std::string&, const char(&)[size] with " \t\f\v\r\n"
as second parameter.
void Corrade:: Utility:: String:: trimInPlace(std:: string& string)
Trim leading and trailing whitespace from string.
Equivalent to calling trimInPlace(std::" \t\f\v\r\n"
as second parameter.
std:: vector<std:: string> Corrade:: Utility:: String:: splitWithoutEmptyParts(const std:: string& string)
Split string on whitespaces and remove empty parts.
Equivalent to calling splitWithoutEmptyParts(const std::" \t\f\v\r\n"
as second parameter.
std:: vector<std:: string> Corrade:: Utility:: String:: split(const std:: string& string,
char delimiter)
Split string on given character.
Parameters | |
---|---|
string | String to split |
delimiter | Delimiter |
std:: vector<std:: string> Corrade:: Utility:: String:: splitWithoutEmptyParts(const std:: string& string,
char delimiter)
Split string on given character and remove empty parts.
Parameters | |
---|---|
string | String to split |
delimiter | Delimiter |
std:: string Corrade:: Utility:: String:: join(const std:: vector<std:: string>& strings,
char delimiter)
Join strings with given character.
Parameters | |
---|---|
strings | Strings to join |
delimiter | Delimiter |
std:: string Corrade:: Utility:: String:: joinWithoutEmptyParts(const std:: vector<std:: string>& strings,
char delimiter)
Join strings with given character and remove empty parts.
Parameters | |
---|---|
strings | Strings to join |
delimiter | Delimiter |
std:: string Corrade:: Utility:: String:: lowercase(std:: string string)
Convert string to lowercase.
std:: string Corrade:: Utility:: String:: uppercase(std:: string string)
Convert string to uppercase.
std:: string Corrade:: Utility:: String:: fromArray(const char* string)
Safely construct string from char array.
If string
is nullptr
, returns empty string.
std:: string Corrade:: Utility:: String:: fromArray(const char* string,
std:: size_t length)
Safely construct string from char array with explicit length.
If string
is nullptr
, returns empty string. Otherwise takes also length
into account.
std:: string Corrade:: Utility:: String:: ltrim(std:: string string,
const std:: string& characters)
Trim leading characters from string.
Parameters | |
---|---|
string | String to be trimmed |
characters | Characters which will be trimmed |
Implemented using ltrimInPlace().
template<std:: size_t size>
std:: string Corrade:: Utility:: String:: ltrim(std:: string string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: rtrim(std:: string string,
const std:: string& characters)
Trim trailing characters from string.
Parameters | |
---|---|
string | String to be trimmed |
characters | Characters which will be trimmed |
Implemented using rtrimInPlace().
template<std:: size_t size>
std:: string Corrade:: Utility:: String:: rtrim(std:: string string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: trim(std:: string string,
const std:: string& characters)
Trim leading and trailing characters from string.
Parameters | |
---|---|
string | String to be trimmed |
characters | Characters which will be trimmed |
Equivalent to ltrim(rtrim(string, characters), characters)
. Implemented using trimInPlace().
template<std:: size_t size>
std:: string Corrade:: Utility:: String:: trim(std:: string string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Corrade:: Utility:: String:: ltrimInPlace(std:: string& string,
const std:: string& characters)
Trim leading characters from string, in place.
Parameters | |
---|---|
string | String to be trimmed in place |
characters | Characters which will be trimmed |
template<std:: size_t size>
void Corrade:: Utility:: String:: ltrimInPlace(std:: string& string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Corrade:: Utility:: String:: rtrimInPlace(std:: string& string,
const std:: string& characters)
Trim trailing characters from string.
Parameters | |
---|---|
string | String to be trimmed |
characters | Characters which will be trimmed |
template<std:: size_t size>
void Corrade:: Utility:: String:: rtrimInPlace(std:: string& string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Corrade:: Utility:: String:: trimInPlace(std:: string& string,
const std:: string& characters)
Trim leading and trailing characters from string.
Parameters | |
---|---|
string | String to be trimmed |
characters | Characters which will be trimmed |
Equivalent to calling both ltrimInPlace() and rtrimInPlace().
template<std:: size_t size>
void Corrade:: Utility:: String:: trimInPlace(std:: string& string,
const char(&characters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: vector<std:: string> Corrade:: Utility:: String:: splitWithoutEmptyParts(const std:: string& string,
const std:: string& delimiters)
Split string on any character from given set and remove empty parts.
Parameters | |
---|---|
string | String to split |
delimiters | Delimiter characters |
template<std:: size_t size>
std:: vector<std:: string> Corrade:: Utility:: String:: splitWithoutEmptyParts(const std:: string& string,
const char(&delimiters)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Utility:: String:: beginsWith(const std:: string& string,
const std:: string& prefix)
Whether the string has given prefix.
In particular, returns false
also if string
is empty.
template<std:: size_t size>
bool Corrade:: Utility:: String:: beginsWith(const std:: string& string,
const char(&prefix)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Utility:: String:: beginsWith(const std:: string& string,
char prefix)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Utility:: String:: endsWith(const std:: string& string,
const std:: string& suffix)
Whether the string has given suffix.
In particular, returns false
also if string
is empty.
template<std:: size_t size>
bool Corrade:: Utility:: String:: endsWith(const std:: string& string,
const char(&suffix)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool Corrade:: Utility:: String:: endsWith(const std:: string& string,
char suffix)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: stripPrefix(std:: string string,
const std:: string& prefix)
Strip given prefix from a string.
Expects that the string actually begins with given prefix.
template<std:: size_t size>
std:: string Corrade:: Utility:: String:: stripPrefix(const std:: string& string,
const char(&prefix)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: stripPrefix(const std:: string& string,
char prefix)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: stripSuffix(const std:: string& string,
const std:: string& suffix)
Strip given suffix from a string.
Expects that the string actually ends with given suffix.
template<std:: size_t size>
std:: string Corrade:: Utility:: String:: stripSuffix(const std:: string& string,
const char(&suffix)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: string Corrade:: Utility:: String:: stripSuffix(const std:: string& string,
char suffix)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.