upgraded to xpdf-3.01pl1
[swftools.git] / pdf2swf / xpdf / GString.h
1 //========================================================================
2 //
3 // GString.h
4 //
5 // Simple variable-length string type.
6 //
7 // Copyright 1996-2003 Glyph & Cog, LLC
8 //
9 //========================================================================
10
11 #ifndef GSTRING_H
12 #define GSTRING_H
13
14 #include <aconf.h>
15
16 #ifdef USE_GCC_PRAGMAS
17 #pragma interface
18 #endif
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   int cmp(GString *str);
85   int cmpN(GString *str, int n);
86   int cmp(const char *sA);
87   int cmpN(const char *sA, int n);
88
89 private:
90
91   int length;
92   char *s;
93
94   void resize(int length1);
95 };
96
97 #endif