X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fxpdf%2FGString.h;fp=lib%2Fxpdf%2FGString.h;h=f4ff7c6a9ee04ad2adf1aff90acd198067ccc2fe;hb=1279e7201aaf80eca58ad982ec11de68c85631af;hp=0000000000000000000000000000000000000000;hpb=e40d573cbf6659328121d0383d6d5ac8acd58c34;p=swftools.git diff --git a/lib/xpdf/GString.h b/lib/xpdf/GString.h new file mode 100644 index 0000000..f4ff7c6 --- /dev/null +++ b/lib/xpdf/GString.h @@ -0,0 +1,97 @@ +//======================================================================== +// +// GString.h +// +// Simple variable-length string type. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +#ifndef GSTRING_H +#define GSTRING_H + +#include + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +class GString { +public: + + // Create an empty string. + GString(); + + // Create a string from a C string. + GString(const char *sA); + + // Create a string from chars at . This string + // can contain null characters. + GString(const char *sA, int lengthA); + + // Create a string from chars at in . + GString(GString *str, int idx, int lengthA); + + // Copy a string. + GString(GString *str); + GString *copy() { return new GString(this); } + + // Concatenate two strings. + GString(GString *str1, GString *str2); + + // Convert an integer to a string. + static GString *fromInt(int x); + + // Destructor. + ~GString(); + + // Get length. + int getLength() { return length; } + + // Get C string. + char *getCString() { return s; } + + // Get th character. + char getChar(int i) { return s[i]; } + + // Change 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(const char *str); + GString *append(const char *str, int lengthA); + + // Insert a character or string. + GString *insert(int i, char c); + GString *insert(int i, GString *str); + GString *insert(int i, const char *str); + GString *insert(int i, const char *str, int lengthA); + + // 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:> + int cmp(GString *str); + int cmpN(GString *str, int n); + int cmp(const char *sA); + int cmpN(const char *sA, int n); + +private: + + int length; + char *s; + + void resize(int length1); +}; + +#endif