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

Functions

template<expr::AnyString TLeft, expr::AnyString TRight>
bool Compare (const TLeft &in_rLeft, const TRight &in_rRight, bool in_isCaseSensitive=true)
template<expr::AnyString TString, expr::AnyString TSubString>
bool Contains (const TString &in_rStr, const TSubString &in_rSubStr, bool in_isCaseSensitive=true)
template<expr::AnyString TDst, expr::AnyString TSrc>
std::conditional_t< std::is_same_v< TDst, TSrc > &&!std::is_pointer_v< TSrc >, const TDst &, TDst > Convert (const TSrc &in_rStr)
template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > Escape (const TString &in_rStr, TChar in_searchChar, TChar in_escapeChar=TChar('\\'))
template<expr::AnyString TString>
expr::InferredString< TString > Format (const TString in_str,...)
template<expr::AnyString TString>
size_t GetWidth (const TString &in_rStr)
template<expr::AnyString TString, expr::AnyString TUrl, typename TOut = expr::PrecedentInferredString<TString, TUrl>>
TOut Hyperlink (const TString &in_rStr, const TUrl &in_rUrl)
template<expr::AnyString TDelimiter, expr::AnyString TCollection>
expr::InferredString< TCollection > Join (const TDelimiter &in_rDelimiter, const std::vector< TCollection > &in_rStrings)
template<expr::AnyString TDelimiter, expr::AnyString... TArgs, typename TOut = expr::PrecedentInferredString<TDelimiter, TArgs...>>
TOut Join (const TDelimiter &in_rDelimiter, const TArgs &... in_rArgs)
template<expr::AnyString TString, expr::AnyString TPadString, typename TOut = expr::PrecedentInferredString<TString, TPadString>>
TOut Pad (const TString &in_rStr, const TPadString &in_rPadStr)
template<typename TOut, expr::AnyString TString>
TOut Parse (const TString &in_rStr)
template<expr::AnyString... TArgs, typename TOut = expr::PrecedentInferredString<TArgs...>>
std::array< TOut, sizeof...(TArgs)> PrecedentConvert (const TArgs &... in_rArgs)
template<expr::AnyString TString>
expr::InferredString< TString > RemoveXmlTags (const TString &in_rStr)
template<expr::AnyString TString, expr::AnyString TDelimiter, typename TOut = expr::PrecedentInferredString<TString, TDelimiter>>
std::vector< TOut > Split (const TString &in_rStr, const TDelimiter &in_rDelimiter)
template<expr::AnyString TString>
expr::InferredString< TString > ToLower (const TString &in_rStr)
template<expr::AnyString TString>
expr::InferredString< TString > ToUpper (const TString &in_rStr)
template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > TrimStart (const TString &in_rStr, std::optional< std::vector< TChar > > in_trimChars={})
template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > TrimEnd (const TString &in_rStr, std::optional< std::vector< TChar > > in_trimChars={})
template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > Trim (const TString &in_rStr, std::optional< std::vector< TChar > > in_trimChars={})
template<expr::AnyString TString>
expr::InferredString< TString > Truncate (const TString &in_rStr, size_t in_maxLength, bool in_truncateEnd=true, bool in_ellipsis=true)
template<expr::BasicString TString, typename TValue>
TString ToHex (TValue in_value, size_t in_maxLength=sizeof(size_t) *2, bool in_prefix=true)
template<expr::AnyString TDst, expr::AnyString TSrc>
bool TryConvert (const TSrc &in_rSrc, TDst &out_rDst)
template<typename TOut, expr::AnyString TString>
bool TryParse (const TString &in_rStr, TOut &out_rValue)
template<expr::AnyString TString>
expr::InferredString< TString > Wrap (const TString &in_rStr, size_t in_maxWidth)

Function Documentation

◆ Compare()

template<expr::AnyString TLeft, expr::AnyString TRight>
bool hedgedev::csl::ut::string::Compare ( const TLeft & in_rLeft,
const TRight & in_rRight,
bool in_isCaseSensitive = true )
inline

Compares two strings.

Parameters
in_rLeftThe first string.
in_rRightThe second string.
in_isCaseSensitiveDetermines whether the comparison should be case sensitive.
Returns
true if the strings are identical. Otherwise, false.

◆ Contains()

template<expr::AnyString TString, expr::AnyString TSubString>
bool hedgedev::csl::ut::string::Contains ( const TString & in_rStr,
const TSubString & in_rSubStr,
bool in_isCaseSensitive = true )
inline

Checks if a string contains a substring.

Parameters
in_rStrThe string to check.
in_rSubStrThe substring to search for.
in_isCaseSensitiveDetermines whether the search should be case sensitive.
Returns
true if the input string contains the specified substring. Otherwise, false.

◆ Convert()

template<expr::AnyString TDst, expr::AnyString TSrc>
std::conditional_t< std::is_same_v< TDst, TSrc > &&!std::is_pointer_v< TSrc >, const TDst &, TDst > hedgedev::csl::ut::string::Convert ( const TSrc & in_rStr)
inline

Converts a string to a different encoding format.

Template Parameters
TDstThe string type to convert to.
TSrcThe string type to convert from.
Parameters
in_rStrThe string to convert.
out_rDstThe output string to set.
Returns
If successful, the input string in the destination format. Otherwise, an empty string in the destination format.

◆ Escape()

template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > hedgedev::csl::ut::string::Escape ( const TString & in_rStr,
TChar in_searchChar,
TChar in_escapeChar = TChar('\\') )
inline

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

Template Parameters
TStringThe input string type.
TCharThe search and escape character type inferred from the input string type.
Parameters
in_rStrThe string to escape.
in_searchCharThe character to search for and escape.
in_escapeCharThe 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::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::Format ( const TString in_str,
... )
inline

Formats a string.

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

◆ GetWidth()

template<expr::AnyString TString>
size_t hedgedev::csl::ut::string::GetWidth ( const TString & in_rStr)
inline

Gets the width of a string.

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

◆ Hyperlink()

template<expr::AnyString TString, expr::AnyString TUrl, typename TOut = expr::PrecedentInferredString<TString, TUrl>>
TOut hedgedev::csl::ut::string::Hyperlink ( const TString & in_rStr,
const TUrl & in_rUrl )
inline

Formats a string to have a HTML hyperlink.

Template Parameters
TStringThe input string type.
Parameters
in_rStrThe string to display.
in_rUrlThe URL to use.
Returns
The input string formatted with a HTML hyperlink with a URL target.

◆ Join() [1/2]

template<expr::AnyString TDelimiter, expr::AnyString TCollection>
expr::InferredString< TCollection > hedgedev::csl::ut::string::Join ( const TDelimiter & in_rDelimiter,
const std::vector< TCollection > & in_rStrings )
inline

Joins a collection of strings together using a delimiter.

Template Parameters
TDelimiterThe delimiter string type.
TCollectionThe collection string type.
Parameters
in_pDelimiterThe delimiter to join the strings with.
in_rStringsThe strings to join.
Returns
The input strings joined together, separated by the delimiter.

◆ Join() [2/2]

template<expr::AnyString TDelimiter, expr::AnyString... TArgs, typename TOut = expr::PrecedentInferredString<TDelimiter, TArgs...>>
TOut hedgedev::csl::ut::string::Join ( const TDelimiter & in_rDelimiter,
const TArgs &... in_rArgs )
inline

Joins a collection of strings together using a delimiter.

Template Parameters
TDelimiterThe delimiter string type.
TArgsThe string types.
Parameters
in_pDelimiterThe delimiter to join the strings with.
in_rArgsThe strings to join.
Returns
The input strings joined together, separated by the delimiter.

◆ Pad()

template<expr::AnyString TString, expr::AnyString TPadString, typename TOut = expr::PrecedentInferredString<TString, TPadString>>
TOut hedgedev::csl::ut::string::Pad ( const TString & in_rStr,
const TPadString & in_rPadStr )
inline

Pads a string with another.

Template Parameters
TStringThe input string type.
TPadStringThe pad string type.
Parameters
in_rStrThe string to pad.
in_rPadStrThe string to pad with.
Returns
The input string padded on either side with the pad string.

◆ Parse()

template<typename TOut, expr::AnyString TString>
TOut hedgedev::csl::ut::string::Parse ( const TString & in_rStr)
inline

Parses a value from a string.

Template Parameters
TOutThe value type to parse.
TStringThe input string type.
Parameters
in_rStrThe string to parse.
Returns
The value that was parsed.

◆ PrecedentConvert()

template<expr::AnyString... TArgs, typename TOut = expr::PrecedentInferredString<TArgs...>>
std::array< TOut, sizeof...(TArgs)> hedgedev::csl::ut::string::PrecedentConvert ( const TArgs &... in_rArgs)
inline

Converts multiple strings to share the same encoding format.

Template Parameters
TArgsThe string types.
TOutThe string type to convert to inferred from the string with the largest character size.
Parameters
in_rArgsThe strings to convert.
Returns
An array of strings in the same destination format. If a string failed to convert, an empty string will be put in its place.

◆ RemoveXmlTags()

template<expr::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::RemoveXmlTags ( const TString & in_rStr)
inline

Omits XML tags from a string.

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

◆ Split()

template<expr::AnyString TString, expr::AnyString TDelimiter, typename TOut = expr::PrecedentInferredString<TString, TDelimiter>>
std::vector< TOut > hedgedev::csl::ut::string::Split ( const TString & in_rStr,
const TDelimiter & in_rDelimiter )
inline

Splits a string into a collection using a delimiter.

Template Parameters
TStringThe input string type.
TDelimiterThe delimiter string type.
Parameters
in_rStrThe string to split.
in_rDelimiterThe delimiter to split the string with.
Returns
A collection of strings split by the delimiter.

◆ ToHex()

template<expr::BasicString TString, typename TValue>
TString hedgedev::csl::ut::string::ToHex ( TValue in_value,
size_t in_maxLength = sizeof(size_t) * 2,
bool in_prefix = true )
inline

Transforms a value into a hexadecimal string.

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

◆ ToLower()

template<expr::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::ToLower ( const TString & in_rStr)
inline

Transforms a string to lowercase.

Template Parameters
TStringThe input string type.
Parameters
in_rStrThe string to transform to lowercase.
Returns
The input string as lowercase.

◆ ToUpper()

template<expr::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::ToUpper ( const TString & in_rStr)
inline

Transforms a string to uppercase.

Template Parameters
TStringThe input string type.
Parameters
in_rStrThe string to transform to uppercase.
Returns
The input string as uppercase.

◆ Trim()

template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > hedgedev::csl::ut::string::Trim ( const TString & in_rStr,
std::optional< std::vector< TChar > > in_trimChars = {} )
inline

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

Template Parameters
TStringThe input string type.
TCharThe trim character type inferred from the input string type.
Parameters
in_rStrThe string to trim.
in_trimCharsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the start and end.

◆ TrimEnd()

template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > hedgedev::csl::ut::string::TrimEnd ( const TString & in_rStr,
std::optional< std::vector< TChar > > in_trimChars = {} )
inline

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

Template Parameters
TStringThe input string type.
TCharThe trim character type inferred from the input string type.
Parameters
in_rStrThe string to trim.
in_trimCharsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the end.

◆ TrimStart()

template<expr::AnyString TString, typename TChar = expr::GetCharType_t<TString>>
expr::InferredString< TString > hedgedev::csl::ut::string::TrimStart ( const TString & in_rStr,
std::optional< std::vector< TChar > > in_trimChars = {} )
inline

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

Template Parameters
TStringThe input string type.
TCharThe trim character type inferred from the input string type.
Parameters
in_rStrThe string to trim.
in_trimCharsThe characters to trim off.
Returns
The input string with all occurrences of the specified characters removed from the start.

◆ Truncate()

template<expr::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::Truncate ( const TString & in_rStr,
size_t in_maxLength,
bool in_truncateEnd = true,
bool in_ellipsis = true )
inline

Truncates a string.

Template Parameters
TStringThe input string type.
Parameters
in_rStrThe string to truncate.
in_maxLengthThe maximum length to truncate to.
in_truncateEndDetermines 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.

◆ TryConvert()

template<expr::AnyString TDst, expr::AnyString TSrc>
bool hedgedev::csl::ut::string::TryConvert ( const TSrc & in_rSrc,
TDst & out_rDst )
inline

Tries to convert a string to a different encoding format.

Template Parameters
TDstThe string type to convert to.
TSrcThe string type to convert from.
Parameters
in_rSrcThe string to convert.
out_rDstThe output string to set.
Returns
true if the conversion was successful. Otherwise, false.

◆ TryParse()

template<typename TOut, expr::AnyString TString>
bool hedgedev::csl::ut::string::TryParse ( const TString & in_rStr,
TOut & out_rValue )
inline

Tries to parse a value from a string.

Template Parameters
TOutThe value type to parse.
TStringThe input string type.
Parameters
in_rStrThe string to parse.
out_rValueThe output value to set.
Returns
true if the parse was successful. Otherwise, false.

◆ Wrap()

template<expr::AnyString TString>
expr::InferredString< TString > hedgedev::csl::ut::string::Wrap ( const TString & in_rStr,
size_t in_maxWidth )
inline

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

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