Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

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 
00107     explicit
00108     XalanOutputStream(
00109             BufferType::size_type           theBufferSize = eDefaultBufferSize,
00110             TranscodeVectorType::size_type  theTranscoderBlockSize = eDefaultTranscoderBlockSize,
00111             bool                            fThrowTranscodeException = true);
00112 
00113     virtual
00114     ~XalanOutputStream();
00115 
00119     void
00120     flush()
00121     {
00122         flushBuffer();
00123 
00124         doFlush();
00125     }
00126 
00133     void
00134     write(char  theChar)
00135     {
00136         write(&theChar, 1);
00137     }
00138 
00145     void
00146     write(XalanDOMChar  theChar)
00147     {
00148         assert(m_bufferSize > 0);
00149 
00150         if (m_buffer.size() == m_bufferSize)
00151         {
00152             flushBuffer();
00153         }
00154 
00155         m_buffer.push_back(theChar);
00156     }
00157 
00164     void
00165     write(const char*   theBuffer)
00166     {
00167         assert(theBuffer != 0);
00168 
00169         write(theBuffer, length(theBuffer));
00170     }
00171 
00178     void
00179     write(const XalanDOMChar*   theBuffer)
00180     {
00181         write(theBuffer, length(theBuffer));
00182     }
00183 
00191     void
00192     write(
00193             const char*     theBuffer,
00194             unsigned long   theBufferLength)
00195     {
00196         assert(theBuffer != 0);
00197 
00198         flushBuffer();
00199 
00200         writeData(theBuffer,
00201                   theBufferLength);
00202     }
00203 
00211     void
00212     write(
00213             const XalanDOMChar*     theBuffer,
00214             unsigned long           theBufferLength);
00215 
00221     const XalanDOMString&
00222     getOutputEncoding() const
00223     {
00224         return m_encoding;
00225     }
00226 
00232     void
00233     setOutputEncoding(const XalanDOMString&     theEncoding);
00234 
00244     bool
00245     getThrowTranscodeException() const
00246     {
00247         return m_throwTranscodeException;
00248     }
00249 
00259     void
00260     setThrowTranscodeException(bool flag)
00261     {
00262         m_throwTranscodeException = flag;
00263     }
00264 
00270     void
00271     setBufferSize(BufferType::size_type     theBufferSize);
00272 
00273 
00274     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
00275     {
00276     public:
00277 
00278         XalanOutputStreamException(
00279             const XalanDOMString&   theMessage,
00280             const XalanDOMString&   theType);
00281 
00282         virtual
00283         ~XalanOutputStreamException();
00284     };
00285 
00286     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
00287     {
00288     public:
00289 
00290         explicit
00291         UnknownEncodingException();
00292 
00293         virtual
00294         ~UnknownEncodingException();
00295     };
00296 
00297     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
00298     {
00299     public:
00300 
00301         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
00302 
00303         virtual
00304         ~UnsupportedEncodingException();
00305 
00306         const XalanDOMString&
00307         getEncoding() const
00308         {
00309             return m_encoding;
00310         }
00311 
00312     private:
00313 
00314         const XalanDOMString    m_encoding;
00315     };
00316 
00317     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
00318     {
00319     public:
00320 
00321         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
00322 
00323         virtual
00324         ~TranscoderInternalFailureException();
00325 
00326         const XalanDOMString&
00327         getEncoding() const
00328         {
00329             return m_encoding;
00330         }
00331 
00332     private:
00333 
00334         const XalanDOMString    m_encoding;
00335     };
00336 
00337     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
00338     {
00339     public:
00340 
00341         explicit
00342         TranscodingException();
00343 
00344         virtual
00345         ~TranscodingException();
00346     };
00347 
00348 protected:
00349 
00357     void
00358     transcode(
00359             const XalanDOMChar*     theBuffer,
00360             unsigned long           theBufferLength,
00361             TranscodeVectorType&    theDestination);
00362 
00363     virtual void
00364     writeData(const char*       theBuffer,
00365               unsigned long     theBufferLength) = 0;
00366 
00367     virtual void
00368     doFlush() = 0;
00369 
00370 private:
00371 
00372     // These are not implemented...
00373     XalanOutputStream(const XalanOutputStream&);
00374 
00375     XalanOutputStream&
00376     operator=(const XalanOutputStream&);
00377 
00378     bool
00379     operator==(const XalanOutputStream&) const;
00380 
00381     // Utility functions...
00382     void
00383     flushBuffer();
00384 
00385     void
00386     doWrite(
00387             const XalanDOMChar*     theBuffer,
00388             unsigned long           theBufferLength);
00389 
00390 
00391     const TranscodeVectorType::size_type    m_transcoderBlockSize;
00392 
00393     XalanOutputTranscoder*                  m_transcoder;
00394 
00395     BufferType::size_type                   m_bufferSize;
00396 
00397     BufferType                              m_buffer;
00398 
00399     XalanDOMString                          m_encoding;
00400 
00401     bool                                    m_writeAsUTF16;
00402 
00403     bool                                    m_throwTranscodeException;
00404 
00405     TranscodeVectorType                     m_transcodingBuffer;
00406 };
00407 
00408 
00409 
00410 #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++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.