author | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-04-13 00:47:20 (UTC) |
commit | 98a1e3f36567639344f12932b629e526a8783aa8 (patch) (unidiff) | |
tree | 0433d296857faceeafc54f7deabddb621f45a933 /noncore/unsupported/qpdf/goo/GString.h | |
parent | 7e31b1fba119f69929d6744d7295555ff1727f4f (diff) | |
download | opie-98a1e3f36567639344f12932b629e526a8783aa8.zip opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.gz opie-98a1e3f36567639344f12932b629e526a8783aa8.tar.bz2 |
CVS import of QPdf
Diffstat (limited to 'noncore/unsupported/qpdf/goo/GString.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/qpdf/goo/GString.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/noncore/unsupported/qpdf/goo/GString.h b/noncore/unsupported/qpdf/goo/GString.h new file mode 100644 index 0000000..3ced1c4 --- a/dev/null +++ b/noncore/unsupported/qpdf/goo/GString.h | |||
@@ -0,0 +1,98 @@ | |||
1 | //======================================================================== | ||
2 | // | ||
3 | // GString.h | ||
4 | // | ||
5 | // Simple variable-length string type. | ||
6 | // | ||
7 | // Copyright 1996 Derek B. Noonburg | ||
8 | // | ||
9 | //======================================================================== | ||
10 | |||
11 | #ifndef GSTRING_H | ||
12 | #define GSTRING_H | ||
13 | |||
14 | #ifdef __GNUC__ | ||
15 | #pragma interface | ||
16 | #endif | ||
17 | |||
18 | #include <string.h> | ||
19 | |||
20 | class GString { | ||
21 | public: | ||
22 | |||
23 | // Create an empty string. | ||
24 | GString(); | ||
25 | |||
26 | // Create a string from a C string. | ||
27 | GString(const char *sA); | ||
28 | |||
29 | // Create a string from <lengthA> chars at <sA>. This string | ||
30 | // can contain null characters. | ||
31 | GString(const char *sA, int lengthA); | ||
32 | |||
33 | // Create a string from <lengthA> chars at <idx> in <str>. | ||
34 | GString(GString *str, int idx, int lengthA); | ||
35 | |||
36 | // Copy a string. | ||
37 | GString(GString *str); | ||
38 | GString *copy() { return new GString(this); } | ||
39 | |||
40 | // Concatenate two strings. | ||
41 | GString(GString *str1, GString *str2); | ||
42 | |||
43 | // Convert an integer to a string. | ||
44 | static GString *fromInt(int x); | ||
45 | |||
46 | // Destructor. | ||
47 | ~GString(); | ||
48 | |||
49 | // Get length. | ||
50 | int getLength() { return length; } | ||
51 | |||
52 | // Get C string. | ||
53 | char *getCString() { return s; } | ||
54 | |||
55 | // Get <i>th character. | ||
56 | char getChar(int i) { return s[i]; } | ||
57 | |||
58 | // Change <i>th character. | ||
59 | void setChar(int i, char c) { s[i] = c; } | ||
60 | |||
61 | // Clear string to zero length. | ||
62 | GString *clear(); | ||
63 | |||
64 | // Append a character or string. | ||
65 | GString *append(char c); | ||
66 | GString *append(GString *str); | ||
67 | GString *append(const char *str); | ||
68 | GString *append(const char *str, int lengthA); | ||
69 | |||
70 | // Insert a character or string. | ||
71 | GString *insert(int i, char c); | ||
72 | GString *insert(int i, GString *str); | ||
73 | GString *insert(int i, const char *str); | ||
74 | GString *insert(int i, const char *str, int lengthA); | ||
75 | |||
76 | // Delete a character or range of characters. | ||
77 | GString *del(int i, int n = 1); | ||
78 | |||
79 | // Convert string to all-upper/all-lower case. | ||
80 | GString *upperCase(); | ||
81 | GString *lowerCase(); | ||
82 | |||
83 | // Compare two strings: -1:< 0:= +1:> | ||
84 | // These functions assume the strings do not contain null characters. | ||
85 | int cmp(GString *str) { return strcmp(s, str->getCString()); } | ||
86 | int cmpN(GString *str, int n) { return strncmp(s, str->getCString(), n); } | ||
87 | int cmp(const char *sA) { return strcmp(s, sA); } | ||
88 | int cmpN(const char *sA, int n) { return strncmp(s, sA, n); } | ||
89 | |||
90 | private: | ||
91 | |||
92 | int length; | ||
93 | char *s; | ||
94 | |||
95 | void resize(int length1); | ||
96 | }; | ||
97 | |||
98 | #endif | ||