Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

To search a string
Various functions are defined in here which allow you to search through a text in different ways. More...

Functions

static size_t kodi::tools::StringUtils::FindWords (const char *str, const char *wordLowerCase)
 Search for a single word within a text.
 
static size_t kodi::tools::StringUtils::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 kodi::tools::StringUtils::FindNumber (const std::string &strInput, const std::string &strFind)
 Search a text and return the number of parts found as a number.
 

Detailed Description

To search a string
Various functions are defined in here which allow you to search through a text in different ways.

Function Documentation

◆ FindEndBracket()

static size_t kodi::tools::StringUtils::FindEndBracket ( const std::string & str,
char opener,
char closer,
size_t startPos = 0 )
inlinestatic

Search a string for a given bracket and give its end position.

Parameters
[in]strString to search within
[in]openerBegin character to start search
[in]closerEnd character to end search
[in]startPos[opt] Position to start search in string, 0 as default to start from begin
Returns
End position where found, -1 if failed

Example:

int ref, var;
ref = 11;
var = kodi::tools::StringUtils::FindEndBracket("atest testbb test", 'a', 'b');
EXPECT_EQ(ref, var);
EXPECT_EQ(dateTime1.GetHour(), 12)
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.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:2389

◆ FindNumber()

static int kodi::tools::StringUtils::FindNumber ( const std::string & strInput,
const std::string & strFind )
inlinestatic

Search a text and return the number of parts found as a number.

Parameters
[in]strInputInput string to search for
[in]strFindString to search in input
Returns
Amount how much the string is found

Example:

static int FindNumber(const std::string &strInput, const std::string &strFind)
Search a text and return the number of parts found as a number.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:2428

◆ FindWords()

static size_t kodi::tools::StringUtils::FindWords ( const char * str,
const char * wordLowerCase )
inlinestatic

Search for a single word within a text.

Parameters
[in]strString to search within
[in]wordLowerCaseWord as lowercase to search
Returns
Position in string where word is found, -1 (std::string::npos) if not found

Example:

size_t ref, var;
// The name "string" is alone within text and becomes found on position 5
ref = 5;
var = kodi::tools::StringUtils::FindWords("test string", "string");
EXPECT_EQ(ref, var);
// The 12 is included inside another word and then not found as it should alone (-1 return)
ref = -1;
var = kodi::tools::StringUtils::FindWords("apple2012", "12");
EXPECT_EQ(ref, var);
static size_t FindWords(const char *str, const char *wordLowerCase)
Search for a single word within a text.
Definition addons/kodi-dev-kit/include/kodi/tools/StringUtils.h:2318