Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/goo/GString.h
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-04-17 02:59:58 (GMT)
committer Arturo Espinosa <unammx@src.gnome.org>1999-04-17 02:59:58 (GMT)
commitd9f9a6449f377b4c933b75d57541b19c6d088994 (patch)
tree04f7f0c54447ef792fbf83bc5039174f4681b3bb /pdf/goo/GString.h
Initial revision
Diffstat (limited to 'pdf/goo/GString.h')
-rw-r--r--pdf/goo/GString.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/pdf/goo/GString.h b/pdf/goo/GString.h
new file mode 100644
index 0000000..904f425
--- /dev/null
+++ b/pdf/goo/GString.h
@@ -0,0 +1,92 @@
+//========================================================================
+//
+// GString.h
+//
+// Simple variable-length string type.
+//
+// Copyright 1996 Derek B. Noonburg
+//
+//========================================================================
+
+#ifndef GSTRING_H
+#define GSTRING_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include <string.h>
+
+class GString {
+public:
+
+ // Create an empty string.
+ GString();
+
+ // Create a string from a C string.
+ GString(char *s1);
+
+ // Create a string from <length1> chars at <s1>. This string
+ // can contain null characters.
+ GString (char *s1, int length1);
+
+ // Copy a string.
+ GString(GString *str);
+ GString *copy() { return new GString(this); }
+
+ // Concatenate two strings.
+ GString(GString *str1, GString *str2);
+
+ // Destructor.
+ ~GString();
+
+ // Get length.
+ int getLength() { return length; }
+
+ // Get C string.
+ char *getCString() { return s; }
+
+ // Get <i>th character.
+ char getChar(int i) { return s[i]; }
+
+ // Change <i>th character.
+ void setChar(int i, char c) { s[i] = c; }
+
+ // Clear string to zero length.
+ GString *clear();
+
+ // Append a character or string.
+ GString *append(char c);
+ GString *append(GString *str);
+ GString *append(char *str);
+ GString *append(char *str, int length1);
+
+ // Insert a character or string.
+ GString *insert(int i, char c);
+ GString *insert(int i, GString *str);
+ GString *insert(int i, char *str);
+ GString *insert(int i, char *str, int length1);
+
+ // Delete a character or range of characters.
+ GString *del(int i, int n = 1);
+
+ // Convert string to all-upper/all-lower case.
+ GString *upperCase();
+ GString *lowerCase();
+
+ // Compare two strings: -1:< 0:= +1:>
+ // These functions assume the strings do not contain null characters.
+ int cmp(GString *str) { return strcmp(s, str->getCString()); }
+ int cmpN(GString *str, int n) { return strncmp(s, str->getCString(), n); }
+ int cmp(char *s1) { return strcmp(s, s1); }
+ int cmpN(char *s1, int n) { return strncmp(s, s1, n); }
+
+private:
+
+ int length;
+ char *s;
+
+ void resize(int length1);
+};
+
+#endif