tgbot-cpp
Loading...
Searching...
No Matches
StringTools Namespace Reference

Functions

TGBOT_API bool startsWith (const std::string &str1, const std::string &str2)
 
TGBOT_API bool endsWith (const std::string &str1, const std::string &str2)
 
TGBOT_API void split (const std::string &str, char delimiter, std::vector< std::string > &dest)
 
TGBOT_API std::string generateRandomString (std::size_t length)
 
TGBOT_API std::string urlEncode (const std::string &value, const std::string &additionalLegitChars="")
 
TGBOT_API std::string urlDecode (const std::string &value)
 
std::string escapeJsonString (const std::string &value)
 
std::vector< std::string > split (const std::string &str, char delimiter)
 

Function Documentation

◆ endsWith()

TGBOT_API bool StringTools::endsWith ( const std::string & str1,
const std::string & str2 )

Checks if first string is ending with second string

Parameters
str1First string
str2Second string

◆ escapeJsonString()

std::string StringTools::escapeJsonString ( const std::string & value)

Escapes a string with illegal characters ("\/) for json

Parameters
valueinput string
Returns
An encoded string

◆ generateRandomString()

TGBOT_API std::string StringTools::generateRandomString ( std::size_t length)

Generates pseudo random string. It's recommended to call srand before this method.

Parameters
lengthLength of resulting string.

◆ split() [1/2]

std::vector< std::string > StringTools::split ( const std::string & str,
char delimiter )
inline

Splits string to smaller substrings which have between them a delimiter. Resulting substrings won't have delimiter.

Parameters
strSource string
delimiterDelimiter
Returns
Array of substrings

Definition at line 80 of file StringTools.h.

◆ split() [2/2]

TGBOT_API void StringTools::split ( const std::string & str,
char delimiter,
std::vector< std::string > & dest )

Splits string to smaller substrings which have between them a delimiter. Resulting substrings won't have delimiter.

Parameters
strSource string
delimiterDelimiter
destArray to which substrings will be saved.

◆ startsWith()

TGBOT_API bool StringTools::startsWith ( const std::string & str1,
const std::string & str2 )

Checks if first string is starting with second string

Parameters
str1First string
str2Second string

◆ urlDecode()

TGBOT_API std::string StringTools::urlDecode ( const std::string & value)

Performs url decode.

Parameters
valueEncoded url string
Returns
Decoded url string

◆ urlEncode()

TGBOT_API std::string StringTools::urlEncode ( const std::string & value,
const std::string & additionalLegitChars = "" )

Performs url encode.

Parameters
valueSource url string
additionalLegitCharsOptional. String of chars which will be not encoded in source url string.
Returns
Encoded url string