00001 #ifndef StringBuffer_h_seen
00002 #define StringBuffer_h_seen
00003
00004 namespace jcpp {
00005
00006
00007
00008
00009
00010 #define STRING_OVERFLOW
00011
00013 class StringBuffer : public virtual Object {
00014
00015 private:
00016
00017 char *buffer;
00019 int tmp;
00021 int used;
00022 int buffer_length;
00023 static const int SPARECAPACITY;
00024
00025 int checkIndex(int index);
00026 void newdata(int l);
00027
00028 public:
00029
00030 CDELETE StringBuffer() ;
00031 ~StringBuffer() ;
00032
00033 CDELETE StringBuffer(char *str);
00034
00035 CDELETE StringBuffer(int length);
00036
00042 StringBuffer *append(Object *obj) ;
00043
00044 StringBuffer *append ( char *str ) ;
00045 StringBuffer *append ( std::string str ) ;
00050 StringBuffer *append ( char *str, int len ) ;
00051
00053 StringBuffer *append(int i);
00054
00055 #ifdef HAVE_BOOLEAN
00056
00057 StringBuffer *append(bool b);
00058 #endif
00059
00061 StringBuffer *append(char c);
00062
00064 StringBuffer *append ( char *str, int offset, int len ) ;
00065
00067 StringBuffer *append(double d);
00068
00070 StringBuffer *append(float f);
00071
00073 StringBuffer *append(long l);
00074
00076 int capacity();
00077
00079 char charAt(int index, int & error);
00080
00081 void ensureCapacity ( int minimumCapacity );
00082
00083 STRING_OVERFLOW void getChars(int srcBegin, int srcEnd, char *dst, int dstBegin, int & rangeError);
00085
00086 StringBuffer *insert(int offset, Object *obj, int & offsetError);
00088
00089 StringBuffer *insert(int offset, char c, int & offsetError);
00091
00092 StringBuffer *insert(int offset, char *str, int & offsetError);
00094
00095 StringBuffer *insert(int offset, double d, int & offsetError);
00097
00098 StringBuffer *insert(int offset, float f, int & offsetError);
00100
00101 #ifdef HAVE_BOOLEAN
00102 StringBuffer *insert(int offset, bool b, int & offsetError);
00104 #endif
00105
00106 StringBuffer *insert(int offset, int i, int & offsetError);
00108
00109 StringBuffer *insert(int offset, long l, int & offsetError);
00111
00113 int length();
00114
00115 StringBuffer *reverse();
00116
00117 void setCharAt(int index, char ch, int &err);
00118
00119 void setLength(int newLength, int & StringIndexOutOfBoundsErrJC) ;
00120
00122 CFREE char *toString() ;
00123
00124 };
00125
00126 } ENDSEMI
00127 #endif // StringBuffer_h_seen