File indexing completed on 2025-01-30 10:27:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_DOMSTRINGPOOL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMSTRINGPOOL_HPP
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <xercesc/util/XercesDefs.hpp>
0035
0036 XERCES_CPP_NAMESPACE_BEGIN
0037
0038 class DOMDocumentImpl;
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 struct DOMStringPoolEntry
0051 {
0052 DOMStringPoolEntry *fNext;
0053 XMLSize_t fLength;
0054 XMLCh fString[1];
0055 };
0056
0057
0058
0059
0060
0061 class DOMBuffer
0062 {
0063 public :
0064
0065
0066
0067 DOMBuffer(DOMDocumentImpl *doc, XMLSize_t capacity = 31);
0068
0069 ~DOMBuffer()
0070 {
0071 }
0072
0073
0074
0075
0076 void append (const XMLCh* const chars);
0077 void append (const XMLCh* const chars, const XMLSize_t count);
0078 void appendInPlace (const XMLCh* const chars, const XMLSize_t count);
0079
0080 void set (const XMLCh* const chars);
0081 void set (const XMLCh* const chars, const XMLSize_t count);
0082
0083 const XMLCh* getRawBuffer() const
0084 {
0085 fBuffer[fIndex] = 0;
0086 return fBuffer;
0087 }
0088
0089 void reset()
0090 {
0091 fIndex = 0;
0092 fBuffer[0] = 0;
0093 }
0094
0095 void chop
0096 (
0097 const XMLSize_t count
0098 )
0099 {
0100 fBuffer[count] = 0;
0101 fIndex = count;
0102 }
0103
0104
0105
0106
0107
0108 XMLSize_t getLen() const
0109 {
0110 return fIndex;
0111 }
0112
0113 XMLSize_t getCapacity() const
0114 {
0115 return fCapacity;
0116 }
0117
0118
0119
0120
0121 void expandCapacity(const XMLSize_t extraNeeded, bool releasePrevious = false);
0122
0123
0124 private :
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 XMLCh* fBuffer;
0144 XMLSize_t fIndex;
0145 XMLSize_t fCapacity;
0146 DOMDocumentImpl* fDoc;
0147
0148
0149
0150
0151 DOMBuffer(const DOMBuffer &);
0152 DOMBuffer & operator = (const DOMBuffer &);
0153 };
0154
0155 inline void DOMBuffer::
0156 append (const XMLCh* const chars)
0157 {
0158 XMLSize_t count = XMLString::stringLen(chars);
0159 if (fIndex + count >= fCapacity)
0160 expandCapacity(count);
0161
0162 memcpy(&fBuffer[fIndex], chars, count * sizeof(XMLCh));
0163 fIndex += count;
0164
0165
0166 fBuffer[fIndex] = 0;
0167 }
0168
0169 inline void DOMBuffer::
0170 append (const XMLCh* const chars, const XMLSize_t count)
0171 {
0172 if (fIndex + count >= fCapacity)
0173 expandCapacity(count);
0174
0175 memcpy(&fBuffer[fIndex], chars, count * sizeof(XMLCh));
0176 fIndex += count;
0177
0178
0179 fBuffer[fIndex] = 0;
0180 }
0181
0182 inline void DOMBuffer::
0183 appendInPlace (const XMLCh* const chars, const XMLSize_t count)
0184 {
0185 if (fIndex + count >= fCapacity)
0186 expandCapacity(count, true);
0187
0188 memcpy(&fBuffer[fIndex], chars, count * sizeof(XMLCh));
0189 fIndex += count;
0190
0191
0192 fBuffer[fIndex] = 0;
0193 }
0194
0195 inline void DOMBuffer::
0196 set (const XMLCh* const chars)
0197 {
0198 XMLSize_t count = XMLString::stringLen(chars);
0199 fIndex = 0;
0200 if (count >= fCapacity)
0201 expandCapacity(count);
0202
0203 memcpy(fBuffer, chars, count * sizeof(XMLCh));
0204 fIndex = count;
0205
0206
0207 fBuffer[fIndex] = 0;
0208 }
0209
0210 inline void DOMBuffer::
0211 set (const XMLCh* const chars, const XMLSize_t count)
0212 {
0213 fIndex = 0;
0214 if (count >= fCapacity)
0215 expandCapacity(count);
0216
0217 memcpy(fBuffer, chars, count * sizeof(XMLCh));
0218 fIndex = count;
0219
0220
0221 fBuffer[fIndex] = 0;
0222 }
0223
0224 XERCES_CPP_NAMESPACE_END
0225
0226 #endif