18#if !defined(XALANUNICODESUBSETWRITER_HEADER_GUARD_1357924680)
19#define XALANUNICODESUBSETWRITER_HEADER_GUARD_1357924680
31template <
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),
97 m_charRefFunctor(*this),
98 m_exceptionFunctor(*this)
127 const XalanDOMChar chars[],
134 const XalanDOMChar theChar = chars[start];
136 XalanUnicodeChar value = theChar;
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,
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);
319 m_writer.write(m_buffer, 0, m_bufferPosition - m_buffer);
321 m_bufferPosition = m_buffer;
322 m_bufferRemaining = kBufferSize;
341 template <
class TranscodingFailureFunctor>
344 const XalanDOMChar chars[],
347 TranscodingFailureFunctor& failureHandler)
349 assert(chars != 0 &&
length > 0);
354 const XalanDOMChar ch = chars[start];
356 XalanUnicodeChar value = ch;
358 if (isUTF16HighSurrogate(ch) ==
true)
362 throwInvalidUTF16SurrogateException(
369 value = decodeUTF16SurrogatePair(ch, chars[start+1], getMemoryManager());
375 if(m_predicate(value))
381 failureHandler(value);
394 write(XalanUnicodeChar theChar)
398 if (theChar > 0xFFFF)
400 if (m_bufferRemaining < 2)
405 *m_bufferPosition =
static_cast<XalanDOMChar
>((theChar >> 10) + 0xD7C0);
409 *m_bufferPosition =
static_cast<XalanDOMChar
>((theChar & 0x03FF) + 0xDC00);
413 m_bufferRemaining = m_bufferRemaining -
size_type(2);
417 if (m_bufferRemaining == 0)
422 *m_bufferPosition = XalanDOMChar(theChar);
430 writeNumericCharacterReference(XalanUnicodeChar theChar)
432 const XalanDOMString& theString =
433 formatNumericCharacterReference(theChar);
435 const XalanDOMString::size_type theLength =
438 if (m_bufferRemaining < theLength)
445 assert(theString.size() <= m_bufferRemaining);
453 m_bufferRemaining -= theLength;
466 XalanDOMChar m_buffer[kBufferSize];
468 XalanDOMChar* m_bufferPosition;
472 const Predicate m_predicate;
474 const ConstantsType m_constants;
476 const WriteCharRef m_charRefFunctor;
478 const ThrowTranscodingException m_exceptionFunctor;
#define XALAN_CPP_NAMESPACE
const XalanDOMChar * c_str() const
ThrowTranscodingException(ThisType &writer)
void operator()(XalanUnicodeChar value) const
void operator()(XalanUnicodeChar value) const
WriteCharRef(ThisType &writer)
void writeNameChar(const XalanDOMChar *data, size_type theLength)
Writes name characters.
virtual ~XalanOtherEncodingWriter()
void writeCommentChars(const XalanDOMChar *data, size_type theLength)
Writes comment characters.
void writePIChars(const XalanDOMChar *data, size_type theLength)
Writes PI characters.
size_type writeCDATAChar(const XalanDOMChar chars[], size_type start, size_type length, bool &outsideCDATA)
Writes CDATA chars , if not presentable, fixes it with addition CDATA sections.
size_type write(const XalanDOMChar chars[], size_type start, size_type length)
void write(const XalanDOMString &theChars)
XalanOtherEncodingWriter< Predicate, ConstantsType > ThisType
void write(const XalanDOMChar *theChars, size_type theLength)
void write(const XalanDOMChar *theChars)
XalanOtherEncodingWriter(Writer &writer, MemoryManager &theMemoryManager)
void write(XalanDOMChar theChar)
Writes writes a UTF-16 code unit that isn't part of the surrogate pair.
void outputNewline()
Output a line break.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.