CommonLib
Loading...
Searching...
No Matches
hedgedev::csl::ut::string Namespace Reference

Functions

template<expr::any_string T_left, expr::any_string T_right>
bool compare (const T_left &in_left, const T_right &in_right, bool in_case_sensitive=true)
template<expr::any_string T_str, expr::any_string T_substr>
bool contains (const T_str &in_str, const T_substr &in_substr, bool in_case_sensitive=true)
template<expr::any_string T_str, typename T_str_char = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > escape (const T_str &in_str, T_str_char in_search_char, T_str_char in_escape_char=T_str_char('\\'))
template<expr::any_string T>
expr::inferred_string_t< T > format (const T in_str,...)
template<expr::any_string T>
size_t get_width (const T &in_str)
template<expr::any_string T_str, expr::any_string T_url, typename T_result = expr::pi_string_t<T_str, T_url>>
T_result hyperlink (const T_str &in_str, const T_url &in_url)
template<expr::any_string T>
bool is_null_or_empty (const T &in_str)
template<expr::any_string T>
bool is_null_or_whitespace (const T &in_str)
template<expr::any_string T_delimiter, expr::any_string T_strings>
expr::inferred_string_t< T_strings > join (const T_delimiter &in_delimiter, const std::vector< T_strings > &in_strings)
template<expr::any_string T_delimiter, expr::any_string... T_args, typename T_result = expr::pi_string_t<T_delimiter, T_args...>>
T_result join (const T_delimiter &in_delimiter, const T_args &... in_args)
template<expr::any_string T_str, expr::any_string T_pad_str, typename T_result = expr::pi_string_t<T_str, T_pad_str>>
T_result pad (const T_str &in_str, const T_pad_str &in_pad_str)
template<typename T_result, expr::any_string T_str>
T_result parse (const T_str &in_str)
template<expr::any_string T_str>
expr::inferred_string_t< T_str > remove_xml_tags (const T_str &in_str)
template<expr::any_string T_str, expr::any_string T_delimiter, typename T_result = expr::pi_string_t<T_str, T_delimiter>>
std::vector< T_result > split (const T_str &in_str, const T_delimiter &in_delimiter)
template<expr::any_string T>
expr::inferred_string_t< T > lower (const T &in_str)
template<expr::any_string T>
expr::inferred_string_t< T > upper (const T &in_str)
template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > trim_start (const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > trim_end (const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > trim (const T_str &in_str, std::optional< std::vector< T_trim_chars > > in_trim_chars={})
template<expr::any_string T>
expr::inferred_string_t< T > truncate (const T &in_str, size_t in_max_length, bool in_truncate_end=true, bool in_ellipsis=true)
template<expr::basic_string T_result, typename T_value>
T_result hex (T_value in_value, size_t in_max_length=sizeof(size_t) *2, bool in_prefix=true)
template<typename T_result, expr::any_string T_str>
bool try_parse (const T_str &in_str, T_result &out_result)
template<expr::any_string T_str>
expr::inferred_string_t< T_str > wrap (const T_str &in_str, size_t in_max_width)

Function Documentation

◆ compare()

template<expr::any_string T_left, expr::any_string T_right>
bool hedgedev::csl::ut::string::compare ( const T_left & in_left,
const T_right & in_right,
bool in_case_sensitive = true )
inline

Compares two strings.

Template Parameters
T_leftThe left string type.
T_rightThe right string type.
Parameters
in_leftThe first string.
in_rightThe second string.
in_case_sensitiveDetermines whether the comparison should be case sensitive.
Returns
true if the strings are identical. Otherwise, false.

◆ contains()

template<expr::any_string T_str, expr::any_string T_substr>
bool hedgedev::csl::ut::string::contains ( const T_str & in_str,
const T_substr & in_substr,
bool in_case_sensitive = true )
inline

Checks if a string contains a substring.

Template Parameters
T_strThe input string type.
T_substrThe substring type.
Parameters
in_strThe string to check.
in_substrThe substring to search for.
in_case_sensitiveDetermines whether the search should be case sensitive.
Returns
true if the input string contains the specified substring. Otherwise, false.

◆ escape()

template<expr::any_string T_str, typename T_str_char = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::escape ( const T_str & in_str,
T_str_char in_search_char,
T_str_char in_escape_char = T_str_char('\\') )
inline

Escapes all instances of a character in a string with an escape sequence.

Template Parameters
T_strThe input string type.
T_str_charThe search and escape character type inferred from the input string type.
Parameters
in_strThe string to escape.
in_search_charThe character to search for and escape.
in_escape_charThe character to escape with.
Returns
The input string where all characters matching the search character have been escaped using the escape character.

◆ format()

template<expr::any_string T>
expr::inferred_string_t< T > hedgedev::csl::ut::string::format ( const T in_str,
... )
inline

Formats a string.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to format.
Returns
The input string with the formatters filled in.

◆ get_width()

template<expr::any_string T>
size_t hedgedev::csl::ut::string::get_width ( const T & in_str)
inline

Gets the width of a string.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to search.
Returns
The width of the string in characters determined by the longest line.

◆ hex()

template<expr::basic_string T_result, typename T_value>
T_result hedgedev::csl::ut::string::hex ( T_value in_value,
size_t in_max_length = sizeof(size_t) * 2,
bool in_prefix = true )
inline

Transforms a value into a hexadecimal string.

Template Parameters
T_resultThe output string type.
T_valueThe input value type.
Parameters
in_valueThe value to transform.
in_max_lengthThe maximum number of leading zeroes to display.
in_prefixDetermines whether to use the "0x" prefix.
Returns
The input value represented as a hexadecimal string.

◆ hyperlink()

template<expr::any_string T_str, expr::any_string T_url, typename T_result = expr::pi_string_t<T_str, T_url>>
T_result hedgedev::csl::ut::string::hyperlink ( const T_str & in_str,
const T_url & in_url )
inline

Formats a string to have a HTML hyperlink.

Template Parameters
T_strThe input string type.
T_urlThe URL string type.
T_resultThe output string type inferred from the precedent input strings.
Parameters
in_strThe string to display.
in_urlThe URL to use.
Returns
The input string formatted with a HTML hyperlink with a URL target.

◆ is_null_or_empty()

template<expr::any_string T>
bool hedgedev::csl::ut::string::is_null_or_empty ( const T & in_str)
inline

Checks if a string of any type is null or empty.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to check.
Returns
true if the string is null or empty. Otherwise, false.

◆ is_null_or_whitespace()

template<expr::any_string T>
bool hedgedev::csl::ut::string::is_null_or_whitespace ( const T & in_str)
inline

Checks if a string of any type is null, empty, or consists only of white-space characters.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to check.
Returns
true if the string is null or empty, or if the string consists only of white-space characters. Otherwise, false.

◆ join() [1/2]

template<expr::any_string T_delimiter, expr::any_string T_strings>
expr::inferred_string_t< T_strings > hedgedev::csl::ut::string::join ( const T_delimiter & in_delimiter,
const std::vector< T_strings > & in_strings )
inline

Joins a collection of strings together using a delimiter.

Template Parameters
T_delimiterThe delimiter string type.
T_stringsThe collection string type.
Parameters
in_delimiterThe delimiter to join the strings with.
in_stringsThe strings to join.
Returns
The input strings joined together, separated by the delimiter.

◆ join() [2/2]

template<expr::any_string T_delimiter, expr::any_string... T_args, typename T_result = expr::pi_string_t<T_delimiter, T_args...>>
T_result hedgedev::csl::ut::string::join ( const T_delimiter & in_delimiter,
const T_args &... in_args )
inline

Joins a collection of strings together using a delimiter.

Template Parameters
T_delimiterThe delimiter string type.
T_argsThe string types.
T_resultThe output string type inferred from the precedent input strings.
Parameters
in_delimiterThe delimiter to join the strings with.
in_argsThe strings to join.
Returns
The input strings joined together, separated by the delimiter.

◆ lower()

template<expr::any_string T>
expr::inferred_string_t< T > hedgedev::csl::ut::string::lower ( const T & in_str)
inline

Transforms a string to lowercase.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to transform to lowercase.
Returns
The input string as lowercase.

◆ pad()

template<expr::any_string T_str, expr::any_string T_pad_str, typename T_result = expr::pi_string_t<T_str, T_pad_str>>
T_result hedgedev::csl::ut::string::pad ( const T_str & in_str,
const T_pad_str & in_pad_str )
inline

Pads a string with another.

Template Parameters
T_strThe input string type.
T_pad_strThe pad string type.
T_resultThe output string type inferred from the precedent input strings.
Parameters
in_strThe string to pad.
in_pad_strThe string to pad with.
Returns
The input string padded on either side with the pad string.

◆ parse()

template<typename T_result, expr::any_string T_str>
T_result hedgedev::csl::ut::string::parse ( const T_str & in_str)
inline

Parses a value from a string.

Template Parameters
T_resultThe value type to parse.
T_strThe input string type.
Parameters
in_strThe string to parse.
Returns
The value that was parsed.

◆ remove_xml_tags()

template<expr::any_string T_str>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::remove_xml_tags ( const T_str & in_str)
inline

Removes XML tags from a string.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to omit XML tags from.
Returns
The input string with XML tags removed.

◆ split()

template<expr::any_string T_str, expr::any_string T_delimiter, typename T_result = expr::pi_string_t<T_str, T_delimiter>>
std::vector< T_result > hedgedev::csl::ut::string::split ( const T_str & in_str,
const T_delimiter & in_delimiter )
inline

Splits a string into a collection using a delimiter.

Template Parameters
T_strThe input string type.
T_delimiterThe delimiter string type.
T_resultThe output string type inferred from the precedent input strings.
Parameters
in_strThe string to split.
in_delimiterThe delimiter to split the string with.
Returns
A collection of strings split by the delimiter.

◆ trim()

template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::trim ( const T_str & in_str,
std::optional< std::vector< T_trim_chars > > in_trim_chars = {} )
inline

Removes all leading and trailing occurrences of a set of characters from the input string.

Template Parameters
T_strThe input string type.
T_trim_charsThe trim character type inferred from the input string type.
Parameters
in_strThe string to trim.
in_trim_charsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the start and end.

◆ trim_end()

template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::trim_end ( const T_str & in_str,
std::optional< std::vector< T_trim_chars > > in_trim_chars = {} )
inline

Removes all trailing occurrences of a set of characters from the input string.

Template Parameters
T_strThe input string type.
T_trim_charsThe trim character type inferred from the input string type.
Parameters
in_strThe string to trim.
in_trim_charsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the end.

◆ trim_start()

template<expr::any_string T_str, typename T_trim_chars = expr::get_char_type_t<T_str>>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::trim_start ( const T_str & in_str,
std::optional< std::vector< T_trim_chars > > in_trim_chars = {} )
inline

Removes all leading occurrences of a set of characters from the input string.

Template Parameters
T_strThe input string type.
T_trim_charsThe trim character type inferred from the input string type.
Parameters
in_strThe string to trim.
in_trim_charsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the start.

◆ truncate()

template<expr::any_string T>
expr::inferred_string_t< T > hedgedev::csl::ut::string::truncate ( const T & in_str,
size_t in_max_length,
bool in_truncate_end = true,
bool in_ellipsis = true )
inline

Truncates a string.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to truncate.
in_max_lengthThe maximum length to truncate to.
in_truncate_endDetermines whether to truncate the end of the string, rather than the beginning.
in_ellipsisDetermines whether to add an ellipsis to the truncated side of the string.
Returns
The input string truncated to the specified length.

◆ try_parse()

template<typename T_result, expr::any_string T_str>
bool hedgedev::csl::ut::string::try_parse ( const T_str & in_str,
T_result & out_result )
inline

Tries to parse a value from a string.

Template Parameters
T_resultThe value type to parse.
T_strThe input string type.
Parameters
in_strThe string to parse.
out_resultThe output value to set.
Returns
true if the parse was successful. Otherwise, false.

◆ upper()

template<expr::any_string T>
expr::inferred_string_t< T > hedgedev::csl::ut::string::upper ( const T & in_str)
inline

Transforms a string to uppercase.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to transform to uppercase.
Returns
The input string as uppercase.

◆ wrap()

template<expr::any_string T_str>
expr::inferred_string_t< T_str > hedgedev::csl::ut::string::wrap ( const T_str & in_str,
size_t in_max_width )
inline

Wraps a string to a fixed character length on each line.

Template Parameters
T_strThe input string type.
Parameters
in_strThe string to wrap.
in_max_widthThe maximum width of each line.
Returns
The input string with line breaks placed around word boundaries to fit within the maximum line width.