Rudiments
Static Public Member Functions | List of all members
charstring Class Reference

#include <charstring.h>

Static Public Member Functions

static size_t getLength (const char *string)
 
static size_t getSize (const char *string)
 
static bool isNullOrEmpty (const char *string)
 
static bool isYes (const char *string)
 
static bool isNo (const char *string)
 
static void zero (char *str, size_t len)
 
static charappend (char *dest, const char *source)
 
static charappend (char *dest, const char *source, size_t len)
 
static charappend (char *dest, int64_t number)
 
static charappend (char *dest, uint64_t number)
 
static charappend (char *dest, double number)
 
static charappend (char *dest, double number, uint16_t scale)
 
static charappend (char *dest, double number, uint16_t precision, uint16_t scale)
 
static charcopy (char *dest, const char *source)
 
static charcopy (char *dest, const char *source, size_t len)
 
static charcopy (char *dest, size_t location, const char *source)
 
static charcopy (char *dest, size_t location, const char *source, size_t len)
 
static charsafeCopy (char *dest, size_t destlen, const char *source)
 
static charsafeCopy (char *dest, size_t destlen, const char *source, size_t sourcelen)
 
static int32_t compare (const char *str1, const char *str2)
 
static int32_t compare (const char *str1, const char *str2, size_t len)
 
static int32_t compareIgnoringCase (const char *str1, const char *str2)
 
static int32_t compareIgnoringCase (const char *str1, const char *str2, size_t len)
 
static int32_t compareNatural (const char *str1, const char *str2)
 
static int32_t compareNatural (const char *str1, const char *str2, const char *delimiters)
 
static int32_t compareVersions (const char *str1, const char *str2)
 
static int32_t compareVersions (const char *str1, const char *str2, const char *delimiters)
 
static bool compareWithWildcards (const char *string, size_t stringlen, const char *pattern, size_t patternlen, char singlewildcard, char multiwildcard)
 
static bool compareWithWildcards (const char *string, const char *pattern, size_t patternlen, char singlewildcard, char multiwildcard)
 
static bool compareWithWildcards (const char *string, size_t stringlen, const char *pattern, char singlewildcard, char multiwildcard)
 
static bool compareWithWildcards (const char *string, const char *pattern, char singlewildcard, char multiwildcard)
 
static bool isInSet (const char *str, const char *const *set)
 
static bool isInSetIgnoringCase (const char *str, const char *const *set)
 
static bool contains (const char *haystack, const char *needle)
 
static bool containsIgnoringCase (const char *haystack, const char *needle)
 
static bool contains (const char *haystack, char needle)
 
static bool containsIgnoringCase (const char *haystack, char needle)
 
static bool startsWith (const char *haystack, const char *needle)
 
static bool endsWith (const char *haystack, const char *needle)
 
static const charfindFirst (const char *haystack, const char *needle)
 
static const charfindFirstIgnoringCase (const char *haystack, const char *needle)
 
static const charfindFirst (const char *haystack, char needle)
 
static const charfindFirstIgnoringCase (const char *haystack, char needle)
 
static const charfindFirstOrEnd (const char *haystack, const char *needle)
 
static const charfindFirstOrEndIgnoringCase (const char *haystack, const char *needle)
 
static const charfindFirstOrEnd (const char *haystack, char needle)
 
static const charfindFirstOrEndIgnoringCase (const char *haystack, char needle)
 
static const charfindLast (const char *haystack, const char *needle)
 
static const charfindLastIgnoringCase (const char *haystack, const char *needle)
 
static const charfindLast (const char *haystack, char needle)
 
static const charfindLastIgnoringCase (const char *haystack, char needle)
 
static charfindFirst (char *haystack, const char *needle)
 
static charfindFirstIgnoringCase (char *haystack, const char *needle)
 
static charfindFirst (char *haystack, char needle)
 
static charfindFirstIgnoringCase (char *haystack, char needle)
 
static charfindFirstOrEnd (char *haystack, const char *needle)
 
static charfindFirstOrEndIgnoringCase (char *haystack, const char *needle)
 
static charfindLast (char *haystack, const char *needle)
 
static charfindLastIgnoringCase (char *haystack, const char *needle)
 
static charfindLast (char *haystack, char needle)
 
static charfindLastIgnoringCase (char *haystack, char needle)
 
static const charfindFirstOfSet (const char *haystack, const char *set)
 
static charfindFirstOfSet (char *haystack, const char *set)
 
static const charfindFirstOfSetOrEnd (const char *haystack, const char *set)
 
static charfindFirstOfSetOrEnd (char *haystack, const char *set)
 
static const charfindLastOfSet (const char *haystack, const char *set)
 
static charfindLastOfSet (char *haystack, const char *set)
 
static const charfindLastOfSetOrEnd (const char *haystack, const char *set)
 
static charfindLastOfSetOrEnd (char *haystack, const char *set)
 
static charfindEndOfQuotedString (char *string, char quote, bool backslash, bool doubling)
 
static const charfindEndOfQuotedString (const char *string, char quote, bool backslash, bool doubling)
 
static charfindEndOfQuotedString (char *string, size_t stringlen, char quote, bool backslash, bool doubling)
 
static const charfindEndOfQuotedString (const char *string, size_t stringlen, char quote, bool backslash, bool doubling)
 
static charfindEndOfQuotedString (char *string, bool backslash, bool doubling)
 
static const charfindEndOfQuotedString (const char *string, bool backslash, bool doubling)
 
static charfindEndOfQuotedString (char *string, size_t stringlen, bool backslash, bool doubling)
 
static const charfindEndOfQuotedString (const char *string, size_t stringlen, bool backslash, bool doubling)
 
static charisBefore (const char *str, const char *delimiter)
 
static charisBetween (const char *str, const char *start, const char *end)
 
static charisAfter (const char *str, const char *delimiter)
 
static size_t getLengthContainingSet (const char *haystack, const char *set)
 
static size_t getLengthNotContainingSet (const char *haystack, const char *set)
 
static charduplicate (const char *str)
 
static charduplicate (const char *str, size_t len)
 
static charduplicate (const wchar_t *str)
 
static charduplicate (const wchar_t *str, size_t len)
 
static charduplicate (const wchar_t *str, char replacement)
 
static charduplicate (const wchar_t *str, size_t len, char replacement)
 
static charduplicateUcs2 (const ucs2_t *str)
 
static charduplicateUcs2 (const ucs2_t *str, size_t len)
 
static charduplicateUcs2 (const ucs2_t *str, bool bigendian)
 
static charduplicateUcs2 (const ucs2_t *str, size_t len, bool bigendian)
 
static charduplicateUcs2 (const ucs2_t *str, char replacement)
 
static charduplicateUcs2 (const ucs2_t *str, size_t len, char replacement)
 
static charduplicateUcs2 (const ucs2_t *str, char replacement, bool bigendian)
 
static charduplicateUcs2 (const ucs2_t *str, size_t len, char replacement, bool bigendian)
 
static void upper (char *str)
 
static void lower (char *str)
 
static void capitalize (char *str)
 
static void rightTrim (char *str)
 
static void rightTrim (char *str, char character)
 
static void leftTrim (char *str)
 
static void leftTrim (char *str, char character)
 
static void bothTrim (char *str)
 
static void bothTrim (char *str, char character)
 
static bool strip (char *str, char character)
 
static bool strip (char *str1, const char *str2)
 
static bool stripSet (char *str1, const char *set)
 
static void replace (char *str, char oldchar, char newchar)
 
static void replace (char *str, const char *oldchars, char newchar)
 
static charreplace (const char *str, const char *oldstr, const char *newstr)
 
static charreplace (const char *str, const char *const *oldstrset, const char *const *newstrset)
 
static charreplace (const char *str, const char *const *oldstrset, size_t *oldstrlen, const char *const *newstrset)
 
static void replaceIgnoringCase (char *str, char oldchar, char newchar)
 
static void replaceIgnoringCase (char *str, const char *oldchars, char newchar)
 
static charreplaceIgnoringCase (const char *str, const char *oldstr, const char *newstr)
 
static charreplaceIgnoringCase (const char *str, const char *const *oldstrset, const char *const *newstrset)
 
static charreplaceIgnoringCase (const char *str, const char *const *oldstrset, size_t *oldstrlen, const char *const *newstrset)
 
static charreplace (const char *str, regularexpression *from, const char *to, bool global)
 
static uint16_t getIntegerLength (int16_t number)
 
static uint16_t getIntegerLength (int32_t number)
 
static uint16_t getIntegerLength (int64_t number)
 
static uint16_t getIntegerLength (uint16_t number)
 
static uint16_t getIntegerLength (uint32_t number)
 
static uint16_t getIntegerLength (uint64_t number)
 
static bool isInteger (const char *val)
 
static bool isInteger (const char *val, int32_t len)
 
static bool isNumber (const char *val)
 
static bool isNumber (const char *val, int32_t len)
 
static charparseNumber (int16_t number)
 
static charparseNumber (uint16_t number)
 
static charparseNumber (int16_t number, uint16_t zeropadding)
 
static charparseNumber (uint16_t number, uint16_t zeropadding)
 
static charparseNumber (int32_t number)
 
static charparseNumber (uint32_t number)
 
static charparseNumber (int32_t number, uint16_t zeropadding)
 
static charparseNumber (uint32_t number, uint16_t zeropadding)
 
static charparseNumber (int64_t number)
 
static charparseNumber (uint64_t number)
 
static charparseNumber (int64_t number, uint16_t zeropadding)
 
static charparseNumber (uint64_t number, uint16_t zeropadding)
 
static charparseNumber (float number)
 
static charparseNumber (float number, uint16_t scale)
 
static charparseNumber (float number, uint16_t precision, uint16_t scale)
 
static charparseNumber (double number)
 
static charparseNumber (double number, uint16_t scale)
 
static charparseNumber (double number, uint16_t precision, uint16_t scale)
 
static charparseNumber (long double number)
 
static charparseNumber (long double number, uint16_t scale)
 
static charparseNumber (long double number, uint16_t precision, uint16_t scale)
 
static int64_t convertToInteger (const char *string)
 
static int64_t convertToInteger (const char *string, const char **endptr)
 
static int64_t convertToInteger (const char *string, int32_t base)
 
static int64_t convertToInteger (const char *string, const char **endptr, int32_t base)
 
static uint64_t convertToUnsignedInteger (const char *string)
 
static uint64_t convertToUnsignedInteger (const char *string, const char **endptr)
 
static uint64_t convertToUnsignedInteger (const char *string, int32_t base)
 
static uint64_t convertToUnsignedInteger (const char *string, const char **endptr, int32_t base)
 
static long double convertToFloat (const char *string)
 
static long double convertToFloatC (const char *string)
 
static long double convertToFloat (const char *string, const char **endptr)
 
static int64_t convertAmount (const char *amount)
 
static charconvertAmount (int64_t amount)
 
static charconvertAmount (int64_t amount, uint16_t padding)
 
static charescape (const char *input, const char *characters)
 
static charunescape (const char *input)
 
static void escape (const char *input, uint64_t inputlen, char **output, uint64_t *outputlen, const char *characters)
 
static void unescape (const char *input, uint64_t inputlen, char **output, uint64_t *outputlen)
 
static charurlEncode (const char *input)
 
static charurlDecode (const char *input)
 
static charbase64Encode (const byte_t *input)
 
static charbase64Encode (const byte_t *input, uint64_t inputsize)
 
static void base64Encode (const byte_t *input, uint64_t inputsize, char **output, uint64_t *outputlen)
 
static byte_t * base64Decode (const char *input)
 
static byte_t * base64Decode (const char *input, uint64_t inputlen)
 
static void base64Decode (const char *input, uint64_t inputlen, byte_t **output, uint64_t *outputsize)
 
static charquotedPrintableEncode (const byte_t *input)
 
static charquotedPrintableEncode (const byte_t *input, uint64_t inputsize)
 
static void quotedPrintableEncode (const byte_t *input, uint64_t inputsize, char **output, uint64_t *outputlen)
 
static byte_t * quotedPrintableDecode (const char *input)
 
static byte_t * quotedPrintableDecode (const char *input, uint64_t inputlen)
 
static void quotedPrintableDecode (const char *input, uint64_t inputlen, byte_t **output, uint64_t *outputlen)
 
static charhexEncode (const byte_t *input)
 
static charhexEncode (const byte_t *input, uint64_t inputsize)
 
static void hexEncode (const byte_t *input, uint64_t inputsize, char **output, uint64_t *outputlen)
 
static byte_t * hexDecode (const char *input)
 
static byte_t * hexDecode (const char *input, uint64_t inputlen)
 
static void hexDecode (const char *input, uint64_t inputlen, byte_t **output, uint64_t *outputsize)
 
static void obfuscate (char *str)
 
static void deobfuscate (char *str)
 
static void leftJustify (char *str, int32_t len)
 
static void rightJustify (char *str, int32_t len)
 
static void center (char *str, int32_t len)
 
static charpad (const char *string, char padchar, int16_t direction, uint64_t totallen)
 
static void split (const char *string, size_t stringlen, const char *delimiter, size_t delimiterlen, bool collapse, char ***list, uint64_t *listcount)
 
static void split (const char *string, const char *delimiter, size_t delimiterlen, bool collapse, char ***list, uint64_t *listcount)
 
static void split (const char *string, size_t stringlen, const char *delimiter, bool collapse, char ***list, uint64_t *listcount)
 
static void split (const char *string, const char *delimiter, bool collapse, char ***list, uint64_t *listcount)
 
static chargetSubString (const char *str, size_t start, size_t end)
 
static chargetSubString (const char *str, size_t start)
 
static charinsertString (const char *dest, const char *src, uint64_t index)
 
static chargetHumanReadable (int64_t number)
 
static chargetHumanReadable (int64_t number, bool onethousand)
 
static chargetHumanReadable (uint64_t number)
 
static chargetHumanReadable (uint64_t number, bool onethousand)
 
static chargetHumanReadable (long double number)
 
static chargetHumanReadable (long double number, bool onethousand)
 
static ssize_t printf (char *buffer, size_t len, const char *format,...)
 
static ssize_t printf (char *buffer, size_t len, const char *format, va_list *argp)
 
static ssize_t printf (char **buffer, const char *format,...)
 
static ssize_t printf (char **buffer, const char *format, va_list *argp)
 

Detailed Description

The charstring class provides static methods for manipulating C-style character strings.

In addition to some unique methods, analogs for the standard C string functions are provided. However, unlike the standard C string functions, the charstring methods are NULL safe. Your application will not crash if a NULL is passed in, and instead, will give intuitive results.

Note that meny method of this class expect to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

Member Function Documentation

◆ append() [1/7]

static char * charstring::append ( char * dest,
const char * source )
static

Appends "source" to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [2/7]

static char * charstring::append ( char * dest,
const char * source,
size_t len )
static

Appends "len" characters of "source" to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [3/7]

static char * charstring::append ( char * dest,
double number )
static

Converts "number" to a string and appends it to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [4/7]

static char * charstring::append ( char * dest,
double number,
uint16_t precision,
uint16_t scale )
static

Converts "number" to a string using "precision" and "scale" and appends it to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [5/7]

static char * charstring::append ( char * dest,
double number,
uint16_t scale )
static

Converts "number" to a string using "scale" and appends it to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [6/7]

static char * charstring::append ( char * dest,
int64_t number )
static

Converts "number" to a string and appends it to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ append() [7/7]

static char * charstring::append ( char * dest,
uint64_t number )
static

Converts "number" to a string and appends it to "dest". Assumes that there is enough room remaining in "dest" to accommodate the new string. Returns a pointer to "dest".

◆ base64Decode() [1/3]

static byte_t * charstring::base64Decode ( const char * input)
static

base64-decodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ base64Decode() [2/3]

static byte_t * charstring::base64Decode ( const char * input,
uint64_t inputlen )
static

similar to base64Decode above but only decodes the first "inputlen" characters of "input"

◆ base64Decode() [3/3]

static void charstring::base64Decode ( const char * input,
uint64_t inputlen,
byte_t ** output,
uint64_t * outputsize )
static

similar to base64Decode() above, but returns the result in "output" and "outputsize" (in bytes) rather than in a return value

◆ base64Encode() [1/3]

static char * charstring::base64Encode ( const byte_t * input)
static

base64-encodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ base64Encode() [2/3]

static char * charstring::base64Encode ( const byte_t * input,
uint64_t inputsize )
static

similar to base64Encode above but only encodes the first "inputsize" bytes of "input"

◆ base64Encode() [3/3]

static void charstring::base64Encode ( const byte_t * input,
uint64_t inputsize,
char ** output,
uint64_t * outputlen )
static

similar to base64Encode() above, but returns the result in "output" and "outputlen" (in characters) rather than in a return value

◆ bothTrim() [1/2]

static void charstring::bothTrim ( char * str)
static

Trims all spaces off of both sides of "str".

◆ bothTrim() [2/2]

static void charstring::bothTrim ( char * str,
char character )
static

Trims all characters off of both sides of "str".

◆ capitalize()

static void charstring::capitalize ( char * str)
static

Captitalizes "str", converting characters to upper or lower case as necessary.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ center()

static void charstring::center ( char * str,
int32_t len )
static

Centers the text of "str" for "len" characters.

Example: "hello " -> " hello "

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ compare() [1/2]

static int32_t charstring::compare ( const char * str1,
const char * str2 )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2".

◆ compare() [2/2]

static int32_t charstring::compare ( const char * str1,
const char * str2,
size_t len )
static

Returns -1,0 or 1 if "len" characters of "str1" are greater than, equal to or less than "len" characters of "str2".

◆ compareIgnoringCase() [1/2]

static int32_t charstring::compareIgnoringCase ( const char * str1,
const char * str2 )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2", ignoring case.

◆ compareIgnoringCase() [2/2]

static int32_t charstring::compareIgnoringCase ( const char * str1,
const char * str2,
size_t len )
static

Returns -1,0 or 1 if "len" characters of "str1" are greater than, equal to or less than "len" characters of "str2", ignoring case.

◆ compareNatural() [1/2]

static int32_t charstring::compareNatural ( const char * str1,
const char * str2 )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2".

Embedded (version) numbers will be interpreted "naturally" (eg. 12 > 8)

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ compareNatural() [2/2]

static int32_t charstring::compareNatural ( const char * str1,
const char * str2,
const char * delimiters )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2".

Embedded (version) numbers will be interpreted "naturally" (eg. 12 > 8)

"delimiters" should be set to the set of characters that will be interpreted as equivalent delimiters. Eg. "._" means that either .'s or _'s may be used to delimit numbers.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ compareVersions() [1/2]

static int32_t charstring::compareVersions ( const char * str1,
const char * str2 )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2", where "str1" and "str2" are version numbers with arbitrary numbers of decimal delimiters.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ compareVersions() [2/2]

static int32_t charstring::compareVersions ( const char * str1,
const char * str2,
const char * delimiters )
static

Returns -1,0 or 1 if "str1" is greater than, equal to or less than "str2", where "str1" and "str2" are version numbers with arbitrary numbers of delimiters.

"delimiters" should be set to the set of characters that will be interpreted as equivalent delimiters. Eg. "._" means that either .'s or _'s may be used to delimiters numbers.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ compareWithWildcards() [1/4]

static bool charstring::compareWithWildcards ( const char * string,
const char * pattern,
char singlewildcard,
char multiwildcard )
static

Compares "string" to "pattern" which may contain instances of single-character wildcard markers "singlewildcard" or multi-character wildcard markers "multiwildcard".

If either "singlewildcard" or "multiwildcard" are '\0' then they are ignored.

Returns true if a match is found or false otherwise.

◆ compareWithWildcards() [2/4]

static bool charstring::compareWithWildcards ( const char * string,
const char * pattern,
size_t patternlen,
char singlewildcard,
char multiwildcard )
static

Compares "string" to the first "patternlen" characters of "pattern" which may contain instances of single-character wildcard markers "singlewildcard" or multi-character wildcard markers "multiwildcard".

If either "singlewildcard" or "multiwildcard" are '\0' then they are ignored.

Returns true if a match is found or false otherwise.

◆ compareWithWildcards() [3/4]

static bool charstring::compareWithWildcards ( const char * string,
size_t stringlen,
const char * pattern,
char singlewildcard,
char multiwildcard )
static

Compares the first "stringlen" characters of "string" to "pattern" which may contain instances of single-character wildcard markers "singlewildcard" or multi-character wildcard markers "multiwildcard".

If either "singlewildcard" or "multiwildcard" are '\0' then they are ignored.

Returns true if a match is found or false otherwise.

◆ compareWithWildcards() [4/4]

static bool charstring::compareWithWildcards ( const char * string,
size_t stringlen,
const char * pattern,
size_t patternlen,
char singlewildcard,
char multiwildcard )
static

Compares the first "stringlen" characters of "string" to the first "patternlen" characters of "pattern" which may contain instances of single-character wildcard markers "singlewildcard" or multi-character wildcard markers "multiwildcard".

If either "singlewildcard" or "multiwildcard" are '\0' then they are ignored.

Returns true if a match is found or false otherwise.

◆ contains() [1/2]

static bool charstring::contains ( const char * haystack,
char needle )
static

Returns true if "haystack" contains "needle" or false otherwise.

◆ contains() [2/2]

static bool charstring::contains ( const char * haystack,
const char * needle )
static

Returns true if "haystack" contains "needle" or false otherwise.

◆ containsIgnoringCase() [1/2]

static bool charstring::containsIgnoringCase ( const char * haystack,
char needle )
static

Returns true if "haystack" contains "needle", ignoring case, or false otherwise.

◆ containsIgnoringCase() [2/2]

static bool charstring::containsIgnoringCase ( const char * haystack,
const char * needle )
static

Returns true if "haystack" contains "needle", ignoring case, or false otherwise.

◆ convertAmount() [1/3]

static int64_t charstring::convertAmount ( const char * amount)
static

Converts "amount" which is assumed to be a dollar amount into pennies.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ convertAmount() [2/3]

static char * charstring::convertAmount ( int64_t amount)
static

Converts "amount" which is assumed to be a number of pennies into a dollar amount string.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ convertAmount() [3/3]

static char * charstring::convertAmount ( int64_t amount,
uint16_t padding )
static

Converts "amount" which is assumed to be a number of pennies into a dollar amount string where there are "padding" places between the dollar sign and decimal point. These will be space padded if the amount is small enough not to fill them.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ convertToFloat() [1/2]

static long double charstring::convertToFloat ( const char * string)
static

Converts "string" to a floating point number.

◆ convertToFloat() [2/2]

static long double charstring::convertToFloat ( const char * string,
const char ** endptr )
static

Converts "string" to a floating point number. If non-NULL, endptr will be set to the first character in the string after the number.

◆ convertToFloatC()

static long double charstring::convertToFloatC ( const char * string)
static

Converts "string" to a floating point number.

If "string" uses a "." as a decimal point (per the "C" locale) then the "." is first converted to the appropriate decimal-delimiter for the current locale.

(Currently only supported on linux/unix platforms that provide the locale.h header. On other platforms, it just falls through to convertToFloat().)

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ convertToInteger() [1/4]

static int64_t charstring::convertToInteger ( const char * string)
static

Converts "string" to a 64-bit integer.

◆ convertToInteger() [2/4]

static int64_t charstring::convertToInteger ( const char * string,
const char ** endptr )
static

Converts "string" to a 64-bit integer. If non-NULL, endptr will be set to the first character in the string after the number.

◆ convertToInteger() [3/4]

static int64_t charstring::convertToInteger ( const char * string,
const char ** endptr,
int32_t base )
static

Converts "string" to a 64-bit integer of base "base". If non-NULL, endptr will be set to the first character in the string after the number.

◆ convertToInteger() [4/4]

static int64_t charstring::convertToInteger ( const char * string,
int32_t base )
static

Converts "string" to a 64-bit integer of base "base".

◆ convertToUnsignedInteger() [1/4]

static uint64_t charstring::convertToUnsignedInteger ( const char * string)
static

Converts "string" to a 64-bit unsigned integer.

◆ convertToUnsignedInteger() [2/4]

static uint64_t charstring::convertToUnsignedInteger ( const char * string,
const char ** endptr )
static

Converts "string" to a 64-bit unsigned integer. If non-NULL, endptr will be set to the first character in the string after the number.

◆ convertToUnsignedInteger() [3/4]

static uint64_t charstring::convertToUnsignedInteger ( const char * string,
const char ** endptr,
int32_t base )
static

Converts "string" to a 64-bit unsigned integer of base "base". If non-NULL, endptr will be set to the first character in the string after the number.

◆ convertToUnsignedInteger() [4/4]

static uint64_t charstring::convertToUnsignedInteger ( const char * string,
int32_t base )
static

Converts "string" to a 64-bit unsigned integer of base "base".

◆ copy() [1/4]

static char * charstring::copy ( char * dest,
const char * source )
static

Replaces "dest" with "source". Assumes that there is enough room in "dest" to accommodate "source". Returns a pointer to "dest".

◆ copy() [2/4]

static char * charstring::copy ( char * dest,
const char * source,
size_t len )
static

Replaces the first "len" characters of "dest" with "source". Assumes that "dest" is at least "len" characters long. Returns a pointer to "dest".

◆ copy() [3/4]

static char * charstring::copy ( char * dest,
size_t location,
const char * source )
static

Replaces "dest" with "source", starting "location" characters into "dest". Assumes that there is enough room in "dest" (after "location" characters) to accommodate "source". Returns a pointer to "dest".

◆ copy() [4/4]

static char * charstring::copy ( char * dest,
size_t location,
const char * source,
size_t len )
static

Replaces "len" characters of "dest" with "source", starting "location" characters into "dest". Assumes that there are "len" characters in "dest" (after "location" characters). Returns a pointer to "dest".

◆ deobfuscate()

static void charstring::deobfuscate ( char * str)
static

Deobfuscates "str" which was obfusacted using the obfuscate method of this class.

◆ duplicate() [1/6]

static char * charstring::duplicate ( const char * str)
static

Creates a duplicate of "str" and returns a pointer to it. Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicate() [2/6]

static char * charstring::duplicate ( const char * str,
size_t len )
static

Creates a duplicate of the first "len" characters of "str" and returns a pointer to it. Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicate() [3/6]

static char * charstring::duplicate ( const wchar_t * str)
static

Creates a duplicate of "str", converting each wide character to an ASCII character, replacing characters that can't be represented in ASCII with an ASCII '?', and returns a pointer to it. Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicate() [4/6]

static char * charstring::duplicate ( const wchar_t * str,
char replacement )
static

Creates a duplicate of "str", converting each wide character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicate() [5/6]

static char * charstring::duplicate ( const wchar_t * str,
size_t len )
static

Creates a duplicate of the first "len" wide characters of "str", converting each wide character to a character per the character set of the current locale, replacing characters that can't be represented '?', and returns a pointer to it.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicate() [6/6]

static char * charstring::duplicate ( const wchar_t * str,
size_t len,
char replacement )
static

Creates a duplicate of the first "len" wide characters of "str", converting each wide character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [1/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str)
static

Creates a duplicate of "str", converting each UCS-2 character to an ASCII character, replacing characters that can't be represented in ASCII with an ASCII '?', and returns a pointer to it.

The UCS-2 characters in "str" are presumed to be in the byte-order of the system.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [2/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
bool bigendian )
static

Creates a duplicate of "str", converting each UCS-2 character to an ASCII character, replacing characters that can't be represented in ASCII with an ASCII '?', and returns a pointer to it.

If "bigendian" is true then "str" is presumed to be big endian. If "bigendian" is false, then "str" is presumed to be little endian.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [3/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
char replacement )
static

Creates a duplicate of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

The UCS-2 characters in "str" are presumed to be in the byte-order of the system.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [4/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
char replacement,
bool bigendian )
static

Creates a duplicate of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

If "bigendian" is true then "str" is presumed to be big endian. If "bigendian" is false, then "str" is presumed to be little endian.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [5/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
size_t len )
static

Creates a duplicate of the first "len" UCS-2 characters of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented '?', and returns a pointer to it.

The UCS-2 characters in "str" are presumed to be in the byte-order of the system.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [6/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
size_t len,
bool bigendian )
static

Creates a duplicate of the first "len" UCS-2 characters of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented '?', and returns a pointer to it.

If "bigendian" is true then "str" is presumed to be big endian. If "bigendian" is false, then "str" is presumed to be little endian.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [7/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
size_t len,
char replacement )
static

Creates a duplicate of the first "len" UCS-2 characters of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

The UCS-2 characters in "str" are presumed to be in the byte-order of the system.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ duplicateUcs2() [8/8]

static char * charstring::duplicateUcs2 ( const ucs2_t * str,
size_t len,
char replacement,
bool bigendian )
static

Creates a duplicate of the first "len" UCS-2 characters of "str", converting each UCS-2 character to a character per the character set of the current locale, replacing characters that can't be represented with "replacement", and returns a pointer to it.

If "bigendian" is true then "str" is presumed to be big endian. If "bigendian" is false, then "str" is presumed to be little endian.

Note that this method allocates a buffer for the duplicate string internally and returns it. The calling program must deallocate this buffer.

◆ endsWith()

static bool charstring::endsWith ( const char * haystack,
const char * needle )
static

Returns true if "haystack" ends with "needle" or false otherwise.

◆ escape() [1/2]

static char * charstring::escape ( const char * input,
const char * characters )
static

escapes all characters in "characters" found in "input" using \'s and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ escape() [2/2]

static void charstring::escape ( const char * input,
uint64_t inputlen,
char ** output,
uint64_t * outputlen,
const char * characters )
static

similar to escape() above, but takes an "inputlen" parameter and returns the result in "output" and "outputlen" rather than in a return value

◆ findEndOfQuotedString() [1/8]

static char * charstring::findEndOfQuotedString ( char * string,
bool backslash,
bool doubling )
static

Where "string" is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

The character to interpret as a quote is determined by the first character in the string.

Note, that in the case of the first character being an open square bracket, the closing quote is set to a closing square bracket, and doubling is disabled, independent of the value of the parameter "doubling".

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [2/8]

static char * charstring::findEndOfQuotedString ( char * string,
char quote,
bool backslash,
bool doubling )
static

Where "string" is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

"quote" specifies the character to interpret as a quote, eg. a single-quote, double-quote, back-quote, etc. but may be any character. Note that the first character of "string" is not validated to be "quote".

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [3/8]

static char * charstring::findEndOfQuotedString ( char * string,
size_t stringlen,
bool backslash,
bool doubling )
static

Where "string", of length "stringlen", is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

The character to interpret as a quote is determined by the first character in the string.

Note, that in the case of the first character being an open square bracket, the closing quote is set to a closing square bracket, and doubling is disabled, independent of the value of the parameter "doubling".

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [4/8]

static char * charstring::findEndOfQuotedString ( char * string,
size_t stringlen,
char quote,
bool backslash,
bool doubling )
static

Where "string", of length "stringlen", is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

"quote" specifies the character to interpret as a quote, eg. a single-quote, double-quote, back-quote, etc. but may be any character. Note that the first character of "string" is not validated to be "quote".

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [5/8]

static const char * charstring::findEndOfQuotedString ( const char * string,
bool backslash,
bool doubling )
static

Where "string" is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

The character to interpret as a quote is determined by the first character in the string.

Note, that in the case of the first character being an open square bracket, the closing quote is set to a closing square bracket, and doubling is disabled, independent of the value of the parameter "doubling".

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [6/8]

static const char * charstring::findEndOfQuotedString ( const char * string,
char quote,
bool backslash,
bool doubling )
static

Where "string" is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

"quote" specifies the character to interpret as a quote, eg. a single-quote, double-quote, back-quote, etc. but may be any character. Note that the first character of "string" is not validated to be "quote".

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [7/8]

static const char * charstring::findEndOfQuotedString ( const char * string,
size_t stringlen,
bool backslash,
bool doubling )
static

Where "string", of length "stringlen", is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

The character to interpret as a quote is determined by the first character in the string.

Note, that in the case of the first character being an open square bracket, the closing quote is set to a closing square bracket, and doubling is disabled, independent of the value of the parameter "doubling".

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findEndOfQuotedString() [8/8]

static const char * charstring::findEndOfQuotedString ( const char * string,
size_t stringlen,
char quote,
bool backslash,
bool doubling )
static

Where "string", of length "stringlen", is presumed to contain a quoted string (eg. "'hello'"), the first character of which is an opening quote, this method returns a pointer to the position in the string, immediately following the closing quote.

"quote" specifies the character to interpret as a quote, eg. a single-quote, double-quote, back-quote, etc. but may be any character. Note that the first character of "string" is not validated to be "quote".

If "backslash" is true then backslash-escaping is considered. If "doubling" is true then doubling to represent a literal quote is considered.

Returns NULL if "string" is NULL. Returns a pointer to "string" if "stringlen" is 0. If no closing quote is found then it returns a pointer to the end of the string.

◆ findFirst() [1/4]

static char * charstring::findFirst ( char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or NULL if not found.

◆ findFirst() [2/4]

static char * charstring::findFirst ( char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or NULL if not found.

◆ findFirst() [3/4]

static const char * charstring::findFirst ( const char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or NULL if not found.

◆ findFirst() [4/4]

static const char * charstring::findFirst ( const char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or NULL if not found.

◆ findFirstIgnoringCase() [1/4]

static char * charstring::findFirstIgnoringCase ( char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findFirstIgnoringCase() [2/4]

static char * charstring::findFirstIgnoringCase ( char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findFirstIgnoringCase() [3/4]

static const char * charstring::findFirstIgnoringCase ( const char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findFirstIgnoringCase() [4/4]

static const char * charstring::findFirstIgnoringCase ( const char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findFirstOfSet() [1/2]

static char * charstring::findFirstOfSet ( char * haystack,
const char * set )
static

Returns a pointer to the first occurence in "haystack" of any of the characters in "set" or NULL if not found.

◆ findFirstOfSet() [2/2]

static const char * charstring::findFirstOfSet ( const char * haystack,
const char * set )
static

Returns a pointer to the first occurence in "haystack" of any of the characters in "set" or NULL if not found.

◆ findFirstOfSetOrEnd() [1/2]

static char * charstring::findFirstOfSetOrEnd ( char * haystack,
const char * set )
static

Returns a pointer to the first occurence in "haystack" of any of the characters in "set". or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOfSetOrEnd() [2/2]

static const char * charstring::findFirstOfSetOrEnd ( const char * haystack,
const char * set )
static

Returns a pointer to the first occurence in "haystack" of any of the characters in "set" or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEnd() [1/3]

static char * charstring::findFirstOrEnd ( char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEnd() [2/3]

static const char * charstring::findFirstOrEnd ( const char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEnd() [3/3]

static const char * charstring::findFirstOrEnd ( const char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack" or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEndIgnoringCase() [1/3]

static char * charstring::findFirstOrEndIgnoringCase ( char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEndIgnoringCase() [2/3]

static const char * charstring::findFirstOrEndIgnoringCase ( const char * haystack,
char needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or a pointer to the NULL terminator at the end of the string if not found.

◆ findFirstOrEndIgnoringCase() [3/3]

static const char * charstring::findFirstOrEndIgnoringCase ( const char * haystack,
const char * needle )
static

Returns a pointer to the first occurrance of "needle" in "haystack", ignoring case, or a pointer to the NULL terminator at the end of the string if not found.

◆ findLast() [1/4]

static char * charstring::findLast ( char * haystack,
char needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack" or NULL if not found.

◆ findLast() [2/4]

static char * charstring::findLast ( char * haystack,
const char * needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack" or NULL if not found.

◆ findLast() [3/4]

static const char * charstring::findLast ( const char * haystack,
char needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack" or NULL if not found.

◆ findLast() [4/4]

static const char * charstring::findLast ( const char * haystack,
const char * needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack" or NULL if not found.

◆ findLastIgnoringCase() [1/4]

static char * charstring::findLastIgnoringCase ( char * haystack,
char needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findLastIgnoringCase() [2/4]

static char * charstring::findLastIgnoringCase ( char * haystack,
const char * needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findLastIgnoringCase() [3/4]

static const char * charstring::findLastIgnoringCase ( const char * haystack,
char needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findLastIgnoringCase() [4/4]

static const char * charstring::findLastIgnoringCase ( const char * haystack,
const char * needle )
static

Returns a pointer to the last occurrance of "needle" in "haystack", ignoring case, or NULL if not found.

◆ findLastOfSet() [1/2]

static char * charstring::findLastOfSet ( char * haystack,
const char * set )
static

Returns a pointer to the last occurence in "haystack" of any of the characters in "set" or NULL if not found.

◆ findLastOfSet() [2/2]

static const char * charstring::findLastOfSet ( const char * haystack,
const char * set )
static

Returns a pointer to the last occurence in "haystack" of any of the characters in "set" or NULL if not found.

◆ findLastOfSetOrEnd() [1/2]

static char * charstring::findLastOfSetOrEnd ( char * haystack,
const char * set )
static

Returns a pointer to the last occurence in "haystack" of any of the characters in "set". or a pointer to the NULL terminator at the end of the string if not found.

◆ findLastOfSetOrEnd() [2/2]

static const char * charstring::findLastOfSetOrEnd ( const char * haystack,
const char * set )
static

Returns a pointer to the last occurence in "haystack" of any of the characters in "set" or a pointer to the NULL terminator at the end of the string if not found.

◆ getHumanReadable() [1/6]

static char * charstring::getHumanReadable ( int64_t number)
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

Where 1K = 1024.

◆ getHumanReadable() [2/6]

static char * charstring::getHumanReadable ( int64_t number,
bool onethousand )
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

If "onethousand" = true then 1K = 1000, otherwise 1K = 1024.

◆ getHumanReadable() [3/6]

static char * charstring::getHumanReadable ( long double number)
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

◆ getHumanReadable() [4/6]

static char * charstring::getHumanReadable ( long double number,
bool onethousand )
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

If "onethousand" = true then 1K = 1000, otherwise 1K = 1024.

◆ getHumanReadable() [5/6]

static char * charstring::getHumanReadable ( uint64_t number)
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

◆ getHumanReadable() [6/6]

static char * charstring::getHumanReadable ( uint64_t number,
bool onethousand )
static

Returns a human-readable version of the number.

Eg. 128, 1.2K, 2.4M, 3.5G, 4.6T, etc.

If "onethousand" = true then 1K = 1000, otherwise 1K = 1024.

◆ getIntegerLength() [1/6]

static uint16_t charstring::getIntegerLength ( int16_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getIntegerLength() [2/6]

static uint16_t charstring::getIntegerLength ( int32_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getIntegerLength() [3/6]

static uint16_t charstring::getIntegerLength ( int64_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getIntegerLength() [4/6]

static uint16_t charstring::getIntegerLength ( uint16_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getIntegerLength() [5/6]

static uint16_t charstring::getIntegerLength ( uint32_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getIntegerLength() [6/6]

static uint16_t charstring::getIntegerLength ( uint64_t number)
static

Returns the number of characters needed to represent "number" as a string.

◆ getLength()

static size_t charstring::getLength ( const char * string)
static

Returns the number of characters in "string".

Note that this method expects to operate on strings encoded using a single-byte encoding, and will give unexpected results for multi-byte-encoded strings.

◆ getLengthContainingSet()

static size_t charstring::getLengthContainingSet ( const char * haystack,
const char * set )
static

Returns the number of characters, starting at the beginning of "haystack" which consists entirely of characters in "set".

◆ getLengthNotContainingSet()

static size_t charstring::getLengthNotContainingSet ( const char * haystack,
const char * set )
static

Returns the number of characters, starting at the beginning of "haystack" which consists entirely of characters not in "set".

◆ getSize()

static size_t charstring::getSize ( const char * string)
static

Returns the number of bytes in "string", including the null terminator.

◆ getSubString() [1/2]

static char * charstring::getSubString ( const char * str,
size_t start )
static

Returns a copy of the segment of "str" between string index "start" and the end of the string, inclusive.

◆ getSubString() [2/2]

static char * charstring::getSubString ( const char * str,
size_t start,
size_t end )
static

Returns a copy of the segment of "str" between string indices "start" and "end", inclusive.

◆ hexDecode() [1/3]

static byte_t * charstring::hexDecode ( const char * input)
static

hex-decodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ hexDecode() [2/3]

static byte_t * charstring::hexDecode ( const char * input,
uint64_t inputlen )
static

similar to hexDecode above but only decodes the first "inputlen" characters of "input"

◆ hexDecode() [3/3]

static void charstring::hexDecode ( const char * input,
uint64_t inputlen,
byte_t ** output,
uint64_t * outputsize )
static

similar to hexDecode() above, but returns the result in "output" and "outputsize" rather than in a return value

◆ hexEncode() [1/3]

static char * charstring::hexEncode ( const byte_t * input)
static

hex-encodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ hexEncode() [2/3]

static char * charstring::hexEncode ( const byte_t * input,
uint64_t inputsize )
static

similar to hexEncode above but only encodes the first "inputsize" bytes of "input"

◆ hexEncode() [3/3]

static void charstring::hexEncode ( const byte_t * input,
uint64_t inputsize,
char ** output,
uint64_t * outputlen )
static

similar to hexEncode() above, but returns the result in "output" and "outputlen" (in characters) rather than in a return value

◆ insertString()

static char * charstring::insertString ( const char * dest,
const char * src,
uint64_t index )
static

Creates a new string with "src" inserted into "dest" at "index".

◆ isAfter()

static char * charstring::isAfter ( const char * str,
const char * delimiter )
static

Returns the string from the "delimiter" until the end of the string. Note that this method allocates a buffer for the return value internally and returns it. The calling program must deallocate this buffer.

◆ isBefore()

static char * charstring::isBefore ( const char * str,
const char * delimiter )
static

Returns the string from the beginning of "str" until Note that this method allocates a buffer for the return value internally and returns it. The calling program must deallocate this buffer.

◆ isBetween()

static char * charstring::isBetween ( const char * str,
const char * start,
const char * end )
static

Returns the string between "start" and "end". Note that this method allocates a buffer for the return value internally and returns it. The calling program must deallocate this buffer.

◆ isInSet()

static bool charstring::isInSet ( const char * str,
const char *const * set )
static

Returns true if "str" is found among the values in the NULL-terminated array "set". Also returns true if "str" is NULL and set is NULL or contains only a NULL-terminator. Otherwise returns false.

◆ isInSetIgnoringCase()

static bool charstring::isInSetIgnoringCase ( const char * str,
const char *const * set )
static

Returns true if "str" is found among the values in the NULL-terminated array "set", ignoring case. Also returns true if "str" is NULL and set is NULL or contains only a NULL-terminator. Otherwise returns false.

◆ isInteger() [1/2]

static bool charstring::isInteger ( const char * val)
static

Returns true if the string "val" is an integer and false if it is not an integer.

◆ isInteger() [2/2]

static bool charstring::isInteger ( const char * val,
int32_t len )
static

Returns true if the string "val" is an integer and false if it is not an integer.

◆ isNo()

static bool charstring::isNo ( const char * string)
static

Returns true if "string" starts with the standalone word: "No" (case-insensitive), "False" (case-insensitive), or "0" and false otherwise.

(Eg. returns true for "No,", "False ", and "0 1 2" but returns false for "Nothing", "Falsest", and "012")

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ isNullOrEmpty()

static bool charstring::isNullOrEmpty ( const char * string)
static

Returns true if "string" is NULL or the empty string.

◆ isNumber() [1/2]

static bool charstring::isNumber ( const char * val)
static

Returns true the string "val" is a number and false if it is not a number

◆ isNumber() [2/2]

static bool charstring::isNumber ( const char * val,
int32_t len )
static

Returns true the string "val" is a number and false if it is not a number

◆ isYes()

static bool charstring::isYes ( const char * string)
static

Returns true if "string" starts with the standalone "word": "Yes" (case-insensitive), "True" (case-insensitive), "Y" (case-insensitive), "T" (case-insensitive), or "1" and false otherwise.

(Eg. returns true for "Yes,", "True ", and "1 2 3" but returns false for "Yesterday", "Truest", and "123")

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ leftJustify()

static void charstring::leftJustify ( char * str,
int32_t len )
static

Moves leading spaces to the end of "str" for "len" characters.

Example: " hello " -> "hello "

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ leftTrim() [1/2]

static void charstring::leftTrim ( char * str)
static

Trims all spaces off of the left hand side of "str".

◆ leftTrim() [2/2]

static void charstring::leftTrim ( char * str,
char character )
static

Trims all "character"'s off of the left hand side of "str".

◆ lower()

static void charstring::lower ( char * str)
static

Converts "str" to lowercase.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ obfuscate()

static void charstring::obfuscate ( char * str)
static

Obfuscates "str" by adding 128 to each character.

◆ pad()

static char * charstring::pad ( const char * string,
char padchar,
int16_t direction,
uint64_t totallen )
static

Returns a copy of "string", padded with "padchar" to a character length of "totallen". Set "direction" to -1 to left-pad, 0 to center-pad and 1 to right-pad. Note that this method allocates a buffer internally and returns it. The calling program must deallocate this buffer.

◆ parseNumber() [1/21]

static char * charstring::parseNumber ( double number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [2/21]

static char * charstring::parseNumber ( double number,
uint16_t precision,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [3/21]

static char * charstring::parseNumber ( double number,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [4/21]

static char * charstring::parseNumber ( float number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [5/21]

static char * charstring::parseNumber ( float number,
uint16_t precision,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [6/21]

static char * charstring::parseNumber ( float number,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [7/21]

static char * charstring::parseNumber ( int16_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [8/21]

static char * charstring::parseNumber ( int16_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [9/21]

static char * charstring::parseNumber ( int32_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [10/21]

static char * charstring::parseNumber ( int32_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [11/21]

static char * charstring::parseNumber ( int64_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [12/21]

static char * charstring::parseNumber ( int64_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [13/21]

static char * charstring::parseNumber ( long double number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [14/21]

static char * charstring::parseNumber ( long double number,
uint16_t precision,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [15/21]

static char * charstring::parseNumber ( long double number,
uint16_t scale )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [16/21]

static char * charstring::parseNumber ( uint16_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [17/21]

static char * charstring::parseNumber ( uint16_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [18/21]

static char * charstring::parseNumber ( uint32_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [19/21]

static char * charstring::parseNumber ( uint32_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [20/21]

static char * charstring::parseNumber ( uint64_t number)
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ parseNumber() [21/21]

static char * charstring::parseNumber ( uint64_t number,
uint16_t zeropadding )
static

Returns a string representing "number". The string is allocated inside the function and must be deleted by the calling program.

◆ printf() [1/4]

static ssize_t charstring::printf ( char ** buffer,
const char * format,
va_list * argp )
static

Allocates "buffer" to sufficient size and writes "argp" to it using "format" which should comply with standard printf formatting rules.

Returns the number of characters written to "buffer" excluding the NULL terminator.

If "buffer" is NULL then nothing is written to "buffer" and 0 is returned.

Returns -1 if an error occurred.

NOTE: wide character sequences will be converted to sequences of characters of the currently selected character set (eg. selected by the locale) which may be ASCII, extended ASCII (eg. Latin 15), or multibyte (eg. UTF8).

◆ printf() [2/4]

static ssize_t charstring::printf ( char ** buffer,
const char * format,
... )
static

Allocates "buffer" to sufficient size and writes "..." to it using "format" which should comply with standard printf formatting rules.

Returns the number of characters written to "buffer" excluding the NULL terminator.

If "buffer" is NULL then nothing is written to "buffer" and 0 is returned.

Returns -1 if an error occurred.

NOTE: wide character sequences will be converted to sequences of characters of the currently selected character set (eg. selected by the locale) which may be ASCII, extended ASCII (eg. Latin 15), or multibyte (eg. UTF8).

◆ printf() [3/4]

static ssize_t charstring::printf ( char * buffer,
size_t len,
const char * format,
va_list * argp )
static

Appends "argp" to "buffer" of character length "len" using "format" which should comply with standard printf formatting rules.

Note that argp is a pointer to a va_list, not just a va_list.

Returns the number of characters written to "buffer" excluding the NULL terminator. If "buffer" wasn't large enough to accommodate the data then it only writes "len" characters to "buffer" but still returns the number of characters that would have been written had "buffer" been large enough.

If "buffer" is NULL or "len" is 0 then nothing is written to "buffer" but the number of characters that would have been written had "buffer" been large enough is still returned.

Returns -1 if an error occurred.

NOTE: wide character sequences will be converted to sequences of characters of the currently selected character set (eg. selected by the locale) which may be ASCII, extended ASCII (eg. Latin 15), or multibyte (eg. UTF8).

◆ printf() [4/4]

static ssize_t charstring::printf ( char * buffer,
size_t len,
const char * format,
... )
static

Appends "..." to "buffer" of character length "len" using "format" which should comply with standard printf formatting rules.

Returns the number of characters written to "buffer" excluding the NULL terminator. If string wasn't large enough to accommodate the data then it only writes "len" characters to "buffer" but still returns the number of characters that would have been written had "buffer" been large enough.

If "buffer" is NULL or "len" is 0 then nothing is written to "buffer" but the number of characters that would have been written had "buffer" been large enough is still returned.

Returns -1 if an error occurred.

NOTE: wide character sequences will be converted to sequences of characters of the currently selected character set (eg. selected by the locale) which may be ASCII, extended ASCII (eg. Latin 15), or multibyte (eg. UTF8).

◆ quotedPrintableDecode() [1/3]

static byte_t * charstring::quotedPrintableDecode ( const char * input)
static

Quoted-printable-decodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ quotedPrintableDecode() [2/3]

static byte_t * charstring::quotedPrintableDecode ( const char * input,
uint64_t inputlen )
static

similar to quotedPrintableDecode above but only decodes the first "inputlen" characters of "input"

◆ quotedPrintableDecode() [3/3]

static void charstring::quotedPrintableDecode ( const char * input,
uint64_t inputlen,
byte_t ** output,
uint64_t * outputlen )
static

similar to quotedPrintableDecode() above, but returns the result in "output" and "outputlen" (in characters) rather than in a return value

◆ quotedPrintableEncode() [1/3]

static char * charstring::quotedPrintableEncode ( const byte_t * input)
static

Quoted-printable-encodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ quotedPrintableEncode() [2/3]

static char * charstring::quotedPrintableEncode ( const byte_t * input,
uint64_t inputsize )
static

similar to quotedPrintableEncode above but only encodes the first "inputsize" bytes of "input"

◆ quotedPrintableEncode() [3/3]

static void charstring::quotedPrintableEncode ( const byte_t * input,
uint64_t inputsize,
char ** output,
uint64_t * outputlen )
static

similar to quotedPrintableEncode() above, but returns the result in "output" and "outputlen" (in characters) rather than in a return value

◆ replace() [1/6]

static void charstring::replace ( char * str,
char oldchar,
char newchar )
static

Replaces all instances of "oldchar" in "str" with "newchar"

◆ replace() [2/6]

static void charstring::replace ( char * str,
const char * oldchars,
char newchar )
static

Replaces all instances of any of the characters in the set "oldchar" in "str" with "newchar"

◆ replace() [3/6]

static char * charstring::replace ( const char * str,
const char *const * oldstrset,
const char *const * newstrset )
static

Returns a new string which is a copy of "str" in which all instances of strings found in the NULL-terminated array "oldstrset", have been replaced with the commensurate string found in the NULL-terminated array "newstrset", which must have the same number of members as "oldstrset"

◆ replace() [4/6]

static char * charstring::replace ( const char * str,
const char *const * oldstrset,
size_t * oldstrlen,
const char *const * newstrset )
static

Returns a new string which is a copy of "str" in which all instances of strings found in the NULL-terminated array "oldstrset", the number of characters of which are given by the array "oldstrlen", have been replaced with the commensurate string found in the NULL-terminated array "newstrset", which must have the same number of members as "oldstrset"

◆ replace() [5/6]

static char * charstring::replace ( const char * str,
const char * oldstr,
const char * newstr )
static

Returns a new string which is a copy of "str" in which all instances of "oldstr" have been replaced with "newstr"

◆ replace() [6/6]

static char * charstring::replace ( const char * str,
regularexpression * from,
const char * to,
bool global )
static

Returns a new string which is a copy of "str" in which parts that match "from" have been replaced with "to".

If "global" is true then all matching parts are replaced. If "global" is false then only the first matching part is replaced.

◆ replaceIgnoringCase() [1/5]

static void charstring::replaceIgnoringCase ( char * str,
char oldchar,
char newchar )
static

Replaces all instances of "oldchar" in "str" with "newchar", ignoring case

◆ replaceIgnoringCase() [2/5]

static void charstring::replaceIgnoringCase ( char * str,
const char * oldchars,
char newchar )
static

Replaces all instances of any of the characters in the set "oldchar" in "str" with "newchar", ignoring case

◆ replaceIgnoringCase() [3/5]

static char * charstring::replaceIgnoringCase ( const char * str,
const char *const * oldstrset,
const char *const * newstrset )
static

Returns a new string which is a copy of "str" in which all instances of strings found in the NULL-terminated array "oldstrset", have been replaced with the commensurate string found in the NULL-terminated array "newstrset", which must have the same number of members as "oldstrset", ignoring case

◆ replaceIgnoringCase() [4/5]

static char * charstring::replaceIgnoringCase ( const char * str,
const char *const * oldstrset,
size_t * oldstrlen,
const char *const * newstrset )
static

Returns a new string which is a copy of "str" in which all instances of strings found in the NULL-terminated array "oldstrset", the number of characters of which are given by the array "oldstrlen", have been replaced with the commensurate string found in the NULL-terminated array "newstrset", which must have the same number of members as "oldstrset", ignoring set

◆ replaceIgnoringCase() [5/5]

static char * charstring::replaceIgnoringCase ( const char * str,
const char * oldstr,
const char * newstr )
static

Returns a new string which is a copy of "str" in which all instances of "oldstr" have been replaced with "newstr", ignoring case

◆ rightJustify()

static void charstring::rightJustify ( char * str,
int32_t len )
static

Moves trailing spaces to the beginning of "str" for "len" characters.

Example: " hello " -> " hello"

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ rightTrim() [1/2]

static void charstring::rightTrim ( char * str)
static

Trims all spaces off of the right hand side of "str".

◆ rightTrim() [2/2]

static void charstring::rightTrim ( char * str,
char character )
static

Trims all "character"'s off of the right hand side of "str".

◆ safeCopy() [1/2]

static char * charstring::safeCopy ( char * dest,
size_t destlen,
const char * source )
static

Replaces "dest" with "source" unless the character length of "source" is greater than "destlen", in which case only "destlen" characters of "dest" will be replaced. Returns a pointer to "dest".

◆ safeCopy() [2/2]

static char * charstring::safeCopy ( char * dest,
size_t destlen,
const char * source,
size_t sourcelen )
static

Replaces "sourcelen" characters of "dest" with "source" unless "sourcelen" is greater than "destlen", in which case only "destlen" characters of "dest" will be replaced. Returns a pointer to "dest".

◆ split() [1/4]

static void charstring::split ( const char * string,
const char * delimiter,
bool collapse,
char *** list,
uint64_t * listcount )
static

Parses NULL-terminated "string" delimited by NULL-terminated "delimiter" and allocates "listcount" elements of "list" to return the parts. If "collapse" is true then multiple instances of the delimiter in a row will be interpreted as one instance of the delimiter. Each member of "list" and "list" itseslf must be deallocated by the calling program.

◆ split() [2/4]

static void charstring::split ( const char * string,
const char * delimiter,
size_t delimiterlen,
bool collapse,
char *** list,
uint64_t * listcount )
static

Parses NULL-terminated "string" delimited by "delimiter" of character length "delimiterlen" and allocates "listcount" elements of "list" to return the parts. If "collapse" is true then multiple instances of the delimiter in a row will be interpreted as one instance of the delimiter. Each member of "list" and "list" itseslf must be deallocated by the calling program.

◆ split() [3/4]

static void charstring::split ( const char * string,
size_t stringlen,
const char * delimiter,
bool collapse,
char *** list,
uint64_t * listcount )
static

Parses "string" of character length "stringlen" delimited by NULL-terminated "delimiter" and allocates "listcount" elements of "list" to return the parts. If "collapse" is true then multiple instances of the delimiter in a row will be interpreted as one instance of the delimiter. Each member of "list" and "list" itseslf must be deallocated by the calling program.

◆ split() [4/4]

static void charstring::split ( const char * string,
size_t stringlen,
const char * delimiter,
size_t delimiterlen,
bool collapse,
char *** list,
uint64_t * listcount )
static

Parses "string" of character length "stringlen" delimited by "delimiter" of character length "delimiterlen" and allocates "listcount" elements of "list" to return the parts. If "collapse" is true then multiple instances of the delimiter in a row will be interpreted as one instance of the delimiter. Each member of "list" and "list" itseslf must be deallocated by the calling program.

◆ startsWith()

static bool charstring::startsWith ( const char * haystack,
const char * needle )
static

Returns true if "haystack" starts with "needle" or false otherwise.

◆ strip() [1/2]

static bool charstring::strip ( char * str,
char character )
static

Strips all instances of "character" from "str". Returns true if any characters were stripped and false if no characters were stripped.

◆ strip() [2/2]

static bool charstring::strip ( char * str1,
const char * str2 )
static

Strips all instances of "str2" from "str1". Returns true if any characters were stripped and false if no characters were stripped.

◆ stripSet()

static bool charstring::stripSet ( char * str1,
const char * set )
static

Strips all instances of any character in "set" from "str1". Returns true if any characters were stripped and false if no characters were stripped.

◆ unescape() [1/2]

static char * charstring::unescape ( const char * input)
static

unescapes all -escaped characters found in "input" and returns the result in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ unescape() [2/2]

static void charstring::unescape ( const char * input,
uint64_t inputlen,
char ** output,
uint64_t * outputlen )
static

similar to unescape() above, but takes an "inputlen" parameter and returns the result in "output" and "outputlen" rather than in a return value

◆ upper()

static void charstring::upper ( char * str)
static

Converts "str" to uppercase.

Note that this method expects to operate on strings encoded using ASCII or extended ASCII, and may give unexpected results for differently-encoded strings.

◆ urlDecode()

static char * charstring::urlDecode ( const char * input)
static

URL-decodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ urlEncode()

static char * charstring::urlEncode ( const char * input)
static

URL-encodes "input" and returns it in a buffer allocated inside the function. This buffer must be deleted by the calling program.

◆ zero()

static void charstring::zero ( char * str,
size_t len )
static

Sets "len" characters of "str" to NULL.

Note that this method expects to operate on strings encoded using a single-byte encoding, and will give unexpected results for multi-byte-encoded strings.