filters
GString.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef GSTRING_H
00012 #define GSTRING_H
00013
00014 #include <aconf.h>
00015
00016
00017 #include <string.h>
00018
00019 class GString {
00020 public:
00021
00022
00023 GString();
00024
00025
00026 GString(const char *sA);
00027
00028
00029
00030 GString(const char *sA, int lengthA);
00031
00032
00033 GString(GString *str, int idx, int lengthA);
00034
00035
00036 GString(GString *str);
00037 GString *copy() { return new GString(this); }
00038
00039
00040 GString(GString *str1, GString *str2);
00041
00042
00043 static GString *fromInt(int x);
00044
00045
00046 ~GString();
00047
00048
00049 int getLength() const { return length; }
00050
00051
00052 const char *getCString() const { return s; }
00053 char *getCString() { return s; }
00054
00055
00056 char getChar(int i) const { return s[i]; }
00057
00058
00059 void setChar(int i, char c) { s[i] = c; }
00060
00061
00062 GString *clear();
00063
00064
00065 GString *append(char c);
00066 GString *append(GString *str);
00067 GString *append(const char *str);
00068 GString *append(const char *str, int lengthA);
00069
00070
00071 GString *insert(int i, char c);
00072 GString *insert(int i, GString *str);
00073 GString *insert(int i, const char *str);
00074 GString *insert(int i, const char *str, int lengthA);
00075
00076
00077 GString *del(int i, int n = 1);
00078
00079
00080 GString *upperCase();
00081 GString *lowerCase();
00082
00083
00084
00085 int cmp(const GString *str) const { return strcmp(s, str->getCString()); }
00086 int cmpN(const GString *str, int n) const { return strncmp(s, str->getCString(), n); }
00087 int cmp(const char *sA) const { return strcmp(s, sA); }
00088 int cmpN(const char *sA, int n) const { return strncmp(s, sA, n); }
00089
00090 private:
00091
00092 int length;
00093 char *s;
00094
00095 void resize(int length1);
00096 };
00097
00098 #endif
|