upgrade to xpdf 3.00.
[swftools.git] / pdf2swf / xpdf / GString.h
blob2083802b381736d16a56a954eb1da8205b1ebe97
1 //========================================================================
2 //
3 // GString.h
4 //
5 // Simple variable-length string type.
6 //
7 // Copyright 1996-2003 Glyph & Cog, LLC
8 //
9 //========================================================================
11 #ifndef GSTRING_H
12 #define GSTRING_H
14 #include <aconf.h>
16 #ifdef USE_GCC_PRAGMAS
17 #pragma interface
18 #endif
20 #include <string.h>
22 class GString {
23 public:
25 // Create an empty string.
26 GString();
28 // Create a string from a C string.
29 GString(const char *sA);
31 // Create a string from <lengthA> chars at <sA>. This string
32 // can contain null characters.
33 GString(const char *sA, int lengthA);
35 // Create a string from <lengthA> chars at <idx> in <str>.
36 GString(GString *str, int idx, int lengthA);
38 // Copy a string.
39 GString(GString *str);
40 GString *copy() { return new GString(this); }
42 // Concatenate two strings.
43 GString(GString *str1, GString *str2);
45 // Convert an integer to a string.
46 static GString *fromInt(int x);
48 // Destructor.
49 ~GString();
51 // Get length.
52 int getLength() { return length; }
54 // Get C string.
55 char *getCString() { return s; }
57 // Get <i>th character.
58 char getChar(int i) { return s[i]; }
60 // Change <i>th character.
61 void setChar(int i, char c) { s[i] = c; }
63 // Clear string to zero length.
64 GString *clear();
66 // Append a character or string.
67 GString *append(char c);
68 GString *append(GString *str);
69 GString *append(const char *str);
70 GString *append(const char *str, int lengthA);
72 // Insert a character or string.
73 GString *insert(int i, char c);
74 GString *insert(int i, GString *str);
75 GString *insert(int i, const char *str);
76 GString *insert(int i, const char *str, int lengthA);
78 // Delete a character or range of characters.
79 GString *del(int i, int n = 1);
81 // Convert string to all-upper/all-lower case.
82 GString *upperCase();
83 GString *lowerCase();
85 // Compare two strings: -1:< 0:= +1:>
86 // These functions assume the strings do not contain null characters.
87 int cmp(GString *str) { return strcmp(s, str->getCString()); }
88 int cmpN(GString *str, int n) { return strncmp(s, str->getCString(), n); }
89 int cmp(const char *sA) { return strcmp(s, sA); }
90 int cmpN(const char *sA, int n) { return strncmp(s, sA, n); }
92 private:
94 int length;
95 char *s;
97 void resize(int length1);
100 #endif