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
38 static bool isYes(const char *string);
39
46 static bool isNo(const char *string);
47
49 static void zero(char *str, size_t size);
50
54 static char *append(char *dest, const char *source);
55
59 static char *append(char *dest, const char *source,
60 size_t size);
61
65 static char *append(char *dest, int64_t number);
66
70 static char *append(char *dest, uint64_t number);
71
75 static char *append(char *dest, double number);
76
81 static char *append(char *dest, double number,
82 uint16_t scale);
83
88 static char *append(char *dest, double number,
89 uint16_t precision,
90 uint16_t scale);
91
95 static char *copy(char *dest, const char *source);
96
100 static char *copy(char *dest,
101 const char *source, size_t size);
102
107 static char *copy(char *dest, size_t location,
108 const char *source);
109
114 static char *copy(char *dest, size_t location,
115 const char *source, size_t size);
116
121 static char *safeCopy(char *dest, size_t destsize,
122 const char *source);
123
128 static char *safeCopy(char *dest, size_t destsize,
129 const char *source, size_t sourcesize);
130
133 static int32_t compare(const char *str1, const char *str2);
134
137 static int32_t compare(const char *str1, const char *str2,
138 size_t size);
139
142 static int32_t compareIgnoringCase(const char *str1,
143 const char *str2);
144
148 static int32_t compareIgnoringCase(const char *str1,
149 const char *str2,
150 size_t size);
151
156 static bool inSet(const char *str, const char * const *set);
157
162 static bool inSetIgnoringCase(const char *str,
163 const char * const *set);
164
167 static bool contains(const char *haystack,
168 const char *needle);
169
172 static bool contains(const char *haystack, char needle);
173
176 static const char *findFirst(const char *haystack,
177 const char *needle);
178
181 static const char *findFirst(const char *haystack,
182 char needle);
183
187 static const char *findFirstOrEnd(const char *haystack,
188 char needle);
189
193 static const char *findFirstOrEnd(const char *haystack,
194 const char *needle);
195
198 static const char *findLast(const char *haystack,
199 const char *needle);
200
203 static const char *findLast(const char *haystack,
204 char needle);
205
208 static char *findFirst(char *haystack, const char *needle);
209
212 static char *findFirst(char *haystack, char needle);
213
217 static char *findFirstOrEnd(char *haystack,
218 const char *needle);
219
222 static char *findLast(char *haystack, const char *needle);
223
226 static char *findLast(char *haystack, char needle);
227
231 static const char *findFirstOfSet(const char *haystack,
232 const char *set);
233
237 static char *findFirstOfSet(char *haystack,
238 const char *set);
239
244 static const char *findFirstOfSetOrEnd(
245 const char *haystack,
246 const char *set);
247
252 static char *findFirstOfSetOrEnd(
253 char *haystack,
254 const char *set);
255
259 static const char *findLastOfSet(const char *haystack,
260 const char *set);
261
265 static char *findLastOfSet(char *haystack,
266 const char *set);
267
272 static const char *findLastOfSetOrEnd(
273 const char *haystack,
274 const char *set);
275
280 static char *findLastOfSetOrEnd(
281 char *haystack,
282 const char *set);
283
287 static size_t lengthContainingSet(const char *haystack,
288 const char *set);
289
293 static size_t lengthNotContainingSet(const char *haystack,
294 const char *set);
295
300 static char *duplicate(const char *str);
301
307 static char *duplicate(const char *str, size_t length);
308
310 static void upper(char *str);
311
313 static void lower(char *str);
314
317 static void capitalize(char *str);
318
320 static void rightTrim(char *str);
321
324 static void rightTrim(char *str, char character);
325
327 static void leftTrim(char *str);
328
331 static void leftTrim(char *str, char character);
332
334 static void bothTrim(char *str);
335
337 static void bothTrim(char *str, char character);
338
342 static bool strip(char *str, char character);
343
347 static bool strip(char *str1, const char *str2);
348
352 static bool stripSet(char *str1, const char *set);
353
356 static void replace(char *str,
357 char oldchar, char newchar);
358
361 static void replace(char *str,
362 const char *oldchars, char newchar);
363
366 static uint16_t integerLength(int16_t number);
367
370 static uint16_t integerLength(int32_t number);
371
374 static uint16_t integerLength(int64_t number);
375
378 static uint16_t integerLength(uint16_t number);
379
382 static uint16_t integerLength(uint32_t number);
383
386 static uint16_t integerLength(uint64_t number);
387
390 static bool isInteger(const char *val);
391
394 static bool isInteger(const char *val, int32_t size);
395
398 static bool isNumber(const char *val);
399
402 static bool isNumber(const char *val, int32_t size);
403
407 static char *parseNumber(int16_t number);
408
412 static char *parseNumber(uint16_t number);
413
417 static char *parseNumber(int16_t number,
418 uint16_t zeropadding);
419
423 static char *parseNumber(uint16_t number,
424 uint16_t zeropadding);
425
429 static char *parseNumber(int32_t number);
430
434 static char *parseNumber(uint32_t number);
435
439 static char *parseNumber(int32_t number,
440 uint16_t zeropadding);
441
445 static char *parseNumber(uint32_t number,
446 uint16_t zeropadding);
447
451 static char *parseNumber(int64_t number);
452
456 static char *parseNumber(uint64_t number);
457
461 static char *parseNumber(int64_t number,
462 uint16_t zeropadding);
463
467 static char *parseNumber(uint64_t number,
468 uint16_t zeropadding);
469
470
474 static char *parseNumber(float number);
475
479 static char *parseNumber(float number,
480 uint16_t scale);
481
485 static char *parseNumber(float number,
486 uint16_t precision,
487 uint16_t scale);
488
492 static char *parseNumber(double number);
493
497 static char *parseNumber(double number,
498 uint16_t scale);
499
503 static char *parseNumber(double number,
504 uint16_t precision,
505 uint16_t scale);
506
510 static char *parseNumber(long double number);
511
515 static char *parseNumber(long double number,
516 uint16_t scale);
517
521 static char *parseNumber(long double number,
522 uint16_t precision,
523 uint16_t scale);
524
526 static int64_t toInteger(const char *string);
527
531 static int64_t toInteger(const char *string,
532 const char **endptr);
533
535 static int64_t toInteger(const char *string, int32_t base);
536
540 static int64_t toInteger(const char *string,
541 const char **endptr, int32_t base);
542
544 static uint64_t toUnsignedInteger(const char *string);
545
549 static uint64_t toUnsignedInteger(const char *string,
550 const char **endptr);
551
554 static uint64_t toUnsignedInteger(const char *string,
555 int32_t base);
556
561 static uint64_t toUnsignedInteger(const char *string,
562 const char **endptr,
563 int32_t base);
564
565
567 static long double toFloat(const char *string);
568
572 static long double toFloat(const char *string,
573 const char **endptr);
574
577 static int64_t convertAmount(const char *amount);
578
581 static char *convertAmount(int64_t amount);
582
588 static char *convertAmount(int64_t amount,
589 uint16_t padding);
590
591
595 static char *httpEscape(const char *input);
596
600 static char *httpUnescape(const char *input);
601
606 static char *escape(const char *input,
607 const char *characters);
608
613 static char *unescape(const char *input);
614
618 static void escape(const char *input, uint64_t inputsize,
619 char **output, uint64_t *outputsize,
620 const char *characters);
621
625 static void unescape(const char *input, uint64_t inputsize,
626 char **output, uint64_t *outputsize);
627
631 static char *base64Encode(const unsigned char *input);
632
635 static char *base64Encode(const unsigned char *input,
636 uint64_t inputsize);
637
641 static void base64Encode(const unsigned char *input,
642 uint64_t inputsize,
643 char **output,
644 uint64_t *outputsize);
645
649 static unsigned char *base64Decode(const char *input);
650
653 static unsigned char *base64Decode(const char *input,
654 uint64_t inputsize);
655
659 static void base64Decode(const char *input,
660 uint64_t inputsize,
661 unsigned char **output,
662 uint64_t *outputsize);
663
665 static void obfuscate(char *str);
666
669 static void deobfuscate(char *str);
670
675 static void leftJustify(char *str, int32_t length);
676
681 static void rightJustify(char *str, int32_t length);
682
686 static void center(char *str, int32_t length);
687
693 static char *pad(const char *string,
694 char padchar,
695 int16_t direction,
696 uint64_t totallength);
697
705 static void split(const char *string,
706 ssize_t stringlength,
707 const char *delimiter,
708 ssize_t delimiterlength,
709 bool collapse,
710 char ***list,
711 uint64_t *listlength);
712
720 static void split(const char *string,
721 const char *delimiter,
722 ssize_t delimiterlength,
723 bool collapse,
724 char ***list,
725 uint64_t *listlength);
733 static void split(const char *string,
734 ssize_t stringlength,
735 const char *delimiter,
736 bool collapse,
737 char ***list,
738 uint64_t *listlength);
739
747 static void split(const char *string,
748 const char *delimiter,
749 bool collapse,
750 char ***list,
751 uint64_t *listlength);
752
756 static char *subString(const char *str,
757 size_t start, size_t end);
758
762 static char *subString(const char *str, size_t start);
763
766 static char *insertString(const char *dest,
767 const char *src,
768 uint64_t index);
769
787 static ssize_t printf(char *buffer, size_t length,
788 const char *format, ...);
789
810 static ssize_t printf(char *buffer, size_t length,
811 const char *format,
812 va_list *argp);
813
814 #include <rudiments/private/charstring.h>
815 };
816
817 #endif
charstring
Definition: charstring.h:16
character
Definition: character.h:11