00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00064 00065 00066 00067 #include <vector> 00068 00069 00070 00071 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00072 00073 00074 00075 #include <xalanc/PlatformSupport/XSLException.hpp> 00076 00077 00078 00079 XALAN_CPP_NAMESPACE_BEGIN 00080 00081 00082 00083 class XalanOutputTranscoder; 00084 00085 00086 00087 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStream 00088 { 00089 public : 00090 00091 enum { eDefaultBufferSize = 512, eDefaultTranscoderBlockSize = 1024 }; 00092 00093 00094 #if defined(XALAN_NO_STD_NAMESPACE) 00095 typedef vector<XalanDOMChar> BufferType; 00096 00097 typedef vector<char> TranscodeVectorType; 00098 #else 00099 typedef std::vector<XalanDOMChar> BufferType; 00100 00101 typedef std::vector<char> TranscodeVectorType; 00102 #endif 00103 00104 typedef BufferType::size_type size_type; 00105 00113 explicit 00114 XalanOutputStream( 00115 BufferType::size_type theBufferSize = eDefaultBufferSize, 00116 TranscodeVectorType::size_type theTranscoderBlockSize = eDefaultTranscoderBlockSize, 00117 bool fThrowTranscodeException = true); 00118 00119 virtual 00120 ~XalanOutputStream(); 00121 00122 static const XalanDOMChar* 00123 defaultNewlineString() 00124 { 00125 #if defined(XALAN_NEWLINE_IS_CRLF) 00126 return s_nlCRString; 00127 #else 00128 return s_nlString; 00129 #endif 00130 } 00131 00135 virtual void 00136 newline(); 00137 00141 virtual const XalanDOMChar* 00142 getNewlineString() const; 00143 00149 void 00150 flushBuffer(); 00151 00155 void 00156 flush() 00157 { 00158 flushBuffer(); 00159 00160 doFlush(); 00161 } 00162 00169 void 00170 write(char theChar) 00171 { 00172 write(&theChar, 1); 00173 } 00174 00181 void 00182 write(XalanDOMChar theChar) 00183 { 00184 assert(m_bufferSize > 0); 00185 00186 if (m_buffer.size() == m_bufferSize) 00187 { 00188 flushBuffer(); 00189 } 00190 00191 m_buffer.push_back(theChar); 00192 } 00193 00201 void 00202 write(const char* theBuffer) 00203 { 00204 assert(theBuffer != 0); 00205 assert(m_buffer.empty() == true); 00206 00207 write(theBuffer, length(theBuffer)); 00208 } 00209 00216 void 00217 write(const XalanDOMChar* theBuffer) 00218 { 00219 write(theBuffer, length(theBuffer)); 00220 } 00221 00230 void 00231 write( 00232 const char* theBuffer, 00233 size_type theBufferLength) 00234 { 00235 assert(theBuffer != 0); 00236 assert(m_buffer.empty() == true); 00237 00238 writeData(theBuffer, 00239 theBufferLength); 00240 } 00241 00249 void 00250 write( 00251 const XalanDOMChar* theBuffer, 00252 size_type theBufferLength); 00253 00259 const XalanDOMString& 00260 getOutputEncoding() const 00261 { 00262 return m_encoding; 00263 } 00264 00270 void 00271 setOutputEncoding(const XalanDOMString& theEncoding); 00272 00279 bool 00280 canTranscodeTo(unsigned int theChar) const; 00281 00282 const XalanOutputTranscoder* 00283 getTranscoder() const 00284 { 00285 return m_transcoder; 00286 } 00287 00297 bool 00298 getThrowTranscodeException() const 00299 { 00300 return m_throwTranscodeException; 00301 } 00302 00312 void 00313 setThrowTranscodeException(bool flag) 00314 { 00315 m_throwTranscodeException = flag; 00316 } 00317 00323 void 00324 setBufferSize(BufferType::size_type theBufferSize); 00325 00326 00327 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException 00328 { 00329 public: 00330 00331 XalanOutputStreamException( 00332 const XalanDOMString& theMessage, 00333 const XalanDOMString& theType); 00334 00335 virtual 00336 ~XalanOutputStreamException(); 00337 }; 00338 00339 class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException 00340 { 00341 public: 00342 00343 explicit 00344 UnknownEncodingException(); 00345 00346 virtual 00347 ~UnknownEncodingException(); 00348 }; 00349 00350 class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException 00351 { 00352 public: 00353 00354 UnsupportedEncodingException(const XalanDOMString& theEncoding); 00355 00356 virtual 00357 ~UnsupportedEncodingException(); 00358 00359 const XalanDOMString& 00360 getEncoding() const 00361 { 00362 return m_encoding; 00363 } 00364 00365 private: 00366 00367 const XalanDOMString m_encoding; 00368 }; 00369 00370 class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException 00371 { 00372 public: 00373 00374 TranscoderInternalFailureException(const XalanDOMString& theEncoding); 00375 00376 virtual 00377 ~TranscoderInternalFailureException(); 00378 00379 const XalanDOMString& 00380 getEncoding() const 00381 { 00382 return m_encoding; 00383 } 00384 00385 private: 00386 00387 const XalanDOMString m_encoding; 00388 }; 00389 00390 class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException 00391 { 00392 public: 00393 00394 explicit 00395 TranscodingException(); 00396 00397 virtual 00398 ~TranscodingException(); 00399 }; 00400 00401 protected: 00402 00410 void 00411 transcode( 00412 const XalanDOMChar* theBuffer, 00413 size_type theBufferLength, 00414 TranscodeVectorType& theDestination); 00415 00422 virtual void 00423 writeData( 00424 const char* theBuffer, 00425 size_type theBufferLength) = 0; 00426 00430 virtual void 00431 doFlush() = 0; 00432 00433 static const XalanDOMChar s_nlString[]; 00434 static const XalanDOMChar s_nlCRString[]; 00435 00436 static const XalanDOMString::size_type s_nlStringLength; 00437 static const XalanDOMString::size_type s_nlCRStringLength; 00438 00439 private: 00440 00441 // These are not implemented... 00442 XalanOutputStream(const XalanOutputStream&); 00443 00444 XalanOutputStream& 00445 operator=(const XalanOutputStream&); 00446 00447 bool 00448 operator==(const XalanOutputStream&) const; 00449 00450 void 00451 doWrite( 00452 const XalanDOMChar* theBuffer, 00453 size_t theBufferLength); 00454 00455 00456 const TranscodeVectorType::size_type m_transcoderBlockSize; 00457 00458 XalanOutputTranscoder* m_transcoder; 00459 00460 BufferType::size_type m_bufferSize; 00461 00462 BufferType m_buffer; 00463 00464 XalanDOMString m_encoding; 00465 00466 bool m_writeAsUTF16; 00467 00468 bool m_throwTranscodeException; 00469 00470 TranscodeVectorType m_transcodingBuffer; 00471 }; 00472 00473 00474 00475 XALAN_CPP_NAMESPACE_END 00476 00477 00478 00479 #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.7 |
|