Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.3

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, 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 
00246     bool
00247     getThrowTranscodeException() const
00248     {
00249         return m_throwTranscodeException;
00250     }
00251 
00261     void
00262     setThrowTranscodeException(bool flag)
00263     {
00264         m_throwTranscodeException = flag;
00265     }
00266 
00272     void
00273     setBufferSize(BufferType::size_type     theBufferSize);
00274 
00275 
00276     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
00277     {
00278     public:
00279 
00280         XalanOutputStreamException(
00281             const XalanDOMString&   theMessage,
00282             const XalanDOMString&   theType);
00283 
00284         virtual
00285         ~XalanOutputStreamException();
00286     };
00287 
00288     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
00289     {
00290     public:
00291 
00292         explicit
00293         UnknownEncodingException();
00294 
00295         virtual
00296         ~UnknownEncodingException();
00297     };
00298 
00299     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
00300     {
00301     public:
00302 
00303         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
00304 
00305         virtual
00306         ~UnsupportedEncodingException();
00307 
00308         const XalanDOMString&
00309         getEncoding() const
00310         {
00311             return m_encoding;
00312         }
00313 
00314     private:
00315 
00316         const XalanDOMString    m_encoding;
00317     };
00318 
00319     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
00320     {
00321     public:
00322 
00323         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
00324 
00325         virtual
00326         ~TranscoderInternalFailureException();
00327 
00328         const XalanDOMString&
00329         getEncoding() const
00330         {
00331             return m_encoding;
00332         }
00333 
00334     private:
00335 
00336         const XalanDOMString    m_encoding;
00337     };
00338 
00339     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
00340     {
00341     public:
00342 
00343         explicit
00344         TranscodingException();
00345 
00346         virtual
00347         ~TranscodingException();
00348     };
00349 
00350 protected:
00351 
00359     void
00360     transcode(
00361             const XalanDOMChar*     theBuffer,
00362             size_type               theBufferLength,
00363             TranscodeVectorType&    theDestination);
00364 
00365     virtual void
00366     writeData(
00367             const char*     theBuffer,
00368             size_type       theBufferLength) = 0;
00369 
00370     virtual void
00371     doFlush() = 0;
00372 
00373 private:
00374 
00375     // These are not implemented...
00376     XalanOutputStream(const XalanOutputStream&);
00377 
00378     XalanOutputStream&
00379     operator=(const XalanOutputStream&);
00380 
00381     bool
00382     operator==(const XalanOutputStream&) const;
00383 
00384     // Utility functions...
00385     void
00386     flushBuffer();
00387 
00388     void
00389     doWrite(
00390             const XalanDOMChar*     theBuffer,
00391             size_t                  theBufferLength);
00392 
00393 
00394     const TranscodeVectorType::size_type    m_transcoderBlockSize;
00395 
00396     XalanOutputTranscoder*                  m_transcoder;
00397 
00398     BufferType::size_type                   m_bufferSize;
00399 
00400     BufferType                              m_buffer;
00401 
00402     XalanDOMString                          m_encoding;
00403 
00404     bool                                    m_writeAsUTF16;
00405 
00406     bool                                    m_throwTranscodeException;
00407 
00408     TranscodeVectorType                     m_transcodingBuffer;
00409 };
00410 
00411 
00412 
00413 #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.3
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.