KittyMemoryEx 1.0.0
Dedicated library for runtime code patching, memory scanning, tracing, injection and some more useful memory utilities. works for both Android and Linux
Loading...
Searching...
No Matches
KittyUtils::String Namespace Reference

Provides utility functions for strings. More...

Functions

bool charEqualsIgnoreCase (char a, char b)
 Helper to compare two characters case-insensitively.
bool startsWith (const std::string &str, const std::string &prefix, bool sensitive=true)
 Checks if a string starts with a given prefix.
bool startsWith (const std::string &str, const std::vector< std::string > &prefixes, bool sensitive=true)
 Checks if a string starts with any of the given prefixes.
bool contains (const std::string &str, const std::string &substring, bool sensitive=true)
 Checks if a string contains a given substring.
bool contains (const std::string &str, const std::vector< std::string > &substrings, bool sensitive=true)
 Checks if a string contains any of the given substrings.
bool endsWith (const std::string &str, const std::string &suffix, bool sensitive=true)
 Checks if a string ends with a given suffix.
bool endsWith (const std::string &str, const std::vector< std::string > &suffixes, bool sensitive=true)
 Checks if a string ends with any of the given suffixes.
void trim (std::string &str)
 Trims whitespace from the beginning and end of a string.
void removeAllWhitespace (std::string &str)
 Removes all whitespace characters from a string, not just leading/trailing.
bool isValidHex (const std::string &hex)
 Checks if the provided string is a valid hexadecimal representation.
bool validateHex (std::string &hex)
 Validates a hexadecimal string.
std::string fmt (const char *fmt,...)
 Formats a string using a printf-style format.

Detailed Description

Provides utility functions for strings.

Function Documentation

◆ contains() [1/2]

bool KittyUtils::String::contains ( const std::string & str,
const std::string & substring,
bool sensitive = true )

Checks if a string contains a given substring.

Parameters
strThe string to check.
substringThe substring to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str contains substring, false otherwise.

◆ contains() [2/2]

bool KittyUtils::String::contains ( const std::string & str,
const std::vector< std::string > & substrings,
bool sensitive = true )

Checks if a string contains any of the given substrings.

Parameters
strThe string to check.
substringsA list of substrings to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str contains at least one substring in substrings, false otherwise.

◆ endsWith() [1/2]

bool KittyUtils::String::endsWith ( const std::string & str,
const std::string & suffix,
bool sensitive = true )

Checks if a string ends with a given suffix.

Parameters
strThe string to check.
suffixThe suffix to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str ends with suffix, false otherwise.

◆ endsWith() [2/2]

bool KittyUtils::String::endsWith ( const std::string & str,
const std::vector< std::string > & suffixes,
bool sensitive = true )

Checks if a string ends with any of the given suffixes.

Parameters
strThe string to check.
suffixesA list of suffixes to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str ends with at least one suffix in suffixes, false otherwise.

◆ fmt()

std::string KittyUtils::String::fmt ( const char * fmt,
... )

Formats a string using a printf-style format.

Parameters
fmtThe format string.
...Variable arguments to be formatted.
Returns
The formatted string.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidHex()

bool KittyUtils::String::isValidHex ( const std::string & hex)

Checks if the provided string is a valid hexadecimal representation.

This function validates if the given string is a valid hexadecimal number. A valid hexadecimal number can contain characters '0'-'9' and 'A-F' or 'a-f'.

Parameters
hexThe string to validate as a hexadecimal number.
Returns
true if the string is a valid hexadecimal number, false otherwise.

◆ removeAllWhitespace()

void KittyUtils::String::removeAllWhitespace ( std::string & str)

Removes all whitespace characters from a string, not just leading/trailing.

Parameters
strThe string to strip whitespace from.

◆ startsWith() [1/2]

bool KittyUtils::String::startsWith ( const std::string & str,
const std::string & prefix,
bool sensitive = true )

Checks if a string starts with a given prefix.

Parameters
strThe string to check.
prefixThe prefix to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str starts with prefix, false otherwise.

◆ startsWith() [2/2]

bool KittyUtils::String::startsWith ( const std::string & str,
const std::vector< std::string > & prefixes,
bool sensitive = true )

Checks if a string starts with any of the given prefixes.

Parameters
strThe string to check.
prefixesA list of prefixes to look for.
sensitiveWhether the comparison should be case-sensitive (default is true).
Returns
true if str starts with at least one prefix in prefixes, false otherwise.

◆ trim()

void KittyUtils::String::trim ( std::string & str)

Trims whitespace from the beginning and end of a string.

Parameters
strThe string to be trimmed.

◆ validateHex()

bool KittyUtils::String::validateHex ( std::string & hex)

Validates a hexadecimal string.

Parameters
hexThe hexadecimal string to validate.
Returns
True if the string was validated, false otherwise.