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