00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055
00056
00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079
00080
00081
00082 #if !defined(XMLBUFFER_HPP)
00083 #define XMLBUFFER_HPP
00084
00085 #include <util/XercesDefs.hpp>
00086
00097 class XMLBuffer
00098 {
00099 public :
00100
00101
00102
00103
00105
00106 XMLBuffer() :
00107
00108 fBuffer(0)
00109 , fIndex(0)
00110 , fCapacity(1023)
00111 , fUsed(false)
00112 {
00113
00114 fBuffer = new XMLCh[fCapacity+1];
00115
00116
00117 fBuffer[0] = XMLCh(0);
00118 }
00119
00120
00122
00123 ~XMLBuffer()
00124 {
00125 delete [] fBuffer;
00126 }
00127
00128
00129
00130
00131
00132 void append(const XMLCh toAppend)
00133 {
00134 if (fIndex == fCapacity)
00135 expand();
00136
00137
00138 fBuffer[fIndex++] = toAppend;
00139 }
00140
00141 void append
00142 (
00143 const XMLCh* const chars
00144 , const unsigned int count = 0
00145 );
00146
00147 const XMLCh* getRawBuffer() const
00148 {
00149 fBuffer[fIndex] = 0;
00150 return fBuffer;
00151 }
00152
00153 XMLCh* getRawBuffer()
00154 {
00155 fBuffer[fIndex] = 0;
00156 return fBuffer;
00157 }
00158
00159 void reset()
00160 {
00161 fIndex = 0;
00162 fBuffer[0] = 0;
00163 }
00164
00165 void set
00166 (
00167 const XMLCh* const chars
00168 , const unsigned int count = 0
00169 );
00170
00171
00172
00173
00174
00175 bool getInUse()
00176 {
00177 return fUsed;
00178 }
00179
00180 unsigned int getLen() const
00181 {
00182 return fIndex;
00183 }
00184
00185 bool isEmpty()
00186 {
00187 return (fIndex == 0);
00188 }
00189
00190
00191
00192
00193
00194 void setInUse(const bool newValue)
00195 {
00196 fUsed = newValue;
00197 }
00198
00199
00200 private :
00201
00202
00203
00204 friend class XMLBufBid;
00205
00206
00207
00208
00209
00210 void expand();
00211 void insureCapacity(const unsigned int extraNeeded);
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 XMLCh* fBuffer;
00233 unsigned int fIndex;
00234 unsigned int fCapacity;
00235 bool fUsed;
00236 };
00237
00238 #endif