18 #if !defined(XALANUNICODESUBSETWRITER_HEADER_GUARD_1357924680)
19 #define XALANUNICODESUBSETWRITER_HEADER_GUARD_1357924680
31 template <
class Predicate,
51 m_writer.writeNumericCharacterReference(value);
71 m_writer.throwUnrepresentableCharacterException(
73 m_writer.getMemoryManager());
88 MemoryManager& theMemoryManager) :
93 m_bufferPosition(m_buffer),
94 m_bufferRemaining(kBufferSize),
95 m_predicate(writer.getStream()),
97 m_charRefFunctor(*this),
98 m_exceptionFunctor(*this)
113 assert(m_newlineString != 0);
114 assert(
length(m_newlineString) == m_newlineStringLength);
118 m_newlineStringLength);
127 const XalanDOMChar chars[],
134 const XalanDOMChar theChar = chars[start];
136 XalanUnicodeChar value = theChar;
140 if (isUTF16HighSurrogate(theChar) ==
true)
144 throwInvalidUTF16SurrogateException(
151 value = decodeUTF16SurrogatePair(theChar, chars[start+1], getMemoryManager());
157 if(m_predicate(value))
159 if (outsideCDATA ==
false)
171 m_constants.s_cdataOpenString,
172 m_constants.s_cdataOpenStringLength);
176 outsideCDATA =
false;
181 if(outsideCDATA ==
false)
186 m_constants.s_cdataCloseString,
187 m_constants.s_cdataCloseStringLength);
189 writeNumericCharacterReference(value);
195 writeNumericCharacterReference(value);
208 const XalanDOMChar* data,
211 for(
size_type i = 0; i < theLength; ++i)
213 i = write(data, i , theLength, m_exceptionFunctor);
223 const XalanDOMChar* data,
228 i = write(data, i , theLength, m_exceptionFunctor);
239 const XalanDOMChar* data,
244 i = write(data, i , theLength, m_exceptionFunctor);
250 const XalanDOMChar* theChars,
273 isUTF16HighSurrogate(theChar) ==
false &&
274 isUTF16LowSurrogate(theChar) ==
false);
276 if (m_bufferRemaining == 0)
281 if(m_predicate(theChar))
283 *m_bufferPosition = theChar;
290 writeNumericCharacterReference(theChar);
296 const XalanDOMChar chars[],
301 return write(chars, start,
length, m_charRefFunctor);
306 const XalanDOMChar* theChars,
311 const XalanDOMChar ch = theChars[i];
313 if (isUTF16HighSurrogate(ch) ==
true)
315 if (i + 1 >= theLength)
317 throwInvalidUTF16SurrogateException(ch, 0, getMemoryManager());
321 XalanUnicodeChar value = decodeUTF16SurrogatePair(ch, theChars[i+1], getMemoryManager());
323 if (this->m_isPresentable(value))
329 this->writeNumberedEntityReference(value);
337 write(
static_cast<XalanUnicodeChar
>(ch));
357 m_writer.write(m_buffer, 0, m_bufferPosition - m_buffer);
359 m_bufferPosition = m_buffer;
360 m_bufferRemaining = kBufferSize;
379 template <
class TranscodingFailureFunctor>
382 const XalanDOMChar chars[],
385 TranscodingFailureFunctor& failureHandler)
387 assert(chars != 0 &&
length > 0);
392 const XalanDOMChar ch = chars[start];
394 XalanUnicodeChar value = ch;
396 if (isUTF16HighSurrogate(ch) ==
true)
400 throwInvalidUTF16SurrogateException(
407 value = decodeUTF16SurrogatePair(ch, chars[start+1], getMemoryManager());
413 if(m_predicate(value))
419 failureHandler(value);
432 write(XalanUnicodeChar theChar)
436 if (theChar > 0xFFFF)
438 if (m_bufferRemaining < 2)
443 *m_bufferPosition =
static_cast<XalanDOMChar
>((theChar >> 10) + 0xD7C0);
447 *m_bufferPosition =
static_cast<XalanDOMChar
>((theChar & 0x03FF) + 0xDC00);
451 m_bufferRemaining = m_bufferRemaining -
size_type(2);
455 if (m_bufferRemaining == 0)
460 *m_bufferPosition = XalanDOMChar(theChar);
468 writeNumericCharacterReference(XalanUnicodeChar theChar)
470 const XalanDOMString& theString =
471 formatNumericCharacterReference(theChar);
476 if (m_bufferRemaining < theLength)
483 assert(theString.size() <= m_bufferRemaining);
491 m_bufferRemaining -= theLength;
504 XalanDOMChar m_buffer[kBufferSize];
506 XalanDOMChar* m_bufferPosition;
510 const Predicate m_predicate;
512 const ConstantsType m_constants;
514 const WriteCharRef m_charRefFunctor;
516 const ThrowTranscodingException m_exceptionFunctor;
525 #endif // XALANUNICODESUBSETWRITER_HEADER_GUARD_1357924680