Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.6

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

XalanOutputStream.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 1999-2003 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 
00147     void
00148     flush()
00149     {
00150         flushBuffer();
00151 
00152         doFlush();
00153     }
00154 
00161     void
00162     write(char  theChar)
00163     {
00164         write(&theChar, 1);
00165     }
00166 
00173     void
00174     write(XalanDOMChar  theChar)
00175     {
00176         assert(m_bufferSize > 0);
00177 
00178         if (m_buffer.size() == m_bufferSize)
00179         {
00180             flushBuffer();
00181         }
00182 
00183         m_buffer.push_back(theChar);
00184     }
00185 
00193     void
00194     write(const char*   theBuffer)
00195     {
00196         assert(theBuffer != 0);
00197         assert(m_buffer.empty() == true);
00198 
00199         write(theBuffer, length(theBuffer));
00200     }
00201 
00208     void
00209     write(const XalanDOMChar*   theBuffer)
00210     {
00211         write(theBuffer, length(theBuffer));
00212     }
00213 
00222     void
00223     write(
00224             const char*     theBuffer,
00225             size_type       theBufferLength)
00226     {
00227         assert(theBuffer != 0);
00228         assert(m_buffer.empty() == true);
00229 
00230         writeData(theBuffer,
00231                   theBufferLength);
00232     }
00233 
00241     void
00242     write(
00243             const XalanDOMChar*     theBuffer,
00244             size_type               theBufferLength);
00245 
00251     const XalanDOMString&
00252     getOutputEncoding() const
00253     {
00254         return m_encoding;
00255     }
00256 
00262     void
00263     setOutputEncoding(const XalanDOMString&     theEncoding);
00264 
00271     bool
00272     canTranscodeTo(unsigned int     theChar) const;
00273 
00274     const XalanOutputTranscoder*
00275     getTranscoder() const
00276     {
00277         return m_transcoder;
00278     }
00279 
00289     bool
00290     getThrowTranscodeException() const
00291     {
00292         return m_throwTranscodeException;
00293     }
00294 
00304     void
00305     setThrowTranscodeException(bool flag)
00306     {
00307         m_throwTranscodeException = flag;
00308     }
00309 
00315     void
00316     setBufferSize(BufferType::size_type     theBufferSize);
00317 
00318 
00319     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
00320     {
00321     public:
00322 
00323         XalanOutputStreamException(
00324             const XalanDOMString&   theMessage,
00325             const XalanDOMString&   theType);
00326 
00327         virtual
00328         ~XalanOutputStreamException();
00329     };
00330 
00331     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
00332     {
00333     public:
00334 
00335         explicit
00336         UnknownEncodingException();
00337 
00338         virtual
00339         ~UnknownEncodingException();
00340     };
00341 
00342     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
00343     {
00344     public:
00345 
00346         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
00347 
00348         virtual
00349         ~UnsupportedEncodingException();
00350 
00351         const XalanDOMString&
00352         getEncoding() const
00353         {
00354             return m_encoding;
00355         }
00356 
00357     private:
00358 
00359         const XalanDOMString    m_encoding;
00360     };
00361 
00362     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
00363     {
00364     public:
00365 
00366         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
00367 
00368         virtual
00369         ~TranscoderInternalFailureException();
00370 
00371         const XalanDOMString&
00372         getEncoding() const
00373         {
00374             return m_encoding;
00375         }
00376 
00377     private:
00378 
00379         const XalanDOMString    m_encoding;
00380     };
00381 
00382     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
00383     {
00384     public:
00385 
00386         explicit
00387         TranscodingException();
00388 
00389         virtual
00390         ~TranscodingException();
00391     };
00392 
00393 protected:
00394 
00402     void
00403     transcode(
00404             const XalanDOMChar*     theBuffer,
00405             size_type               theBufferLength,
00406             TranscodeVectorType&    theDestination);
00407 
00414     virtual void
00415     writeData(
00416             const char*     theBuffer,
00417             size_type       theBufferLength) = 0;
00418 
00422     virtual void
00423     doFlush() = 0;
00424 
00425     static const XalanDOMChar               s_nlString[];
00426     static const XalanDOMChar               s_nlCRString[];
00427 
00428     static const XalanDOMString::size_type  s_nlStringLength;
00429     static const XalanDOMString::size_type  s_nlCRStringLength;
00430 
00431 private:
00432 
00433     // These are not implemented...
00434     XalanOutputStream(const XalanOutputStream&);
00435 
00436     XalanOutputStream&
00437     operator=(const XalanOutputStream&);
00438 
00439     bool
00440     operator==(const XalanOutputStream&) const;
00441 
00442     // Utility functions...
00443     void
00444     flushBuffer();
00445 
00446     void
00447     doWrite(
00448             const XalanDOMChar*     theBuffer,
00449             size_t                  theBufferLength);
00450 
00451 
00452     const TranscodeVectorType::size_type    m_transcoderBlockSize;
00453 
00454     XalanOutputTranscoder*                  m_transcoder;
00455 
00456     BufferType::size_type                   m_bufferSize;
00457 
00458     BufferType                              m_buffer;
00459 
00460     XalanDOMString                          m_encoding;
00461 
00462     bool                                    m_writeAsUTF16;
00463 
00464     bool                                    m_throwTranscodeException;
00465 
00466     TranscodeVectorType                     m_transcodingBuffer;
00467 };
00468 
00469 
00470 
00471 XALAN_CPP_NAMESPACE_END
00472 
00473 
00474 
00475 #endif  // XALANOUTPUTSTREAM_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.6
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.