Check strings for the desired state
With this, texts can be checked to see that they correspond to a required format.
◆ EqualsNoCase() [1/3]
static bool EqualsNoCase |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2 |
|
) |
| |
|
inlinestatic |
Compare two strings with ignore of lower-/uppercase.
- Parameters
-
[in] | str1 | C++ string to compare |
[in] | str2 | C++ string to compare |
- Returns
- True if the strings are equal, false otherwise
Example:
#include <kodi/tools/StringUtils.h>
std::string refstr = "TeSt";
◆ EqualsNoCase() [2/3]
static bool EqualsNoCase |
( |
const std::string & |
str1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Compare two strings with ignore of lower-/uppercase.
- Parameters
-
[in] | str1 | C++ string to compare |
[in] | s2 | C string to compare |
- Returns
- True if the strings are equal, false otherwise
◆ EqualsNoCase() [3/3]
static bool EqualsNoCase |
( |
const char * |
s1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Compare two strings with ignore of lower-/uppercase.
- Parameters
-
[in] | s1 | C string to compare |
[in] | s2 | C string to compare |
- Returns
- True if the strings are equal, false otherwise
◆ CompareNoCase() [1/2]
static int CompareNoCase |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2, |
|
|
size_t |
n = 0 |
|
) |
| |
|
inlinestatic |
Compare two strings with ignore of lower-/uppercase with given size.
Equal to EqualsNoCase only that size can defined and on return the difference between compared character becomes given.
- Parameters
-
[in] | str1 | C++ string to compare |
[in] | str2 | C++ string to compare |
[in] | n | [opt] Length to check, 0 as default to make complete |
- Returns
- 0 if equal, otherwise difference of failed character in string to other ("a" - "b" = -1)
◆ CompareNoCase() [2/2]
static int CompareNoCase |
( |
const char * |
s1, |
|
|
const char * |
s2, |
|
|
size_t |
n = 0 |
|
) |
| |
|
inlinestatic |
Compare two strings with ignore of lower-/uppercase with given size.
Equal to EqualsNoCase only that size can defined and on return the difference between compared character becomes given.
- Parameters
-
[in] | s1 | C string to compare |
[in] | s2 | C string to compare |
[in] | n | [opt] Length to check, 0 as default to make complete |
- Returns
- 0 if equal, otherwise difference of failed character in string to other ("a" - "b" = -1)
◆ StartsWith() [1/3]
static bool StartsWith |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | str2 | C++ string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
Example:
#include <kodi/tools/StringUtils.h>
bool ret;
std::string refstr = "test";
fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
◆ StartsWith() [2/3]
static bool StartsWith |
( |
const std::string & |
str1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
◆ StartsWith() [3/3]
static bool StartsWith |
( |
const char * |
s1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string.
- Parameters
-
[in] | s1 | C string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
◆ StartsWithNoCase() [1/3]
static bool StartsWithNoCase |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string by ignore of upper-/lowercase.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | str2 | C++ string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
Example:
#include <kodi/tools/StringUtils.h>
bool ret;
std::string refstr = "test";
fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
◆ StartsWithNoCase() [2/3]
static bool StartsWithNoCase |
( |
const std::string & |
str1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string by ignore of upper-/lowercase.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
◆ StartsWithNoCase() [3/3]
static bool StartsWithNoCase |
( |
const char * |
s1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the begin of another string by ignore of upper-/lowercase.
- Parameters
-
[in] | s1 | C string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the beginning |
- Returns
- True if string started with asked text, false otherwise
◆ EndsWith() [1/2]
static bool EndsWith |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2 |
|
) |
| |
|
inlinestatic |
Checks a string for the ending of another string.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | str2 | C++ string with which text defined in str1 is checked at the ending |
- Returns
- True if string ended with asked text, false otherwise
Example:
#include <kodi/tools/StringUtils.h>
bool ret;
std::string refstr = "test";
fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
◆ EndsWith() [2/2]
static bool EndsWith |
( |
const std::string & |
str1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the ending of another string.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the ending |
- Returns
- True if string ended with asked text, false otherwise
◆ EndsWithNoCase() [1/2]
static bool EndsWithNoCase |
( |
const std::string & |
str1, |
|
|
const std::string & |
str2 |
|
) |
| |
|
inlinestatic |
Checks a string for the ending of another string by ignore of upper-/lowercase.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | str2 | C++ string with which text defined in str1 is checked at the ending |
- Returns
- True if string ended with asked text, false otherwise
Example:
#include <kodi/tools/StringUtils.h>
bool ret;
std::string refstr = "test";
fprintf(stderr, "Excpect true for here and is '%s'\n", ret ? "true" : "false");
fprintf(stderr, "Excpect false for here and is '%s'\n", ret ? "true" : "false");
◆ EndsWithNoCase() [2/2]
static bool EndsWithNoCase |
( |
const std::string & |
str1, |
|
|
const char * |
s2 |
|
) |
| |
|
inlinestatic |
Checks a string for the ending of another string by ignore of upper-/lowercase.
- Parameters
-
[in] | str1 | C++ string to be checked |
[in] | s2 | C string with which text defined in str1 is checked at the ending |
- Returns
- True if string ended with asked text, false otherwise
◆ AlphaNumericCompare()
static int64_t AlphaNumericCompare |
( |
const wchar_t * |
left, |
|
|
const wchar_t * |
right |
|
) |
| |
|
inlinestatic |
Compare two strings by his calculated alpha numeric values.
- Parameters
-
[in] | left | Left string to compare with right |
[in] | right | Right string to compare with left |
- Returns
- Return about compare
- 0 if left and right the same
- -1 if right is longer
- 1 if left is longer
- < 0 if less equal
- > 0 if more equal
Example:
#include <kodi/tools/StringUtils.h>
int64_t ref, var;
ref = 0;
EXPECT_LT(var, ref);
◆ Utf8StringLength()
static size_t Utf8StringLength |
( |
const char * |
s | ) |
|
|
inlinestatic |
UTF8 version of strlen.
Skips any non-starting bytes in the count, thus returning the number of utf8 characters.
- Parameters
-
[in] | s | c-string to find the length of. |
- Returns
- The number of utf8 characters in the string.
◆ IsSpace()
static int IsSpace |
( |
char |
c | ) |
|
|
inlinestatic |
Check given character is a space.
Hack to check only first byte of UTF-8 character without this hack "TrimX" functions failed on Win32 and OS X with UTF-8 strings
- Parameters
-
- Returns
- true if space, false otherwise
◆ IsUTF8Letter()
static int IsUTF8Letter |
( |
const unsigned char * |
str | ) |
|
|
inlinestatic |
Checks given pointer in string is a UTF8 letter.
- Parameters
-
[in] | str | Given character values to check, must be minimum array of 2 |
- Returns
- return -1 if not, else return the utf8 char length.
◆ IsNaturalNumber()
static bool IsNaturalNumber |
( |
const std::string & |
str | ) |
|
|
inlinestatic |
Check whether a string is a natural number.
Matches [ \t]*[0-9]+[ \t]*
- Parameters
-
[in] | str | The string to check |
- Returns
- true if the string is a natural number, false otherwise.
Example:
#include <kodi/tools/StringUtils.h>
◆ IsInteger()
static bool IsInteger |
( |
const std::string & |
str | ) |
|
|
inlinestatic |
Check whether a string is an integer.
Matches [ \t]*[\-]*[0-9]+[ \t]*
- Parameters
-
- Returns
- true if the string is an integer, false otherwise.
Example:
#include <kodi/tools/StringUtils.h>
◆ IsAasciiDigit()
static bool IsAasciiDigit |
( |
char |
chr | ) |
|
|
inlinestatic |
Checks a character is ascii number.
- Parameters
-
[in] | chr | Single character to test |
- Returns
- true if yes, false otherwise
◆ IsAsciiXDigit()
static bool IsAsciiXDigit |
( |
char |
chr | ) |
|
|
inlinestatic |
Checks a character is ascii hexadecimal number.
- Parameters
-
[in] | chr | Single character to test |
- Returns
- true if yes, false otherwise
◆ AsciiDigitValue()
static int AsciiDigitValue |
( |
char |
chr | ) |
|
|
inlinestatic |
Translate a character where defined as a numerical value (0-9) string to right integer.
- Parameters
-
[in] | chr | Single character to translate |
- Returns
◆ AsciiXDigitValue()
static int AsciiXDigitValue |
( |
char |
chr | ) |
|
|
inlinestatic |
Translate a character where defined as a hexadecimal value string to right integer.
- Parameters
-
[in] | chr | Single character to translate |
- Returns
- Corresponding integer value, e.g. character is "A" becomes returned as a integer with 10.
◆ IsAsciiUppercaseLetter()
static bool IsAsciiUppercaseLetter |
( |
char |
chr | ) |
|
|
inlinestatic |
Checks a character is ascii alphabetic lowercase.
- Parameters
-
[in] | chr | Single character to test |
- Returns
- True if ascii uppercase letter, false otherwise
◆ IsAsciiLowercaseLetter()
static bool IsAsciiLowercaseLetter |
( |
char |
chr | ) |
|
|
inlinestatic |
Checks a character is ascii alphabetic lowercase.
- Parameters
-
[in] | chr | Single character to test |
- Returns
- True if ascii lowercase letter, false otherwise
◆ IsAsciiAlphaNum()
static bool IsAsciiAlphaNum |
( |
char |
chr | ) |
|
|
inlinestatic |
Checks a character is within ascii alphabetic and numerical fields.
- Parameters
-
[in] | chr | Single character to test |
- Returns
- true if alphabetic / numerical ascii value
◆ ContainsKeyword()
static bool ContainsKeyword |
( |
const std::string & |
str, |
|
|
const std::vector< std::string > & |
keywords |
|
) |
| |
|
inlinestatic |
Check a string for another text.
- Parameters
-
[in] | str | String to seach for keywords |
[in] | keywords | List of keywords to search in text |
- Returns
- true if string contains word in list