Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StringUtils Class Reference

#include <StringUtils.h>

Static Public Member Functions

template<typename... Args>
static constexpr std::string Format (std::string_view format, Args &&... args)
 Get a formatted string similar to sprintf.
 
template<typename... Args>
static constexpr std::wstring Format (std::wstring_view format, Args &&... args)
 
static std::string FormatV (PRINTF_FORMAT_STRING const char *fmt, va_list args)
 
static std::wstring FormatV (PRINTF_FORMAT_STRING const wchar_t *fmt, va_list args)
 
static std::string ToUpper (std::string_view str)
 
static std::wstring ToUpper (std::wstring_view str)
 
static void ToUpper (std::string &str) noexcept
 
static void ToUpper (std::wstring &str) noexcept
 
static std::string ToLower (std::string_view str)
 
static std::wstring ToLower (std::wstring_view str)
 
static void ToLower (std::string &str) noexcept
 
static void ToLower (std::wstring &str) noexcept
 
static void ToCapitalize (std::string &str) noexcept
 
static void ToCapitalize (std::wstring &str) noexcept
 
static bool EqualsNoCase (std::string_view str1, std::string_view str2) noexcept
 
static int CompareNoCase (std::string_view str1, std::string_view str2, size_t n=0) noexcept
 
static int ReturnDigits (std::string_view str) noexcept
 
static std::string Left (std::string_view str, size_t count)
 
static std::string Mid (std::string_view str, size_t first, size_t count=std::string_view::npos)
 
static std::string Right (std::string_view str, size_t count)
 
static std::string & Trim (std::string &str) noexcept
 
static std::string & Trim (std::string &str, std::string_view chars) noexcept
 
static std::string & TrimLeft (std::string &str) noexcept
 
static std::string & TrimLeft (std::string &str, std::string_view chars) noexcept
 
static std::string & TrimRight (std::string &str) noexcept
 
static std::string & TrimRight (std::string &str, std::string_view chars) noexcept
 
static std::string & RemoveDuplicatedSpacesAndTabs (std::string &str) noexcept
 
static bool IsSpecialCharacter (char c) noexcept
 Check if the character is a special character.
 
static std::string ReplaceSpecialCharactersWithSpace (std::string_view str)
 
static int Replace (std::string &str, char oldChar, char newChar) noexcept
 
static int Replace (std::string &str, std::string_view oldStr, std::string_view newStr)
 
static int Replace (std::wstring &str, std::wstring_view oldStr, std::wstring_view newStr)
 
static bool StartsWith (std::string_view str1, std::string_view str2) noexcept
 
static bool StartsWithNoCase (std::string_view str1, std::string_view str2) noexcept
 
static bool EndsWith (std::string_view str1, std::string_view str2) noexcept
 
static bool EndsWithNoCase (std::string_view str1, std::string_view str2) noexcept
 
template<typename CONTAINER>
static std::string Join (const CONTAINER &strings, std::string_view delimiter)
 
static std::vector< std::string > Split (std::string_view input, std::string_view delimiter, unsigned int iMaxStrings=0)
 Splits the given input string using the given delimiter into separate strings.
 
static std::vector< std::string > Split (std::string_view input, char delimiter, size_t iMaxStrings=0)
 
static std::vector< std::string > Split (std::string_view input, std::span< const std::string > delimiters)
 
static std::vector< std::string > Split (std::string_view input, std::span< const std::string_view > delimiters)
 
template<typename OutputIt>
static OutputIt SplitTo (OutputIt d_first, std::string_view input, std::string_view delimiter, unsigned int iMaxStrings=0)
 Splits the given input string using the given delimiter into separate strings.
 
template<typename OutputIt>
static OutputIt SplitTo (OutputIt d_first, std::string_view input, char delimiter, size_t iMaxStrings=0)
 
template<typename OutputIt, typename StringLike>
static OutputIt SplitTo (OutputIt d_first, std::string_view input, std::span< StringLike > delimiters)
 
static std::vector< std::string > SplitMulti (std::span< const std::string > input, std::span< const std::string > delimiters, size_t iMaxStrings=0)
 Splits the given input strings using the given delimiters into further separate strings.
 
static std::vector< std::string > SplitMulti (std::span< const std::string_view > input, std::span< const std::string_view > delimiters, size_t iMaxStrings=0)
 
static std::vector< std::string > SplitMulti (std::span< const std::string > input, std::span< const std::string_view > delimiters, size_t iMaxStrings=0)
 
static std::vector< std::string > SplitMulti (std::span< const std::string_view > input, std::span< const std::string > delimiters, size_t iMaxStrings=0)
 
static int FindNumber (std::string_view strInput, std::string_view strFind) noexcept
 
static int64_t AlphaNumericCompare (std::wstring_view left, std::wstring_view right) noexcept
 
static int AlphaNumericCollation (int nKey1, const void *pKey1, int nKey2, const void *pKey2) noexcept
 
static long TimeStringToSeconds (std::string_view timeString)
 
static void RemoveCRLF (std::string &strLine) noexcept
 
static size_t utf8_strlen (std::string_view s) noexcept
 utf8 version of strlen - skips any non-starting bytes in the count, thus returning the number of utf8 characters
 
static std::string SecondsToTimeString (long seconds, TIME_FORMAT format=TIME_FORMAT_GUESS)
 convert a time in seconds to a string based on the given time format
 
static std::string MillisecondsToTimeString (std::chrono::milliseconds milliSeconds)
 convert a milliseconds value to a time string in the TIME_FORMAT_HH_MM_SS format
 
static bool IsNaturalNumber (std::string_view str) noexcept
 check whether a string is a natural number. Matches [ \t]*[0-9]+[ \t]*
 
static bool IsInteger (std::string_view str) noexcept
 check whether a string is an integer. Matches [ \t]*[-]*[0-9]+[ \t]*
 
static bool isasciidigit (char chr) noexcept
 
static bool isasciixdigit (char chr) noexcept
 
static int asciidigitvalue (char chr) noexcept
 
static int asciixdigitvalue (char chr) noexcept
 
static bool isasciiuppercaseletter (char chr) noexcept
 
static bool isasciilowercaseletter (char chr) noexcept
 
static bool isasciiletter (char chr) noexcept
 
static bool isasciialphanum (char chr) noexcept
 
static std::string SizeToString (int64_t size)
 
static size_t FindWords (std::string_view str, std::string_view wordLowerCase) noexcept
 
static int FindEndBracket (std::string_view str, char opener, char closer, int startPos=0) noexcept
 
static int DateStringToYYYYMMDD (std::string_view dateString)
 
static std::string ISODateToLocalizedDate (std::string_view strIsoDate)
 
static void WordToDigits (std::string &word) noexcept
 
static std::string CreateUUID ()
 
static bool ValidateUUID (const std::string &uuid)
 
static double CompareFuzzy (std::string_view left, std::string_view right) noexcept
 
static int FindBestMatch (std::string_view str, std::span< const std::string_view > strings, double &matchscore) noexcept
 
static int FindBestMatch (std::string_view str, std::span< const std::string > strings, double &matchscore) noexcept
 
static bool ContainsKeyword (std::string_view str, std::span< const std::string_view > keywords) noexcept
 
static bool ContainsKeyword (std::string_view str, std::span< const std::string > keywords) noexcept
 
static std::string BinaryStringToString (std::string_view in)
 Convert the string of binary chars to the actual string.
 
static std::string ToHexadecimal (std::string_view in)
 
template<typename T>
static std::string FormatNumber (T num)
 Format the string with locale separators.
 
static std::string Paramify (std::string param)
 Escapes the given string to be able to be used as a parameter.
 
static std::string DeParamify (std::string param)
 Unescapes the given string.
 
static std::vector< std::string > Tokenize (std::string_view input, std::string_view delimiters)
 Split a string by the specified delimiters. Splits a string using one or more delimiting characters, ignoring empty tokens. Differs from Split() in two ways:
 
static void Tokenize (std::string_view input, std::vector< std::string > &tokens, std::string_view delimiters)
 
static std::vector< std::string > Tokenize (std::string_view input, const char delimiter)
 
static void Tokenize (std::string_view input, std::vector< std::string > &tokens, const char delimiter)
 
static uint32_t ToUint32 (std::string_view str, uint32_t fallback=0)
 Converts a string to a unsigned int number.
 
static uint64_t ToUint64 (std::string_view str, uint64_t fallback=0)
 Converts a string to a unsigned long long number.
 
static float ToFloat (std::string_view str, float fallback=0.0f)
 Converts a string to a float number.
 
static std::string FormatFileSize (uint64_t bytes)
 
static std::string CreateFromCString (const char *cstr)
 Converts a cstring pointer (const char*) to a std::string. In case nullptr is passed the result is an empty string.
 
static bool Contains (std::string_view str, std::string_view keyword, bool isCaseInsensitive=true) noexcept
 Check if a keyword string is contained on another string.
 

Static Public Attributes

static const std::string Empty = ""
 

Member Function Documentation

◆ AlphaNumericCollation()

int KODI::UTILS::StringUtils::AlphaNumericCollation ( int nKey1,
const void * pKey1,
int nKey2,
const void * pKey2 )
staticnodiscardnoexcept

◆ AlphaNumericCompare()

int64_t KODI::UTILS::StringUtils::AlphaNumericCompare ( std::wstring_view left,
std::wstring_view right )
staticnodiscardnoexcept

◆ asciidigitvalue()

int KODI::UTILS::StringUtils::asciidigitvalue ( char chr)
staticnodiscardnoexcept

◆ asciixdigitvalue()

int KODI::UTILS::StringUtils::asciixdigitvalue ( char chr)
staticnodiscardnoexcept

◆ BinaryStringToString()

std::string KODI::UTILS::StringUtils::BinaryStringToString ( std::string_view in)
staticnodiscard

Convert the string of binary chars to the actual string.

Convert the string representation of binary chars to the actual string. For example \1\2\3 is converted to a string with binary char \1, \2 and \3

Parameters
paramString to convert
Returns
Converted string

◆ CompareFuzzy()

double KODI::UTILS::StringUtils::CompareFuzzy ( std::string_view left,
std::string_view right )
staticnodiscardnoexcept

◆ CompareNoCase()

int KODI::UTILS::StringUtils::CompareNoCase ( std::string_view str1,
std::string_view str2,
size_t n = 0 )
staticnodiscardnoexcept

◆ Contains()

bool KODI::UTILS::StringUtils::Contains ( std::string_view str,
std::string_view keyword,
bool isCaseInsensitive = true )
staticnodiscardnoexcept

Check if a keyword string is contained on another string.

Parameters
strThe string in which to search for the keyword
keywordThe string to search for
Returns
True if the keyword if found.

◆ ContainsKeyword() [1/2]

bool KODI::UTILS::StringUtils::ContainsKeyword ( std::string_view str,
std::span< const std::string > keywords )
staticnodiscardnoexcept

◆ ContainsKeyword() [2/2]

bool KODI::UTILS::StringUtils::ContainsKeyword ( std::string_view str,
std::span< const std::string_view > keywords )
staticnodiscardnoexcept

◆ CreateFromCString()

std::string KODI::UTILS::StringUtils::CreateFromCString ( const char * cstr)
staticnodiscard

Converts a cstring pointer (const char*) to a std::string. In case nullptr is passed the result is an empty string.

Parameters
cstrthe const pointer to char
Returns
the resulting std::string or ""

◆ CreateUUID()

std::string KODI::UTILS::StringUtils::CreateUUID ( )
staticnodiscard

◆ DateStringToYYYYMMDD()

int KODI::UTILS::StringUtils::DateStringToYYYYMMDD ( std::string_view dateString)
staticnodiscard

◆ DeParamify()

std::string KODI::UTILS::StringUtils::DeParamify ( std::string param)
staticnodiscard

Unescapes the given string.

Unescapes backslashes and double-quotes and removes double-quotes around the whole string.

Parameters
paramString to unescape/deparamify
Returns
Unescaped/Deparamified string

◆ EndsWith()

bool KODI::UTILS::StringUtils::EndsWith ( std::string_view str1,
std::string_view str2 )
staticnodiscardnoexcept

◆ EndsWithNoCase()

bool KODI::UTILS::StringUtils::EndsWithNoCase ( std::string_view str1,
std::string_view str2 )
staticnodiscardnoexcept

◆ EqualsNoCase()

bool KODI::UTILS::StringUtils::EqualsNoCase ( std::string_view str1,
std::string_view str2 )
staticnodiscardnoexcept

◆ FindBestMatch() [1/2]

int KODI::UTILS::StringUtils::FindBestMatch ( std::string_view str,
std::span< const std::string > strings,
double & matchscore )
staticnodiscardnoexcept

◆ FindBestMatch() [2/2]

int KODI::UTILS::StringUtils::FindBestMatch ( std::string_view str,
std::span< const std::string_view > strings,
double & matchscore )
staticnodiscardnoexcept

◆ FindEndBracket()

int KODI::UTILS::StringUtils::FindEndBracket ( std::string_view str,
char opener,
char closer,
int startPos = 0 )
staticnodiscardnoexcept

◆ FindNumber()

int KODI::UTILS::StringUtils::FindNumber ( std::string_view strInput,
std::string_view strFind )
staticnodiscardnoexcept

◆ FindWords()

size_t KODI::UTILS::StringUtils::FindWords ( std::string_view str,
std::string_view wordLowerCase )
staticnodiscardnoexcept

◆ Format() [1/2]

template<typename... Args>
static constexpr std::string KODI::UTILS::StringUtils::Format ( std::string_view format,
Args &&... args )
inlinestaticconstexpr

Get a formatted string similar to sprintf.

Parameters
fmtFormat of the resulting string
...variable number of value type arguments
Returns
Formatted string

◆ Format() [2/2]

template<typename... Args>
static constexpr std::wstring KODI::UTILS::StringUtils::Format ( std::wstring_view format,
Args &&... args )
inlinestaticconstexpr

◆ FormatFileSize()

std::string KODI::UTILS::StringUtils::FormatFileSize ( uint64_t bytes)
staticnodiscard

Returns bytes in a human readable format using the smallest unit that will fit bytes in at most three digits. The number of decimals are adjusted with significance such that 'small' numbers will have more decimals than larger ones.

For example: 1024 bytes will be formatted as "1.00kB", 10240 bytes as "10.0kB" and 102400 bytes as "100kB". See TestStringUtils for more examples.

◆ FormatNumber()

template<typename T>
static std::string KODI::UTILS::StringUtils::FormatNumber ( T num)
inlinestaticnodiscard

Format the string with locale separators.

Format the string with locale separators. For example 10000.57 in en-us is '10,000.57' but in italian is '10.000,57'

Parameters
paramString to format
Returns
Formatted string

◆ FormatV() [1/2]

static std::string KODI::UTILS::StringUtils::FormatV ( PRINTF_FORMAT_STRING const char * fmt,
va_list args )
staticnodiscard

◆ FormatV() [2/2]

static std::wstring KODI::UTILS::StringUtils::FormatV ( PRINTF_FORMAT_STRING const wchar_t * fmt,
va_list args )
staticnodiscard

◆ isasciialphanum()

static bool KODI::UTILS::StringUtils::isasciialphanum ( char chr)
inlinestaticnodiscardnoexcept

◆ isasciidigit()

static bool KODI::UTILS::StringUtils::isasciidigit ( char chr)
inlinestaticnodiscardnoexcept

◆ isasciiletter()

static bool KODI::UTILS::StringUtils::isasciiletter ( char chr)
inlinestaticnodiscardnoexcept

◆ isasciilowercaseletter()

static bool KODI::UTILS::StringUtils::isasciilowercaseletter ( char chr)
inlinestaticnodiscardnoexcept

◆ isasciiuppercaseletter()

static bool KODI::UTILS::StringUtils::isasciiuppercaseletter ( char chr)
inlinestaticnodiscardnoexcept

◆ isasciixdigit()

static bool KODI::UTILS::StringUtils::isasciixdigit ( char chr)
inlinestaticnodiscardnoexcept

◆ IsInteger()

bool KODI::UTILS::StringUtils::IsInteger ( std::string_view str)
staticnodiscardnoexcept

check whether a string is an integer. Matches [ \t]*[-]*[0-9]+[ \t]*

Parameters
strthe string to check
Returns
true if the string is an integer, false otherwise.

◆ IsNaturalNumber()

bool KODI::UTILS::StringUtils::IsNaturalNumber ( std::string_view str)
staticnodiscardnoexcept

check whether a string is a natural number. Matches [ \t]*[0-9]+[ \t]*

Parameters
strthe string to check
Returns
true if the string is a natural number, false otherwise.

◆ ISODateToLocalizedDate()

std::string KODI::UTILS::StringUtils::ISODateToLocalizedDate ( std::string_view strIsoDate)
staticnodiscard

◆ IsSpecialCharacter()

bool KODI::UTILS::StringUtils::IsSpecialCharacter ( char c)
staticnodiscardnoexcept

Check if the character is a special character.

A special character is not an alphanumeric character, and is not useful to provide information

Parameters
cInput character to be checked

◆ Join()

template<typename CONTAINER>
static std::string KODI::UTILS::StringUtils::Join ( const CONTAINER & strings,
std::string_view delimiter )
inlinestaticnodiscard

◆ Left()

std::string KODI::UTILS::StringUtils::Left ( std::string_view str,
size_t count )
staticnodiscard

◆ Mid()

std::string KODI::UTILS::StringUtils::Mid ( std::string_view str,
size_t first,
size_t count = std::string_view::npos )
staticnodiscard

◆ MillisecondsToTimeString()

std::string KODI::UTILS::StringUtils::MillisecondsToTimeString ( std::chrono::milliseconds milliSeconds)
staticnodiscard

convert a milliseconds value to a time string in the TIME_FORMAT_HH_MM_SS format

Parameters
milliSecondstime in milliseconds
Returns
the formatted time
See also
TIME_FORMAT

◆ Paramify()

std::string KODI::UTILS::StringUtils::Paramify ( std::string param)
staticnodiscard

Escapes the given string to be able to be used as a parameter.

Escapes backslashes and double-quotes with an additional backslash and adds double-quotes around the whole string.

Parameters
paramString to escape/paramify
Returns
Escaped/Paramified string

◆ RemoveCRLF()

void KODI::UTILS::StringUtils::RemoveCRLF ( std::string & strLine)
staticnoexcept

◆ RemoveDuplicatedSpacesAndTabs()

std::string & KODI::UTILS::StringUtils::RemoveDuplicatedSpacesAndTabs ( std::string & str)
staticnoexcept

◆ Replace() [1/3]

int KODI::UTILS::StringUtils::Replace ( std::string & str,
char oldChar,
char newChar )
staticnoexcept

◆ Replace() [2/3]

int KODI::UTILS::StringUtils::Replace ( std::string & str,
std::string_view oldStr,
std::string_view newStr )
static

◆ Replace() [3/3]

int KODI::UTILS::StringUtils::Replace ( std::wstring & str,
std::wstring_view oldStr,
std::wstring_view newStr )
static

◆ ReplaceSpecialCharactersWithSpace()

std::string KODI::UTILS::StringUtils::ReplaceSpecialCharactersWithSpace ( std::string_view str)
staticnodiscard

◆ ReturnDigits()

int KODI::UTILS::StringUtils::ReturnDigits ( std::string_view str)
staticnodiscardnoexcept

◆ Right()

std::string KODI::UTILS::StringUtils::Right ( std::string_view str,
size_t count )
staticnodiscard

◆ SecondsToTimeString()

std::string KODI::UTILS::StringUtils::SecondsToTimeString ( long seconds,
TIME_FORMAT format = TIME_FORMAT_GUESS )
staticnodiscard

convert a time in seconds to a string based on the given time format

Parameters
secondstime in seconds
formatthe format we want the time in.
Returns
the formatted time
See also
TIME_FORMAT

◆ SizeToString()

std::string KODI::UTILS::StringUtils::SizeToString ( int64_t size)
staticnodiscard

◆ Split() [1/4]

std::vector< std::string > KODI::UTILS::StringUtils::Split ( std::string_view input,
char delimiter,
size_t iMaxStrings = 0 )
staticnodiscard

◆ Split() [2/4]

std::vector< std::string > KODI::UTILS::StringUtils::Split ( std::string_view input,
std::span< const std::string > delimiters )
staticnodiscard

◆ Split() [3/4]

std::vector< std::string > KODI::UTILS::StringUtils::Split ( std::string_view input,
std::span< const std::string_view > delimiters )
staticnodiscard

◆ Split() [4/4]

std::vector< std::string > KODI::UTILS::StringUtils::Split ( std::string_view input,
std::string_view delimiter,
unsigned int iMaxStrings = 0 )
staticnodiscard

Splits the given input string using the given delimiter into separate strings.

If the given input string is empty the result will be an empty array (not an array containing an empty string).

Parameters
inputInput string to be split
delimiterDelimiter to be used to split the input string
iMaxStrings(optional) Maximum number of split strings

◆ SplitMulti() [1/4]

std::vector< std::string > KODI::UTILS::StringUtils::SplitMulti ( std::span< const std::string > input,
std::span< const std::string > delimiters,
size_t iMaxStrings = 0 )
staticnodiscard

Splits the given input strings using the given delimiters into further separate strings.

If the given input string vector is empty the result will be an empty array (not an array containing an empty string).

Delimiter strings are applied in order, so once the (optional) maximum number of items is produced no other delimiters are applied. This produces different results to applying all delimiters at once e.g. "a/b#c/d" becomes "a", "b#c", "d" rather than "a", "b", "c/d"

Parameters
inputInput vector of strings each to be split
delimitersDelimiter strings to be used to split the input strings
iMaxStrings(optional) Maximum number of resulting split strings

◆ SplitMulti() [2/4]

std::vector< std::string > KODI::UTILS::StringUtils::SplitMulti ( std::span< const std::string > input,
std::span< const std::string_view > delimiters,
size_t iMaxStrings = 0 )
staticnodiscard

◆ SplitMulti() [3/4]

std::vector< std::string > KODI::UTILS::StringUtils::SplitMulti ( std::span< const std::string_view > input,
std::span< const std::string > delimiters,
size_t iMaxStrings = 0 )
staticnodiscard

◆ SplitMulti() [4/4]

std::vector< std::string > KODI::UTILS::StringUtils::SplitMulti ( std::span< const std::string_view > input,
std::span< const std::string_view > delimiters,
size_t iMaxStrings = 0 )
staticnodiscard

◆ SplitTo() [1/3]

template<typename OutputIt>
static OutputIt KODI::UTILS::StringUtils::SplitTo ( OutputIt d_first,
std::string_view input,
char delimiter,
size_t iMaxStrings = 0 )
inlinestatic

◆ SplitTo() [2/3]

template<typename OutputIt, typename StringLike>
static OutputIt KODI::UTILS::StringUtils::SplitTo ( OutputIt d_first,
std::string_view input,
std::span< StringLike > delimiters )
inlinestatic

◆ SplitTo() [3/3]

template<typename OutputIt>
static OutputIt KODI::UTILS::StringUtils::SplitTo ( OutputIt d_first,
std::string_view input,
std::string_view delimiter,
unsigned int iMaxStrings = 0 )
inlinestatic

Splits the given input string using the given delimiter into separate strings.

If the given input string is empty nothing will be put into the target iterator.

Parameters
d_firstthe beginning of the destination range
inputInput string to be split
delimiterDelimiter to be used to split the input string
iMaxStrings(optional) Maximum number of split strings
Returns
output iterator to the element in the destination range, one past the last element that was put there

◆ StartsWith()

bool KODI::UTILS::StringUtils::StartsWith ( std::string_view str1,
std::string_view str2 )
staticnodiscardnoexcept

◆ StartsWithNoCase()

bool KODI::UTILS::StringUtils::StartsWithNoCase ( std::string_view str1,
std::string_view str2 )
staticnodiscardnoexcept

◆ TimeStringToSeconds()

long KODI::UTILS::StringUtils::TimeStringToSeconds ( std::string_view timeString)
staticnodiscard

◆ ToCapitalize() [1/2]

void KODI::UTILS::StringUtils::ToCapitalize ( std::string & str)
staticnoexcept

◆ ToCapitalize() [2/2]

void KODI::UTILS::StringUtils::ToCapitalize ( std::wstring & str)
staticnoexcept

◆ ToFloat()

float KODI::UTILS::StringUtils::ToFloat ( std::string_view str,
float fallback = 0.0f )
staticnodiscard

Converts a string to a float number.

Parameters
strThe string to convert
fallback[OPT] The number to return when the conversion fails
Returns
The converted number, otherwise fallback if conversion fails

◆ ToHexadecimal()

std::string KODI::UTILS::StringUtils::ToHexadecimal ( std::string_view in)
staticnodiscard

Convert each character in the string to its hexadecimal representation and return the concatenated result

example: "abc\n" -> "6162630a"

◆ Tokenize() [1/4]

std::vector< std::string > KODI::UTILS::StringUtils::Tokenize ( std::string_view input,
const char delimiter )
staticnodiscard

◆ Tokenize() [2/4]

std::vector< std::string > KODI::UTILS::StringUtils::Tokenize ( std::string_view input,
std::string_view delimiters )
staticnodiscard

Split a string by the specified delimiters. Splits a string using one or more delimiting characters, ignoring empty tokens. Differs from Split() in two ways:

  1. The delimiters are treated as individual characters, rather than a single delimiting string.
  2. Empty tokens are ignored.
    Returns
    a vector of tokens

◆ Tokenize() [3/4]

void KODI::UTILS::StringUtils::Tokenize ( std::string_view input,
std::vector< std::string > & tokens,
const char delimiter )
static

◆ Tokenize() [4/4]

void KODI::UTILS::StringUtils::Tokenize ( std::string_view input,
std::vector< std::string > & tokens,
std::string_view delimiters )
static

◆ ToLower() [1/4]

void KODI::UTILS::StringUtils::ToLower ( std::string & str)
staticnoexcept

◆ ToLower() [2/4]

std::string KODI::UTILS::StringUtils::ToLower ( std::string_view str)
staticnodiscard

◆ ToLower() [3/4]

void KODI::UTILS::StringUtils::ToLower ( std::wstring & str)
staticnoexcept

◆ ToLower() [4/4]

std::wstring KODI::UTILS::StringUtils::ToLower ( std::wstring_view str)
staticnodiscard

◆ ToUint32()

uint32_t KODI::UTILS::StringUtils::ToUint32 ( std::string_view str,
uint32_t fallback = 0 )
staticnodiscard

Converts a string to a unsigned int number.

Parameters
strThe string to convert
fallback[OPT] The number to return when the conversion fails
Returns
The converted number, otherwise fallback if conversion fails

◆ ToUint64()

uint64_t KODI::UTILS::StringUtils::ToUint64 ( std::string_view str,
uint64_t fallback = 0 )
staticnodiscard

Converts a string to a unsigned long long number.

Parameters
strThe string to convert
fallback[OPT] The number to return when the conversion fails
Returns
The converted number, otherwise fallback if conversion fails

◆ ToUpper() [1/4]

void KODI::UTILS::StringUtils::ToUpper ( std::string & str)
staticnoexcept

◆ ToUpper() [2/4]

std::string KODI::UTILS::StringUtils::ToUpper ( std::string_view str)
staticnodiscard

◆ ToUpper() [3/4]

void KODI::UTILS::StringUtils::ToUpper ( std::wstring & str)
staticnoexcept

◆ ToUpper() [4/4]

std::wstring KODI::UTILS::StringUtils::ToUpper ( std::wstring_view str)
staticnodiscard

◆ Trim() [1/2]

std::string & KODI::UTILS::StringUtils::Trim ( std::string & str)
staticnoexcept

◆ Trim() [2/2]

std::string & KODI::UTILS::StringUtils::Trim ( std::string & str,
std::string_view chars )
staticnoexcept

◆ TrimLeft() [1/2]

std::string & KODI::UTILS::StringUtils::TrimLeft ( std::string & str)
staticnoexcept

◆ TrimLeft() [2/2]

std::string & KODI::UTILS::StringUtils::TrimLeft ( std::string & str,
std::string_view chars )
staticnoexcept

◆ TrimRight() [1/2]

std::string & KODI::UTILS::StringUtils::TrimRight ( std::string & str)
staticnoexcept

◆ TrimRight() [2/2]

std::string & KODI::UTILS::StringUtils::TrimRight ( std::string & str,
std::string_view chars )
staticnoexcept

◆ utf8_strlen()

size_t KODI::UTILS::StringUtils::utf8_strlen ( std::string_view s)
staticnodiscardnoexcept

utf8 version of strlen - skips any non-starting bytes in the count, thus returning the number of utf8 characters

Parameters
sc-string to find the length of.
Returns
the number of utf8 characters in the string.

◆ ValidateUUID()

bool KODI::UTILS::StringUtils::ValidateUUID ( const std::string & uuid)
staticnodiscard

◆ WordToDigits()

void KODI::UTILS::StringUtils::WordToDigits ( std::string & word)
staticnoexcept

Member Data Documentation

◆ Empty

const std::string KODI::UTILS::StringUtils::Empty = ""
static

The documentation for this class was generated from the following files: