Rudiments: /home/dmuse/src/rudiments/include/rudiments/charstring.h Source File

Rudiments

- Main Page
- Classes

charstring.h
1 // Copyright (c) 2003 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_CHARSTRING_H
5 #define RUDIMENTS_CHARSTRING_H
6
7 #include <rudiments/private/charstringincludes.h>
8
16 class RUDIMENTS_DLLSPEC charstring {
17 public:
18
20 static size_t length(const char *string);
21
23 static size_t length(const unsigned char *string);
24
26 static bool isNullOrEmpty(const char *string);
27
29 static bool isNullOrEmpty(const unsigned char *string);
30
32 static void zero(char *str, size_t size);
33
37 static char *append(char *dest, const char *source);
38
42 static char *append(char *dest, const char *source,
43 size_t size);
44
48 static char *append(char *dest, int64_t number);
49
53 static char *append(char *dest, uint64_t number);
54
58 static char *append(char *dest, double number);
59
64 static char *append(char *dest, double number,
65 uint16_t scale);
66
71 static char *append(char *dest, double number,
72 uint16_t precision,
73 uint16_t scale);
74
78 static char *copy(char *dest, const char *source);
79
83 static char *copy(char *dest,
84 const char *source, size_t size);
85
90 static char *copy(char *dest, size_t location,
91 const char *source);
92
97 static char *copy(char *dest, size_t location,
98 const char *source, size_t size);
99
104 static char *safeCopy(char *dest, size_t destsize,
105 const char *source);
106
111 static char *safeCopy(char *dest, size_t destsize,
112 const char *source, size_t sourcesize);
113
116 static int32_t compare(const char *str1, const char *str2);
117
120 static int32_t compare(const char *str1, const char *str2,
121 size_t size);
122
125 static int32_t compareIgnoringCase(const char *str1,
126 const char *str2);
127
131 static int32_t compareIgnoringCase(const char *str1,
132 const char *str2,
133 size_t size);
134
139 static bool inSet(const char *str, const char * const *set);
140
145 static bool inSetIgnoringCase(const char *str,
146 const char * const *set);
147
150 static bool contains(const char *haystack,
151 const char *needle);
152
155 static bool contains(const char *haystack, char needle);
156
159 static const char *findFirst(const char *haystack,
160 const char *needle);
161
164 static const char *findFirst(const char *haystack,
165 char needle);
166
170 static const char *findFirstOrEnd(const char *haystack,
171 char needle);
172
176 static const char *findFirstOrEnd(const char *haystack,
177 const char *needle);
178
181 static const char *findLast(const char *haystack,
182 const char *needle);
183
186 static const char *findLast(const char *haystack,
187 char needle);
188
191 static char *findFirst(char *haystack, const char *needle);
192
195 static char *findFirst(char *haystack, char needle);
196
200 static char *findFirstOrEnd(char *haystack,
201 const char *needle);
202
205 static char *findLast(char *haystack, const char *needle);
206
209 static char *findLast(char *haystack, char needle);
210
214 static const char *findFirstOfSet(const char *haystack,
215 const char *set);
216
220 static char *findFirstOfSet(char *haystack,
221 const char *set);
222
227 static const char *findFirstOfSetOrEnd(
228 const char *haystack,
229 const char *set);
230
235 static char *findFirstOfSetOrEnd(
236 char *haystack,
237 const char *set);
238
242 static size_t lengthContainingSet(const char *haystack,
243 const char *set);
244
248 static size_t lengthNotContainingSet(const char *haystack,
249 const char *set);
250
255 static char *duplicate(const char *str);
256
262 static char *duplicate(const char *str, size_t length);
263
265 static void upper(char *str);
266
268 static void lower(char *str);
269
272 static void capitalize(char *str);
273
275 static void rightTrim(char *str);
276
279 static void rightTrim(char *str, char character);
280
282 static void leftTrim(char *str);
283
286 static void leftTrim(char *str, char character);
287
289 static void bothTrim(char *str);
290
292 static void bothTrim(char *str, char character);
293
297 static bool strip(char *str, char character);
298
302 static bool strip(char *str1, const char *str2);
303
307 static bool stripSet(char *str1, const char *set);
308
311 static void replace(char *str,
312 char oldchar, char newchar);
313
316 static void replace(char *str,
317 const char *oldchars, char newchar);
318
321 static uint16_t integerLength(int16_t number);
322
325 static uint16_t integerLength(int32_t number);
326
329 static uint16_t integerLength(int64_t number);
330
333 static uint16_t integerLength(uint16_t number);
334
337 static uint16_t integerLength(uint32_t number);
338
341 static uint16_t integerLength(uint64_t number);
342
345 static bool isInteger(const char *val);
346
349 static bool isInteger(const char *val, int32_t size);
350
353 static bool isNumber(const char *val);
354
357 static bool isNumber(const char *val, int32_t size);
358
362 static char *parseNumber(int16_t number);
363
367 static char *parseNumber(uint16_t number);
368
372 static char *parseNumber(int16_t number,
373 uint16_t zeropadding);
374
378 static char *parseNumber(uint16_t number,
379 uint16_t zeropadding);
380
384 static char *parseNumber(int32_t number);
385
389 static char *parseNumber(uint32_t number);
390
394 static char *parseNumber(int32_t number,
395 uint16_t zeropadding);
396
400 static char *parseNumber(uint32_t number,
401 uint16_t zeropadding);
402
406 static char *parseNumber(int64_t number);
407
411 static char *parseNumber(uint64_t number);
412
416 static char *parseNumber(int64_t number,
417 uint16_t zeropadding);
418
422 static char *parseNumber(uint64_t number,
423 uint16_t zeropadding);
424
425
429 static char *parseNumber(float number);
430
434 static char *parseNumber(float number,
435 uint16_t scale);
436
440 static char *parseNumber(float number,
441 uint16_t precision,
442 uint16_t scale);
443
447 static char *parseNumber(double number);
448
452 static char *parseNumber(double number,
453 uint16_t scale);
454
458 static char *parseNumber(double number,
459 uint16_t precision,
460 uint16_t scale);
461
465 static char *parseNumber(long double number);
466
470 static char *parseNumber(long double number,
471 uint16_t scale);
472
476 static char *parseNumber(long double number,
477 uint16_t precision,
478 uint16_t scale);
479
481 static int64_t toInteger(const char *string);
482
486 static int64_t toInteger(const char *string,
487 const char **endptr);
488
490 static int64_t toInteger(const char *string, int32_t base);
491
495 static int64_t toInteger(const char *string,
496 const char **endptr, int32_t base);
497
499 static uint64_t toUnsignedInteger(const char *string);
500
504 static uint64_t toUnsignedInteger(const char *string,
505 const char **endptr);
506
509 static uint64_t toUnsignedInteger(const char *string,
510 int32_t base);
511
516 static uint64_t toUnsignedInteger(const char *string,
517 const char **endptr,
518 int32_t base);
519
520
522 static long double toFloat(const char *string);
523
527 static long double toFloat(const char *string,
528 const char **endptr);
529
532 static int64_t convertAmount(const char *amount);
533
536 static char *convertAmount(int64_t amount);
537
543 static char *convertAmount(int64_t amount,
544 uint16_t padding);
545
546
550 static char *httpEscape(const char *input);
551
555 static char *httpUnescape(const char *input);
556
561 static char *escape(const char *input,
562 const char *characters);
563
568 static char *unescape(const char *input);
569
573 static void escape(const char *input, uint64_t inputsize,
574 char **output, uint64_t *outputsize,
575 const char *characters);
576
580 static void unescape(const char *input, uint64_t inputsize,
581 char **output, uint64_t *outputsize);
582
586 static char *base64Encode(const unsigned char *input);
587
590 static char *base64Encode(const unsigned char *input,
591 uint64_t inputsize);
592
596 static void base64Encode(const unsigned char *input,
597 uint64_t inputsize,
598 char **output,
599 uint64_t *outputsize);
600
604 static unsigned char *base64Decode(const char *input);
605
608 static unsigned char *base64Decode(const char *input,
609 uint64_t inputsize);
610
614 static void base64Decode(const char *input,
615 uint64_t inputsize,
616 unsigned char **output,
617 uint64_t *outputsize);
618
620 static void obfuscate(char *str);
621
624 static void deobfuscate(char *str);
625
630 static void leftJustify(char *str, int32_t length);
631
636 static void rightJustify(char *str, int32_t length);
637
641 static void center(char *str, int32_t length);
642
648 static char *pad(const char *string,
649 char padchar,
650 int16_t direction,
651 uint64_t totallength);
652
660 static void split(const char *string,
661 ssize_t stringlength,
662 const char *delimiter,
663 ssize_t delimiterlength,
664 bool collapse,
665 char ***list,
666 uint64_t *listlength);
667
675 static void split(const char *string,
676 const char *delimiter,
677 ssize_t delimiterlength,
678 bool collapse,
679 char ***list,
680 uint64_t *listlength);
688 static void split(const char *string,
689 ssize_t stringlength,
690 const char *delimiter,
691 bool collapse,
692 char ***list,
693 uint64_t *listlength);
694
702 static void split(const char *string,
703 const char *delimiter,
704 bool collapse,
705 char ***list,
706 uint64_t *listlength);
707
711 static char *subString(const char *str,
712 size_t start, size_t end);
713
717 static char *subString(const char *str, size_t start);
718
721 static char *insertString(const char *dest,
722 const char *src,
723 uint64_t index);
724
742 static ssize_t printf(char *buffer, size_t length,
743 const char *format, ...);
744
765 static ssize_t printf(char *buffer, size_t length,
766 const char *format,
767 va_list *argp);
768
769 #include <rudiments/private/charstring.h>
770 };
771
772 #endif
charstring
Definition: charstring.h:16
character
Definition: character.h:11