charstring.h
// Copyright (c) 2003 David Muse
// See the COPYING file for more information.
#ifndef RUDIMENTS_CHARSTRING_H
#define RUDIMENTS_CHARSTRING_H
#include <rudiments/private/charstringincludes.h>
class RUDIMENTS_DLLSPEC charstring {
public:
static size_t length(const char *string);
static size_t length(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 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, char **endptr);
static int64_t toInteger(const char *string, int32_t base);
static int64_t toInteger(const char *string,
char **endptr, int32_t base);
static uint64_t toUnsignedInteger(const char *string);
static uint64_t toUnsignedInteger(const char *string,
char **endptr);
static uint64_t toUnsignedInteger(const char *string,
int32_t base);
static uint64_t toUnsignedInteger(const char *string,
char **endptr,
int32_t base);
static long double toFloat(const char *string);
static long double toFloat(const char *string,
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 leftJustify(char *str, int32_t length);
static void rightPad(char *str, int32_t lngth,
char padchar, bool fill);
static void rightJustify(char *str, int32_t length);
static void center(char *str, int32_t length);
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 void obfuscate(char *str);
static void deobfuscate(char *str);
static char *padString(const char *string,
char padchar,
int16_t direction,
uint64_t totallength);
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);
#include <rudiments/private/charstring.h>
};
#endif