Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
kodi::tools::StringUtils Class Reference

#include <StringUtils.h>

Static Public Member Functions

static std::string Format (const char *fmt,...)
 Returns the C++ string pointed by given format. If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
 
static std::wstring Format (const wchar_t *fmt,...)
 Returns the C++ wide string pointed by given format.
 
static std::string FormatV (PRINTF_FORMAT_STRING const char *fmt, va_list args)
 Returns the C++ string pointed by given format list.
 
static std::wstring FormatV (PRINTF_FORMAT_STRING const wchar_t *fmt, va_list args)
 Returns the C++ wide string pointed by given format list.
 
static std::string FormatFileSize (uint64_t bytes)
 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.
 
static std::string BinaryStringToString (const std::string &in)
 Convert the string of binary chars to the actual string.
 
static std::string ToHexadecimal (const std::string &in)
 Convert each character in the string to its hexadecimal representation and return the concatenated result.
 
static void ToUpper (std::string &str)
 Convert a string to uppercase.
 
static void ToUpper (std::wstring &str)
 Convert a 16bit wide string to uppercase.
 
static void ToLower (std::string &str)
 Convert a string to lowercase.
 
static void ToLower (std::wstring &str)
 Convert a 16bit wide string to lowercase.
 
static int ReturnDigits (const std::string &str)
 Combine all numerical digits and give it as integer value.
 
static std::string Left (const std::string &str, size_t count)
 Returns a string from start with givent count.
 
static std::string Mid (const std::string &str, size_t first, size_t count=std::string::npos)
 Get substring from mid of given string.
 
static std::string Right (const std::string &str, size_t count)
 Returns a string from end with givent count.
 
static std::string & Trim (std::string &str)
 Trim a string with remove of not wanted spaces at begin and end of string.
 
static std::string & Trim (std::string &str, const char *const chars)
 Trim a string with remove of not wanted characters at begin and end of string.
 
static std::string & TrimLeft (std::string &str)
 Trim a string with remove of not wanted spaces at begin of string.
 
static std::string & TrimLeft (std::string &str, const char *const chars)
 Trim a string with remove of not wanted characters at begin of string.
 
static std::string & TrimRight (std::string &str)
 Trim a string with remove of not wanted spaces at end of string.
 
static std::string & TrimRight (std::string &str, const char *const chars)
 Trim a string with remove of not wanted characters at end of string.
 
static std::string & RemoveDuplicatedSpacesAndTabs (std::string &str)
 Cleanup string by remove of duplicates of spaces and tabs.
 
static int Replace (std::string &str, char oldChar, char newChar)
 Replace a character with another inside text string.
 
static int Replace (std::string &str, const std::string &oldStr, const std::string &newStr)
 Replace a complete text with another inside text string.
 
static int Replace (std::wstring &str, const std::wstring &oldStr, const std::wstring &newStr)
 Replace a complete text with another inside 16bit wide text string.
 
static std::string MakeSafeUrl (const std::string &str)
 Transform characters to create a safe URL.
 
static std::string MakeSafeString (const std::string &str)
 Transform characters to create a safe, printable string.
 
static std::string RemoveMACAddress (const std::string &str)
 Removes a MAC address from a given string.
 
static void RemoveCRLF (std::string &strLine)
 Remove carriage return and line feeds on string ends.
 
static void WordToDigits (std::string &word)
 Convert a word to a digit numerical string.
 
static std::string Paramify (const std::string &param)
 Escapes the given string to be able to be used as a parameter.
 
static bool EqualsNoCase (const std::string &str1, const std::string &str2)
 Compare two strings with ignore of lower-/uppercase.
 
static bool EqualsNoCase (const std::string &str1, const char *s2)
 Compare two strings with ignore of lower-/uppercase.
 
static bool EqualsNoCase (const char *s1, const char *s2)
 Compare two strings with ignore of lower-/uppercase.
 
static int CompareNoCase (const std::string &str1, const std::string &str2, size_t n=0)
 Compare two strings with ignore of lower-/uppercase with given size.
 
static int CompareNoCase (const char *s1, const char *s2, size_t n=0)
 Compare two strings with ignore of lower-/uppercase with given size.
 
static bool StartsWith (const std::string &str1, const std::string &str2)
 Checks a string for the begin of another string.
 
static bool StartsWith (const std::string &str1, const char *s2)
 Checks a string for the begin of another string.
 
static bool StartsWith (const char *s1, const char *s2)
 Checks a string for the begin of another string.
 
static bool StartsWithNoCase (const std::string &str1, const std::string &str2)
 Checks a string for the begin of another string by ignore of upper-/lowercase.
 
static bool StartsWithNoCase (const std::string &str1, const char *s2)
 Checks a string for the begin of another string by ignore of upper-/lowercase.
 
static bool StartsWithNoCase (const char *s1, const char *s2)
 Checks a string for the begin of another string by ignore of upper-/lowercase.
 
static bool EndsWith (const std::string &str1, const std::string &str2)
 Checks a string for the ending of another string.
 
static bool EndsWith (const std::string &str1, const char *s2)
 Checks a string for the ending of another string.
 
static bool EndsWithNoCase (const std::string &str1, const std::string &str2)
 Checks a string for the ending of another string by ignore of upper-/lowercase.
 
static bool EndsWithNoCase (const std::string &str1, const char *s2)
 Checks a string for the ending of another string by ignore of upper-/lowercase.
 
static int64_t AlphaNumericCompare (const wchar_t *left, const wchar_t *right)
 Compare two strings by his calculated alpha numeric values.
 
static size_t Utf8StringLength (const char *s)
 UTF8 version of strlen.
 
static int IsSpace (char c)
 Check given character is a space.
 
static int IsUTF8Letter (const unsigned char *str)
 Checks given pointer in string is a UTF8 letter.
 
static bool IsNaturalNumber (const std::string &str)
 Check whether a string is a natural number.
 
static bool IsInteger (const std::string &str)
 Check whether a string is an integer.
 
static bool IsAasciiDigit (char chr)
 Checks a character is ascii number.
 
static bool IsAsciiXDigit (char chr)
 Checks a character is ascii hexadecimal number.
 
static int AsciiDigitValue (char chr)
 Translate a character where defined as a numerical value (0-9) string to right integer.
 
static int AsciiXDigitValue (char chr)
 Translate a character where defined as a hexadecimal value string to right integer.
 
static bool IsAsciiUppercaseLetter (char chr)
 Checks a character is ascii alphabetic lowercase.
 
static bool IsAsciiLowercaseLetter (char chr)
 Checks a character is ascii alphabetic lowercase.
 
static bool IsAsciiAlphaNum (char chr)
 Checks a character is within ascii alphabetic and numerical fields.
 
static bool ContainsKeyword (const std::string &str, const std::vector< std::string > &keywords)
 Check a string for another text.
 
static size_t FindWords (const char *str, const char *wordLowerCase)
 Search for a single word within a text.
 
static size_t FindEndBracket (const std::string &str, char opener, char closer, size_t startPos=0)
 Search a string for a given bracket and give its end position.
 
static int FindNumber (const std::string &strInput, const std::string &strFind)
 Search a text and return the number of parts found as a number.
 
template<typename CONTAINER >
static std::string Join (const CONTAINER &strings, const std::string &delimiter)
 Concatenates the elements of a specified array or the members of a collection and uses the specified separator between each element or member.
 
static std::vector< std::string > Split (const std::string &input, const std::string &delimiter, unsigned int iMaxStrings=0)
 Splits the given input string using the given delimiter into separate strings.
 
static std::vector< std::string > Split (const std::string &input, const char delimiter, int iMaxStrings=0)
 Splits the given input string using the given delimiter into separate strings.
 
static std::vector< std::string > Split (const std::string &input, const std::vector< std::string > &delimiters)
 Splits the given input string using the given delimiter into separate strings.
 
template<typename OutputIt >
static OutputIt SplitTo (OutputIt d_first, const std::string &input, const std::string &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, const std::string &input, const char delimiter, int iMaxStrings=0)
 Splits the given input string using the given delimiter into separate strings.
 
template<typename OutputIt >
static OutputIt SplitTo (OutputIt d_first, const std::string &input, const std::vector< std::string > &delimiters)
 Splits the given input string using the given delimiter into separate strings.
 
static std::vector< std::string > SplitMulti (const std::vector< std::string > &input, const std::vector< std::string > &delimiters, unsigned int iMaxStrings=0)
 Splits the given input strings using the given delimiters into further separate strings.
 
static std::vector< std::string > Tokenize (const std::string &input, const std::string &delimiters)
 Split a string by the specified delimiters.
 
static void Tokenize (const std::string &input, std::vector< std::string > &tokens, const std::string &delimiters)
 Tokenizing a string denotes splitting a string with respect to a delimiter.
 
static std::vector< std::string > Tokenize (const std::string &input, const char delimiter)
 Tokenizing a string denotes splitting a string with respect to a delimiter.
 
static void Tokenize (const std::string &input, std::vector< std::string > &tokens, const char delimiter)
 Tokenizing a string denotes splitting a string with respect to a delimiter.
 
static long TimeStringToSeconds (const std::string &timeString)
 Converts a time string to the respective integer value.
 
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 int DateStringToYYYYMMDD (const std::string &dateString)
 Converts a string in the format YYYYMMDD to the corresponding integer value.
 

Static Public Attributes

static const std::string Empty
 Defines a static empty std::string.
 

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