File include/brisk/core/Text.hpp
¶
CaseTransformation
enum¶
enum class CaseTransformation
Enum representing case transformation modes.
Lower
enumerator (CaseTransformation::Lower
)¶
Transform to lowercase.
Upper
enumerator (CaseTransformation::Upper
)¶
Transform to uppercase.
transformCase
function¶
U8String transformCase(U8StringView str,
CaseTransformation mode)
Transforms the case of a UTF-8 string based on the specified mode.
Param str
The input UTF-8 string to transform.
Param mode
The case transformation mode (lower or upper).
Returns Transformed string in the specified case.
U16String transformCase(U16StringView str,
CaseTransformation mode)
Transforms the case of a UTF-16 string based on the specified mode.
Param str
The input UTF-16 string to transform.
Param mode
The case transformation mode (lower or upper).
Returns Transformed string in the specified case.
U32String transformCase(U32StringView str,
CaseTransformation mode)
Transforms the case of a UTF-32 string based on the specified mode.
Param str
The input UTF-32 string to transform.
Param mode
The case transformation mode (lower or upper).
Returns Transformed string in the specified case.
lowerCase
function¶
inline U8String lowerCase(U8StringView str)
Converts a UTF-8 string to lowercase.
Param str
The input UTF-8 string to convert.
Returns The converted lowercase string.
upperCase
function¶
inline U8String upperCase(U8StringView str)
Converts a UTF-8 string to uppercase.
Param str
The input UTF-8 string to convert.
Returns The converted uppercase string.
lowerCase
function¶
inline U16String lowerCase(U16StringView str)
Converts a UTF-16 string to lowercase.
Param str
The input UTF-16 string to convert.
Returns The converted lowercase string.
upperCase
function¶
inline U16String upperCase(U16StringView str)
Converts a UTF-16 string to uppercase.
Param str
The input UTF-16 string to convert.
Returns The converted uppercase string.
lowerCase
function¶
inline U32String lowerCase(U32StringView str)
Converts a UTF-32 string to lowercase.
Param str
The input UTF-32 string to convert.
Returns The converted lowercase string.
upperCase
function¶
inline U32String upperCase(U32StringView str)
Converts a UTF-32 string to uppercase.
Param str
The input UTF-32 string to convert.
Returns The converted uppercase string.
wordWrap
function¶
string wordWrap(string text, size_t columns)
Word-wraps a string to the specified number of columns.
Param text
The input string to wrap.
Param columns
The number of columns for wrapping.
Returns The word-wrapped string.
split
function¶
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(std::basic_string_view<Char> text,
std::basic_string_view<std::type_identity_t<Char>>
delimiter)
Splits a string into a list of substrings using a delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string to split.
Param delimiter
The delimiter used to split the string.
Returns A vector of string views representing the split substrings.
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(std::basic_string_view<Char> text,
std::type_identity_t<Char> delimiter)
Splits a string into a list of substrings using a single character as a delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string to split.
Param delimiter
The delimiter character used to split the string.
Returns A vector of string views representing the split substrings.
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(const std::basic_string<Char> &text,
std::basic_string_view<std::type_identity_t<Char>>
delimiter)
Splits a basic string into a list of substrings using a delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string to split.
Param delimiter
The string delimiter used to split the text.
Returns A vector of string views representing the split substrings.
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(const std::basic_string<Char> &text,
std::type_identity_t<Char> delimiter)
Splits a basic string into a list of substrings using a single character as a delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string to split.
Param delimiter
The delimiter character used to split the text.
Returns A vector of string views representing the split substrings.
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(const Char *text,
std::basic_string_view<std::type_identity_t<Char>>
delimiter)
Splits a character array (C-string) into a list of substrings using a string delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input C-string to split.
Param delimiter
The string delimiter used to split the text.
Returns A vector of string views representing the split substrings.
template <typename Char>
std::vector<std::basic_string_view<Char>>
split(Char *text, std::type_identity_t<Char> delimiter)
Splits a character array (C-string) into a list of substrings using a single character as a
delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input C-string to split.
Param delimiter
The delimiter character used to split the text.
Returns A vector of string views representing the split substrings.
toStrings
function¶
template <typename Char = char, typename T>
std::vector<std::basic_string<Char>> toStrings(T &&value)
Converts a container of elements to a vector of basic strings.
Template param Char
The character type for the output strings.
Template param T
The container type.
Param value
The container with elements to convert.
Returns A vector of basic strings converted from the container elements.
join
function¶
template <typename Char>
std::basic_string<Char>
join(const std::vector<std::basic_string<Char>> &list,
std::basic_string_view<std::type_identity_t<Char>>
delimiter)
Joins a list of strings into a single string with a specified delimiter.
Template param Char
The character type of the strings.
Param list
The list of strings to join.
Param delimiter
The delimiter used to join the strings.
Returns A single string with the elements joined by the delimiter.
template <typename Char>
std::basic_string<Char>
join(const std::vector<std::basic_string<Char>> &list,
std::type_identity_t<Char> delimiter)
Joins a list of basic strings into a single string with a character delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param list
A vector of basic strings to join.
Param delimiter
The character used to separate the joined strings.
Returns A single string with the individual strings joined by the delimiter.
template <typename Char>
std::basic_string<Char>
join(const std::vector<std::basic_string_view<Char>> &list,
std::basic_string_view<std::type_identity_t<Char>>
delimiter)
Joins a list of basic string views into a single string with a string delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param list
A vector of basic string views to join.
Param delimiter
The string delimiter used to separate the joined string views.
Returns A single string with the individual string views joined by the delimiter.
template <typename Char>
std::basic_string<Char>
join(const std::vector<std::basic_string_view<Char>> &list,
std::type_identity_t<Char> delimiter)
Joins a list of basic string views into a single string with a character delimiter.
Template param Char
The character type (e.g., char, wchar_t).
Param list
A vector of basic string views to join.
Param delimiter
The character used to separate the joined string views.
Returns A single string with the individual string views joined by the delimiter.
replaceAll
function¶
template <typename Char>
std::basic_string<Char> replaceAll(
std::basic_string<Char> str,
std::basic_string_view<std::type_identity_t<Char>> from,
std::basic_string_view<std::type_identity_t<Char>> to)
Replaces all occurrences of a substring in a string with another substring.
Template param Char
The character type of the string.
Param str
The string in which to perform replacements.
Param from
The substring to be replaced.
Param to
The substring to replace with.
Returns The string with all replacements applied.
template <typename Char>
std::basic_string<Char>
replaceAll(std::basic_string<Char> str,
std::type_identity_t<Char> from,
const std::type_identity_t<Char> &to)
Replaces all occurrences of a character in a basic string with another character.
Template param Char
The character type (e.g., char, wchar_t).
Param str
The input string where replacements are made.
Param from
The character to replace.
Param to
The character to replace with.
Returns A new string with all occurrences of the 'from' character replaced by the 'to' character.
template <typename Char>
std::basic_string<Char> replaceAll(
std::basic_string_view<Char> text,
std::basic_string_view<std::type_identity_t<Char>> from,
std::basic_string_view<std::type_identity_t<Char>> to)
Replaces all occurrences of a substring in a basic string view with another substring.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string view where replacements are made.
Param from
The substring to replace.
Param to
The substring to replace with.
Returns A new string with all occurrences of the 'from' substring replaced by the 'to' substring.
template <typename Char>
std::basic_string<Char>
replaceAll(std::basic_string_view<Char> text,
std::type_identity_t<Char> from,
std::type_identity_t<Char> to)
Replaces all occurrences of a character in a basic string view with another character.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input string view where replacements are made.
Param from
The character to replace.
Param to
The character to replace with.
Returns A new string with all occurrences of the 'from' character replaced by the 'to' character.
template <typename Char>
std::basic_string<Char> replaceAll(
const Char *text,
std::basic_string_view<std::type_identity_t<Char>> from,
std::basic_string_view<std::type_identity_t<Char>> to)
Replaces all occurrences of a substring in a C-string with another substring.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input C-string where replacements are made.
Param from
The substring to replace.
Param to
The substring to replace with.
Returns A new string with all occurrences of the 'from' substring replaced by the 'to' substring.
template <typename Char>
std::basic_string<Char>
replaceAll(Char *text, std::type_identity_t<Char> from,
std::type_identity_t<Char> to)
Replaces all occurrences of a character in a C-string with another character.
Template param Char
The character type (e.g., char, wchar_t).
Param text
The input C-string where replacements are made.
Param from
The character to replace.
Param to
The character to replace with.
Returns A new string with all occurrences of the 'from' character replaced by the 'to' character.
contains
function¶
template <typename Char>
inline bool
contains(const std::basic_string<Char> &str,
const std::basic_string<std::type_identity_t<Char>>
&substr)
Checks if a string contains a specific substring.
Template param Char
The character type of the string.
Param str
The string to search in.
Param substr
The substring to search for.
Returns true if the substring is found, false otherwise.
ltrim
function¶
std::string ltrim(std::string s)
Trims whitespace from the left side of a string.
Param s
The string to trim.
Returns The left-trimmed string.
rtrim
function¶
std::string rtrim(std::string s)
Trims whitespace from the right side of a string.
Param s
The string to trim.
Returns The right-trimmed string.
trim
function¶
std::string trim(std::string s)
Trims whitespace from both sides of a string.
Param s
The string to trim.
Returns The trimmed string.
split
function¶
void split(std::string_view text,
std::string_view delimiter, std::string_view &s1,
std::string_view &s2)
Splits a string view into two substrings using a delimiter.
Param text
The input string to split.
Param delimiter
The delimiter used to split the string.
Param s1
Output string view for the first part.
Param s2
Output string view for the second part.
shorten
function¶
std::u32string shorten(std::u32string str, size_t maxLength,
float position,
std::u32string_view ellipsis = U"…")
Shortens a string to a specified maximum length.
Param str
The string to shorten.
Param maxLength
The maximum length of the output string in unicode codepoints.
Param position
Where to cut the string: left (0), right (1), or middle (0.5).
Param ellipsis
The ellipsis string to append if shortening occurs.
Returns The shortened string.
inline std::string
shorten(const std::string &str, size_t maxLength,
float position, std::u32string_view ellipsis = U"…")
Shortens a UTF-8 string to a specified maximum length.
Param str
The UTF-8 string to shorten.
Param maxLength
The maximum length of the output string in unicode codepoints.
Param position
Where to cut the string: left (0), right (1), or middle (0.5).
Param ellipsis
The ellipsis string to append if shortening occurs.
Returns The shortened UTF-8 string.
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/