00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XALANOUTPUTSTREAM_HEADER_GUARD_1357924680) 00058 #define XALANOUTPUTSTREAM_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <PlatformSupport/PlatformSupportDefinitions.hpp> 00064 00065 00066 00067 #include <vector> 00068 00069 00070 00071 #include <XalanDOM/XalanDOMString.hpp> 00072 00073 00074 00075 #include <PlatformSupport/XSLException.hpp> 00076 00077 00078 00079 class XalanOutputTranscoder; 00080 00081 00082 00083 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStream 00084 { 00085 public : 00086 00087 enum { eDefaultBufferSize = 512, eDefaultTranscoderBlockSize = 1024 }; 00088 00089 00090 #if defined(XALAN_NO_NAMESPACES) 00091 typedef vector<XalanDOMChar> BufferType; 00092 00093 typedef vector<char> TranscodeVectorType; 00094 #else 00095 typedef std::vector<XalanDOMChar> BufferType; 00096 00097 typedef std::vector<char> TranscodeVectorType; 00098 #endif 00099 00100 typedef BufferType::size_type size_type; 00101 00109 explicit 00110 XalanOutputStream( 00111 BufferType::size_type theBufferSize = eDefaultBufferSize, 00112 TranscodeVectorType::size_type theTranscoderBlockSize = eDefaultTranscoderBlockSize, 00113 bool fThrowTranscodeException = true); 00114 00115 virtual 00116 ~XalanOutputStream(); 00117 00121 void 00122 flush() 00123 { 00124 flushBuffer(); 00125 00126 doFlush(); 00127 } 00128 00135 void 00136 write(char theChar) 00137 { 00138 write(&theChar, 1); 00139 } 00140 00147 void 00148 write(XalanDOMChar theChar) 00149 { 00150 assert(m_bufferSize > 0); 00151 00152 if (m_buffer.size() == m_bufferSize) 00153 { 00154 flushBuffer(); 00155 } 00156 00157 m_buffer.push_back(theChar); 00158 } 00159 00166 void 00167 write(const char* theBuffer) 00168 { 00169 assert(theBuffer != 0); 00170 00171 write(theBuffer, length(theBuffer)); 00172 } 00173 00180 void 00181 write(const XalanDOMChar* theBuffer) 00182 { 00183 write(theBuffer, length(theBuffer)); 00184 } 00185 00193 void 00194 write( 00195 const char* theBuffer, 00196 size_type theBufferLength) 00197 { 00198 assert(theBuffer != 0); 00199 00200 flushBuffer(); 00201 00202 writeData(theBuffer, 00203 theBufferLength); 00204 } 00205 00213 void 00214 write( 00215 const XalanDOMChar* theBuffer, 00216 size_type theBufferLength); 00217 00223 const XalanDOMString& 00224 getOutputEncoding() const 00225 { 00226 return m_encoding; 00227 } 00228 00234 void 00235 setOutputEncoding(const XalanDOMString& theEncoding); 00236 00243 bool 00244 canTranscodeTo(unsigned int theChar) const; 00245 00246 const XalanOutputTranscoder* 00247 getTranscoder() const 00248 { 00249 return m_transcoder; 00250 } 00251 00261 bool 00262 getThrowTranscodeException() const 00263 { 00264 return m_throwTranscodeException; 00265 } 00266 00276 void 00277 setThrowTranscodeException(bool flag) 00278 { 00279 m_throwTranscodeException = flag; 00280 } 00281 00287 void 00288 setBufferSize(BufferType::size_type theBufferSize); 00289 00290 00291 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException 00292 { 00293 public: 00294 00295 XalanOutputStreamException( 00296 const XalanDOMString& theMessage, 00297 const XalanDOMString& theType); 00298 00299 virtual 00300 ~XalanOutputStreamException(); 00301 }; 00302 00303 class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException 00304 { 00305 public: 00306 00307 explicit 00308 UnknownEncodingException(); 00309 00310 virtual 00311 ~UnknownEncodingException(); 00312 }; 00313 00314 class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException 00315 { 00316 public: 00317 00318 UnsupportedEncodingException(const XalanDOMString& theEncoding); 00319 00320 virtual 00321 ~UnsupportedEncodingException(); 00322 00323 const XalanDOMString& 00324 getEncoding() const 00325 { 00326 return m_encoding; 00327 } 00328 00329 private: 00330 00331 const XalanDOMString m_encoding; 00332 }; 00333 00334 class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException 00335 { 00336 public: 00337 00338 TranscoderInternalFailureException(const XalanDOMString& theEncoding); 00339 00340 virtual 00341 ~TranscoderInternalFailureException(); 00342 00343 const XalanDOMString& 00344 getEncoding() const 00345 { 00346 return m_encoding; 00347 } 00348 00349 private: 00350 00351 const XalanDOMString m_encoding; 00352 }; 00353 00354 class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException 00355 { 00356 public: 00357 00358 explicit 00359 TranscodingException(); 00360 00361 virtual 00362 ~TranscodingException(); 00363 }; 00364 00365 protected: 00366 00374 void 00375 transcode( 00376 const XalanDOMChar* theBuffer, 00377 size_type theBufferLength, 00378 TranscodeVectorType& theDestination); 00379 00380 virtual void 00381 writeData( 00382 const char* theBuffer, 00383 size_type theBufferLength) = 0; 00384 00385 virtual void 00386 doFlush() = 0; 00387 00388 private: 00389 00390 // These are not implemented... 00391 XalanOutputStream(const XalanOutputStream&); 00392 00393 XalanOutputStream& 00394 operator=(const XalanOutputStream&); 00395 00396 bool 00397 operator==(const XalanOutputStream&) const; 00398 00399 // Utility functions... 00400 void 00401 flushBuffer(); 00402 00403 void 00404 doWrite( 00405 const XalanDOMChar* theBuffer, 00406 size_t theBufferLength); 00407 00408 00409 const TranscodeVectorType::size_type m_transcoderBlockSize; 00410 00411 XalanOutputTranscoder* m_transcoder; 00412 00413 BufferType::size_type m_bufferSize; 00414 00415 BufferType m_buffer; 00416 00417 XalanDOMString m_encoding; 00418 00419 bool m_writeAsUTF16; 00420 00421 bool m_throwTranscodeException; 00422 00423 TranscodeVectorType m_transcodingBuffer; 00424 }; 00425 00426 00427 00428 #endif // XALANOUTPUTSTREAM_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.4 |
|