Rudiments

- Main Page
- Classes

- Class List
- Class Hierarchy
- Class Members

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

## Static Public Member Functions
static size_t | length (const char *string)
static size_t | length (const unsigned char *string)
static bool | isNullOrEmpty (const char *string)
static bool | isNullOrEmpty (const unsigned char *string)
static void | zero (char *str, size_t size)
static char * | append (char *dest, const char *source)
static char * | append (char *dest, const char *source, size_t size)
static char * | append (char *dest, int64_t number)
static char * | append (char *dest, uint64_t number)
static char * | append (char *dest, double number)
static char * | append (char *dest, double number, uint16_t scale)
static char * | append (char *dest, double number, uint16_t precision, uint16_t scale)
static char * | copy (char *dest, const char *source)
static char * | copy (char *dest, const char *source, size_t size)
static char * | copy (char *dest, size_t location, const char *source)
static char * | copy (char *dest, size_t location, const char *source, size_t size)
static char * | safeCopy (char *dest, size_t destsize, const char *source)
static char * | safeCopy (char *dest, size_t destsize, const char *source, size_t sourcesize)
static int32_t | compare (const char *str1, const char *str2)
static int32_t | compare (const char *str1, const char *str2, size_t size)
static int32_t | compareIgnoringCase (const char *str1, const char *str2)
static int32_t | compareIgnoringCase (const char *str1, const char *str2, size_t size)
static bool | inSet (const char *str, const char *const *set)
static bool | inSetIgnoringCase (const char *str, const char *const *set)
static bool | contains (const char *haystack, const char *needle)
static bool | contains (const char *haystack, char needle)
static const char * | findFirst (const char *haystack, const char *needle)
static const char * | findFirst (const char *haystack, char needle)
static const char * | findFirstOrEnd (const char *haystack, char needle)
static const char * | findFirstOrEnd (const char *haystack, const char *needle)
static const char * | findLast (const char *haystack, const char *needle)
static const char * | findLast (const char *haystack, char needle)
static char * | findFirst (char *haystack, const char *needle)
static char * | findFirst (char *haystack, char needle)
static char * | findFirstOrEnd (char *haystack, const char *needle)
static char * | findLast (char *haystack, const char *needle)
static char * | findLast (char *haystack, char needle)
static const char * | findFirstOfSet (const char *haystack, const char *set)
static char * | findFirstOfSet (char *haystack, const char *set)
static const char * | findFirstOfSetOrEnd (const char *haystack, const char *set)
static char * | findFirstOfSetOrEnd (char *haystack, const char *set)
static size_t | lengthContainingSet (const char *haystack, const char *set)
static size_t | lengthNotContainingSet (const char *haystack, const char *set)
static char * | duplicate (const char *str)
static char * | duplicate (const char *str, size_t length)
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 uint16_t | integerLength (int16_t number)
static uint16_t | integerLength (int32_t number)
static uint16_t | integerLength (int64_t number)
static uint16_t | integerLength (uint16_t number)
static uint16_t | integerLength (uint32_t number)
static uint16_t | integerLength (uint64_t number)
static bool | isInteger (const char *val)
static bool | isInteger (const char *val, int32_t size)
static bool | isNumber (const char *val)
static bool | isNumber (const char *val, int32_t size)
static char * | parseNumber (int16_t number)
static char * | parseNumber (uint16_t number)
static char * | parseNumber (int16_t number, uint16_t zeropadding)
static char * | parseNumber (uint16_t number, uint16_t zeropadding)
static char * | parseNumber (int32_t number)
static char * | parseNumber (uint32_t number)
static char * | parseNumber (int32_t number, uint16_t zeropadding)
static char * | parseNumber (uint32_t number, uint16_t zeropadding)
static char * | parseNumber (int64_t number)
static char * | parseNumber (uint64_t number)
static char * | parseNumber (int64_t number, uint16_t zeropadding)
static char * | parseNumber (uint64_t number, uint16_t zeropadding)
static char * | parseNumber (float number)
static char * | parseNumber (float number, uint16_t scale)
static char * | parseNumber (float number, uint16_t precision, uint16_t scale)
static char * | parseNumber (double number)
static char * | parseNumber (double number, uint16_t scale)
static char * | parseNumber (double number, uint16_t precision, uint16_t scale)
static char * | parseNumber (long double number)
static char * | parseNumber (long double number, uint16_t scale)
static char * | parseNumber (long double number, uint16_t precision, uint16_t scale)
static int64_t | toInteger (const char *string)
static int64_t | toInteger (const char *string, const char **endptr)
static int64_t | toInteger (const char *string, int32_t base)
static int64_t | toInteger (const char *string, const char **endptr, int32_t base)
static uint64_t | toUnsignedInteger (const char *string)
static uint64_t | toUnsignedInteger (const char *string, const char **endptr)
static uint64_t | toUnsignedInteger (const char *string, int32_t base)
static uint64_t | toUnsignedInteger (const char *string, const char **endptr, int32_t base)
static long double | toFloat (const char *string)
static long double | toFloat (const char *string, const char **endptr)
static int64_t | convertAmount (const char *amount)
static char * | convertAmount (int64_t amount)
static char * | convertAmount (int64_t amount, uint16_t padding)
static char * | httpEscape (const char *input)
static char * | httpUnescape (const char *input)
static char * | escape (const char *input, const char *characters)
static char * | unescape (const char *input)
static void | escape (const char *input, uint64_t inputsize, char **output, uint64_t *outputsize, const char *characters)
static void | unescape (const char *input, uint64_t inputsize, char **output, uint64_t *outputsize)
static char * | base64Encode (const unsigned char *input)
static char * | base64Encode (const unsigned char *input, uint64_t inputsize)
static void | base64Encode (const unsigned char *input, uint64_t inputsize, char **output, uint64_t *outputsize)
static unsigned char * | base64Decode (const char *input)
static unsigned char * | base64Decode (const char *input, uint64_t inputsize)
static void | base64Decode (const char *input, uint64_t inputsize, unsigned char **output, uint64_t *outputsize)
static void | obfuscate (char *str)
static void | deobfuscate (char *str)
static void | leftJustify (char *str, int32_t length)
static void | rightJustify (char *str, int32_t length)
static void | center (char *str, int32_t length)
static char * | pad (const char *string, char padchar, int16_t direction, uint64_t totallength)
static void | split (const char *string, ssize_t stringlength, const char *delimiter, ssize_t delimiterlength, bool collapse, char ***list, uint64_t *listlength)
static void | split (const char *string, const char *delimiter, ssize_t delimiterlength, bool collapse, char ***list, uint64_t *listlength)
static void | split (const char *string, ssize_t stringlength, const char *delimiter, bool collapse, char ***list, uint64_t *listlength)
static void | split (const char *string, const char *delimiter, bool collapse, char ***list, uint64_t *listlength)
static char * | subString (const char *str, size_t start, size_t end)
static char * | subString (const char *str, size_t start)
static char * | insertString (const char *dest, const char *src, uint64_t index)
static ssize_t | printf (char *buffer, size_t length, const char *format,...)
static ssize_t | printf (char *buffer, size_t length, 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.

## Member Function Documentation

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".

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

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

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".

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".

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".

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".

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".

static unsigned char* 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.

static unsigned char* charstring::base64Decode | ( | const char * | input,
|  | uint64_t | inputsize
| ) |  |
| static

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

static void charstring::base64Decode | ( | const char * | input,
|  | uint64_t | inputsize,
|  | unsigned char ** | output,
|  | uint64_t * | outputsize
| ) |  |
| static

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

static char* charstring::base64Encode | ( | const unsigned char * | input | ) |
| static

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

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

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

static void charstring::base64Encode | ( | const unsigned char * | input,
|  | uint64_t | inputsize,
|  | char ** | output,
|  | uint64_t * | outputsize
| ) |  |
| static

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

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

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

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

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

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

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

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

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

Example: "hello " -> " hello "

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".

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

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

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.

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

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

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

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

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

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

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

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

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

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

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.

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".

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

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

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

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

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

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

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

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

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.

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

Creates a duplicate of the first "length" bytes 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.

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.

static void charstring::escape | ( | const char * | input,
|  | uint64_t | inputsize,
|  | char ** | output,
|  | uint64_t * | outputsize,
|  | const char * | characters
| ) |  |
| static

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

static char* charstring::httpEscape | ( | const char * | input | ) |
| static

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

static char* charstring::httpUnescape | ( | const char * | input | ) |
| static

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

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".

static bool charstring::inSet | ( | 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.

static bool charstring::inSetIgnoringCase | ( | 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.

static uint16_t charstring::integerLength | ( | int16_t | number | ) |
| static

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

static uint16_t charstring::integerLength | ( | int32_t | number | ) |
| static

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

static uint16_t charstring::integerLength | ( | int64_t | number | ) |
| static

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

static uint16_t charstring::integerLength | ( | uint16_t | number | ) |
| static

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

static uint16_t charstring::integerLength | ( | uint32_t | number | ) |
| static

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

static uint16_t charstring::integerLength | ( | uint64_t | number | ) |
| static

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

Example: " hello " -> "hello "

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

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

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

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

static size_t charstring::length | ( | const char * | string | ) |
| static

Returns the length of "string".

static size_t charstring::length | ( | const unsigned char * | string | ) |
| static

Returns the length of "string".

static size_t charstring::lengthContainingSet | ( | 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".

static size_t charstring::lengthNotContainingSet | ( | 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".

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

Converts "str" to lowercase.

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

Obfuscates "str" by adding 128 to each character.

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

Returns a copy of "string", padded with "padchar" to a length of "totallength". 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

Appends "..." to "buffer" of length "length" 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 "length" bytes to "buffer" but still returns the number of characters that would have been written had "buffer" been large enough.

If "buffer" is NULL or "length" 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.

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

Appends "..." to "buffer" of length "length" 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 "length" bytes to "buffer" but still returns the number of characters that would have been written had "buffer" been large enough.

If "buffer" is NULL or "length" 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.

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

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

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"

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

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

Example: " hello " -> " hello"

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

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

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

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

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

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

static char* charstring::safeCopy | ( | char * | dest,
|  | size_t | destsize,
|  | const char * | source,
|  | size_t | sourcesize
| ) |  |
| static

Replaces "sourcesize" bytes of "dest" with "source" unless "sourcesize" is greater than "destsize", in which case only "destsize" bytes of "dest" will be replaced. Returns a pointer to "dest".

static void charstring::split | ( | const char * | string,
|  | ssize_t | stringlength,
|  | const char * | delimiter,
|  | ssize_t | delimiterlength,
|  | bool | collapse,
|  | char *** | list,
|  | uint64_t * | listlength
| ) |  |
| static

Parses "string" of length "stringlength" delimited by "delimiter" of length "delimiterlength" and allocates "listlength" 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.

static void charstring::split | ( | const char * | string,
|  | const char * | delimiter,
|  | ssize_t | delimiterlength,
|  | bool | collapse,
|  | char *** | list,
|  | uint64_t * | listlength
| ) |  |
| static

Parses NULL-terminated "string" delimited by "delimiter" of length "delimiterlength" and allocates "listlength" 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.

static void charstring::split | ( | const char * | string,
|  | ssize_t | stringlength,
|  | const char * | delimiter,
|  | bool | collapse,
|  | char *** | list,
|  | uint64_t * | listlength
| ) |  |
| static

Parses "string" of "stringlength" delimited by NULL-terminated "delimiter" and allocates "listlength" 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.

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

Parses NULL-terminated "string" delimited by NULL-terminated "delimiter" and allocates "listlength" 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.

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.

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.

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.

static char* charstring::subString | ( | 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.

static char* charstring::subString | ( | 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.

static long double charstring::toFloat | ( | const char * | string | ) |
| static

Converts "string" to a floating point number.

static long double charstring::toFloat | ( | 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.

static int64_t charstring::toInteger | ( | const char * | string | ) |
| static

Converts "string" to a 64-bit integer.

static int64_t charstring::toInteger | ( | 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.

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

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

static int64_t charstring::toInteger | ( | 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.

static uint64_t charstring::toUnsignedInteger | ( | const char * | string | ) |
| static

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

static uint64_t charstring::toUnsignedInteger | ( | 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.

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

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

static uint64_t charstring::toUnsignedInteger | ( | 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.

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.

static void charstring::unescape | ( | const char * | input,
|  | uint64_t | inputsize,
|  | char ** | output,
|  | uint64_t * | outputsize
| ) |  |
| static

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

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

Converts "str" to uppercase.

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

Sets "size" bytes of "str" to NULL.