## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.10

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XalanUTF16Writer.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *     http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016 #if !defined(XALANUTF16WRITER_HEADER_GUARD_1357924680)
    00017 #define XALANUTF16WRITER_HEADER_GUARD_1357924680
    00018
    00019
    00020 #include <xalanc/XMLSupport/XalanFormatterWriter.hpp>
    00021
    00022
    00023 XALAN_CPP_NAMESPACE_BEGIN
    00024
    00025
    00026 class XalanUTF16Writer : public XalanFormatterWriter
    00027 {
    00028 public:
    00029
    00030     typedef XalanDOMChar    value_type;
    00031
    00032
    00033     XalanUTF16Writer(
    00034                 Writer&         writer,
    00035                 MemoryManager&  theMemoryManager);
    00036
    00037     virtual
    00038     ~XalanUTF16Writer()
    00039     {
    00040     }
    00041
    00045     void
    00046     outputNewline()
    00047     {
    00048         assert(m_newlineString != 0);
    00049         assert(length(m_newlineString) == m_newlineStringLength);
    00050
    00051         write(
    00052             m_newlineString,
    00053             m_newlineStringLength);
    00054     }
    00055
    00056
    00057     size_type
    00058     writeCDATAChar(
    00059                 const XalanDOMChar  chars[],
    00060                 size_type           start,
    00061                 size_type           /*length*/,
    00062                 bool&               /* outsideCDATA */)
    00063     {
    00064         assert( chars != 0 );
    00065
    00066         write(chars[start]);
    00067
    00068         return start;
    00069     }
    00070
    00074     void writeNameChar(const XalanDOMChar*            data,
    00075                        size_type                theLength)
    00076     {
    00077         write(data, theLength);
    00078     }
    00079
    00083     void writePIChars(const XalanDOMChar*       data,
    00084                         size_type               theLength)
    00085     {
    00086         write(data, theLength);
    00087     }
    00088
    00092     void writeCommentChars(const XalanDOMChar*      data,
    00093                            size_type                theLength)
    00094     {
    00095         write(data, theLength);
    00096     }
    00097
    00098     void
    00099     safeWriteContent(
    00100             const XalanDOMChar*     theChars,
    00101             size_type               theLength)
    00102     {
    00103         write(theChars, theLength);
    00104     }
    00105
    00106     void
    00107     write(
    00108             const value_type*   theChars,
    00109             size_type           theLength)
    00110     {
    00111         if (theLength > sizeof(m_buffer))
    00112         {
    00113             flushBuffer();
    00114
    00115             m_writer.write(theChars, 0, theLength);
    00116         }
    00117         else
    00118         {
    00119             if (m_bufferRemaining < theLength)
    00120             {
    00121                 flushBuffer();
    00122             }
    00123
    00124             for(size_type i = 0; i < theLength; ++i)
    00125             {
    00126                 *m_bufferPosition = theChars[i];
    00127
    00128                 ++m_bufferPosition;
    00129             }
    00130
    00131             m_bufferRemaining -= theLength;
    00132         }
    00133
    00134     }
    00135
    00136     void
    00137     write(const XalanDOMString&     theChars)
    00138     {
    00139         write(theChars.c_str(), theChars.length());
    00140     }
    00141
    00142     void
    00143     write(value_type    theChar)
    00144     {
    00145
    00146         if (m_bufferRemaining == 0)
    00147         {
    00148             flushBuffer();
    00149         }
    00150
    00151         *m_bufferPosition = theChar;
    00152
    00153         ++m_bufferPosition;
    00154         --m_bufferRemaining;
    00155     }
    00156
    00157
    00158     size_type
    00159     write(
    00160             const value_type    chars[],
    00161             size_type           start,
    00162             size_type           /*length*/)
    00163     {
    00164         write(chars[start]);
    00165
    00166         return start;
    00167     }
    00168
    00169     void
    00170     writeSafe(
    00171             const XalanDOMChar*     theChars,
    00172             size_type               theLength)
    00173     {
    00174         write(theChars, theLength);
    00175     }
    00176
    00177     void
    00178     write(const value_type* theChars)
    00179     {
    00180         write(theChars, XalanDOMString::length(theChars));
    00181     }
    00182
    00183     void
    00184     flushBuffer()
    00185     {
    00186         m_writer.write(
    00187             reinterpret_cast<const char*>(m_buffer),
    00188             0,
    00189             (m_bufferPosition - m_buffer) * sizeof m_buffer[0]);
    00190
    00191
    00192         m_bufferPosition = m_buffer;
    00193         m_bufferRemaining = kBufferSize;
    00194     }
    00195
    00196
    00197 private:
    00198
    00199     enum
    00200     {
    00201         kBufferSize = 512       // The size of the buffer
    00202     };
    00203
    00204
    00205     // Data members...
    00206     value_type      m_buffer[kBufferSize];
    00207
    00208     value_type*     m_bufferPosition;
    00209
    00210     size_type       m_bufferRemaining;
    00211 };
    00212
    00213
    00214
    00215 XALAN_CPP_NAMESPACE_END
    00216
    00217
    00218
    00219 #endif  // XALANUTF16WRITER_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.