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 void zero(char *str, size_t size);
27
31 static char *append(char *dest, const char *source);
32
36 static char *append(char *dest, const char *source,
37 size_t size);
38
42 static char *append(char *dest, int64_t number);
43
47 static char *append(char *dest, uint64_t number);
48
52 static char *append(char *dest, double number);
53
58 static char *append(char *dest, double number,
59 uint16_t scale);
60
65 static char *append(char *dest, double number,
66 uint16_t precision,
67 uint16_t scale);
68
72 static char *copy(char *dest, const char *source);
73
77 static char *copy(char *dest,
78 const char *source, size_t size);
79
84 static char *copy(char *dest, size_t location,
85 const char *source);
86
91 static char *copy(char *dest, size_t location,
92 const char *source, size_t size);
93
98 static char *safeCopy(char *dest, size_t destsize,
99 const char *source);
100
105 static char *safeCopy(char *dest, size_t destsize,
106 const char *source, size_t sourcesize);
107
110 static int32_t compare(const char *str1, const char *str2);
111
114 static int32_t compare(const char *str1, const char *str2,
115 size_t size);
116
119 static int32_t compareIgnoringCase(const char *str1,
120 const char *str2);
121
125 static int32_t compareIgnoringCase(const char *str1,
126 const char *str2,
127 size_t size);
128
133 static bool inSet(const char *str, const char * const *set);
134
139 static bool inSetIgnoringCase(const char *str,
140 const char * const *set);
141
144 static bool contains(const char *haystack,
145 const char *needle);
146
149 static bool contains(const char *haystack, char needle);
150
153 static const char *findFirst(const char *haystack,
154 const char *needle);
155
158 static const char *findFirst(const char *haystack,
159 char needle);
160
164 static const char *findFirstOrEnd(const char *haystack,
165 char needle);
166
170 static const char *findFirstOrEnd(const char *haystack,
171 const char *needle);
172
175 static const char *findLast(const char *haystack,
176 const char *needle);
177
180 static const char *findLast(const char *haystack,
181 char needle);
182
185 static char *findFirst(char *haystack, const char *needle);
186
189 static char *findFirst(char *haystack, char needle);
190
194 static char *findFirstOrEnd(char *haystack,
195 const char *needle);
196
199 static char *findLast(char *haystack, const char *needle);
200
203 static char *findLast(char *haystack, char needle);
204
208 static const char *findFirstOfSet(const char *haystack,
209 const char *set);
210
214 static char *findFirstOfSet(char *haystack,
215 const char *set);
216
221 static const char *findFirstOfSetOrEnd(
222 const char *haystack,
223 const char *set);
224
229 static char *findFirstOfSetOrEnd(
230 char *haystack,
231 const char *set);
232
236 static size_t lengthContainingSet(const char *haystack,
237 const char *set);
238
242 static size_t lengthNotContainingSet(const char *haystack,
243 const char *set);
244
249 static char *duplicate(const char *str);
250
256 static char *duplicate(const char *str, size_t length);
257
259 static void upper(char *str);
260
262 static void lower(char *str);
263
266 static void capitalize(char *str);
267
269 static void rightTrim(char *str);
270
273 static void rightTrim(char *str, char character);
274
276 static void leftTrim(char *str);
277
280 static void leftTrim(char *str, char character);
281
283 static void bothTrim(char *str);
284
286 static void bothTrim(char *str, char character);
287
291 static bool strip(char *str, char character);
292
296 static bool strip(char *str1, const char *str2);
297
301 static bool stripSet(char *str1, const char *set);
302
305 static void replace(char *str,
306 char oldchar, char newchar);
307
310 static void replace(char *str,
311 const char *oldchars, char newchar);
312
315 static uint16_t integerLength(int16_t number);
316
319 static uint16_t integerLength(int32_t number);
320
323 static uint16_t integerLength(int64_t number);
324
327 static uint16_t integerLength(uint16_t number);
328
331 static uint16_t integerLength(uint32_t number);
332
335 static uint16_t integerLength(uint64_t number);
336
339 static bool isInteger(const char *val);
340
343 static bool isInteger(const char *val, int32_t size);
344
347 static bool isNumber(const char *val);
348
351 static bool isNumber(const char *val, int32_t size);
352
356 static char *parseNumber(int16_t number);
357
361 static char *parseNumber(uint16_t number);
362
366 static char *parseNumber(int16_t number,
367 uint16_t zeropadding);
368
372 static char *parseNumber(uint16_t number,
373 uint16_t zeropadding);
374
378 static char *parseNumber(int32_t number);
379
383 static char *parseNumber(uint32_t number);
384
388 static char *parseNumber(int32_t number,
389 uint16_t zeropadding);
390
394 static char *parseNumber(uint32_t number,
395 uint16_t zeropadding);
396
400 static char *parseNumber(int64_t number);
401
405 static char *parseNumber(uint64_t number);
406
410 static char *parseNumber(int64_t number,
411 uint16_t zeropadding);
412
416 static char *parseNumber(uint64_t number,
417 uint16_t zeropadding);
418
419
423 static char *parseNumber(float number);
424
428 static char *parseNumber(float number,
429 uint16_t scale);
430
434 static char *parseNumber(float number,
435 uint16_t precision,
436 uint16_t scale);
437
441 static char *parseNumber(double number);
442
446 static char *parseNumber(double number,
447 uint16_t scale);
448
452 static char *parseNumber(double number,
453 uint16_t precision,
454 uint16_t scale);
455
459 static char *parseNumber(long double number);
460
464 static char *parseNumber(long double number,
465 uint16_t scale);
466
470 static char *parseNumber(long double number,
471 uint16_t precision,
472 uint16_t scale);
473
475 static int64_t toInteger(const char *string);
476
480 static int64_t toInteger(const char *string, char **endptr);
481
483 static int64_t toInteger(const char *string, int32_t base);
484
488 static int64_t toInteger(const char *string,
489 char **endptr, int32_t base);
490
492 static uint64_t toUnsignedInteger(const char *string);
493
497 static uint64_t toUnsignedInteger(const char *string,
498 char **endptr);
499
502 static uint64_t toUnsignedInteger(const char *string,
503 int32_t base);
504
509 static uint64_t toUnsignedInteger(const char *string,
510 char **endptr,
511 int32_t base);
512
513
515 static long double toFloat(const char *string);
516
520 static long double toFloat(const char *string,
521 char **endptr);
522
525 static int64_t convertAmount(const char *amount);
526
529 static char *convertAmount(int64_t amount);
530
536 static char *convertAmount(int64_t amount,
537 uint16_t padding);
538
539
543 static char *httpEscape(const char *input);
544
548 static char *httpUnescape(const char *input);
549
554 static char *escape(const char *input,
555 const char *characters);
556
561 static char *unescape(const char *input);
562
566 static void escape(const char *input, uint64_t inputsize,
567 char **output, uint64_t *outputsize,
568 const char *characters);
569
573 static void unescape(const char *input, uint64_t inputsize,
574 char **output, uint64_t *outputsize);
575
579 static char *base64Encode(const unsigned char *input);
580
583 static char *base64Encode(const unsigned char *input,
584 uint64_t inputsize);
585
589 static void base64Encode(const unsigned char *input,
590 uint64_t inputsize,
591 char **output,
592 uint64_t *outputsize);
593
597 static unsigned char *base64Decode(const char *input);
598
601 static unsigned char *base64Decode(const char *input,
602 uint64_t inputsize);
603
607 static void base64Decode(const char *input,
608 uint64_t inputsize,
609 unsigned char **output,
610 uint64_t *outputsize);
611
613 static void obfuscate(char *str);
614
617 static void deobfuscate(char *str);
618
623 static void leftJustify(char *str, int32_t length);
624
629 static void rightJustify(char *str, int32_t length);
630
634 static void center(char *str, int32_t length);
635
641 static char *pad(const char *string,
642 char padchar,
643 int16_t direction,
644 uint64_t totallength);
645
653 static void split(const char *string,
654 ssize_t stringlength,
655 const char *delimiter,
656 ssize_t delimiterlength,
657 bool collapse,
658 char ***list,
659 uint64_t *listlength);
660
668 static void split(const char *string,
669 const char *delimiter,
670 ssize_t delimiterlength,
671 bool collapse,
672 char ***list,
673 uint64_t *listlength);
681 static void split(const char *string,
682 ssize_t stringlength,
683 const char *delimiter,
684 bool collapse,
685 char ***list,
686 uint64_t *listlength);
687
695 static void split(const char *string,
696 const char *delimiter,
697 bool collapse,
698 char ***list,
699 uint64_t *listlength);
700
704 static char *subString(const char *str,
705 size_t start, size_t end);
706
710 static char *subString(const char *str, size_t start);
711
714 static char *insertString(const char *dest,
715 const char *src,
716 uint64_t index);
717
735 static ssize_t printf(char *buffer, size_t length,
736 const char *format, ...);
737
758 static ssize_t printf(char *buffer, size_t length,
759 const char *format,
760 va_list *argp);
761
762 #include <rudiments/private/charstring.h>
763 };
764
765 #endif
charstring
Definition: charstring.h:16
character
Definition: character.h:11