Xalan-C++ API Documentation

The Xalan-C++ XSL Transformer Version 1.0

Main Page   Namespace List   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     explicit
00101     XalanOutputStream(
00102             BufferType::size_type           theBufferSize = eDefaultBufferSize,
00103             TranscodeVectorType::size_type  theTranscoderBlockSize = eDefaultTranscoderBlockSize);
00104 
00105     virtual
00106     ~XalanOutputStream();
00107 
00111     virtual void
00112     flush();
00113 
00120     virtual void
00121     write(char  theChar);
00122 
00129     virtual void
00130     write(XalanDOMChar  theChar);
00131 
00138     virtual void
00139     write(const char*   theBuffer);
00140 
00147     virtual void
00148     write(const XalanDOMChar*   theBuffer);
00149 
00157     virtual void
00158     write(
00159             const char*     theBuffer,
00160             unsigned long   theBufferLength);
00161 
00169     virtual void
00170     write(
00171             const XalanDOMChar*     theBuffer,
00172             unsigned long           theBufferLength);
00173 
00179     virtual const XalanDOMString&
00180     getOutputEncoding() const;
00181 
00187     virtual void
00188     setOutputEncoding(const XalanDOMString&     theEncoding);
00189 
00195     virtual void
00196     setBufferSize(BufferType::size_type     theBufferSize);
00197 
00198 
00199     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
00200     {
00201     public:
00202 
00203         XalanOutputStreamException(
00204             const XalanDOMString&   theMessage,
00205             const XalanDOMString&   theType);
00206 
00207         virtual
00208         ~XalanOutputStreamException();
00209     };
00210 
00211     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
00212     {
00213     public:
00214 
00215         explicit
00216         UnknownEncodingException();
00217 
00218         virtual
00219         ~UnknownEncodingException();
00220     };
00221 
00222     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
00223     {
00224     public:
00225 
00226         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
00227 
00228         virtual
00229         ~UnsupportedEncodingException();
00230 
00231         const XalanDOMString&
00232         getEncoding() const
00233         {
00234             return m_encoding;
00235         }
00236 
00237     private:
00238 
00239         const XalanDOMString&   m_encoding;
00240     };
00241 
00242     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
00243     {
00244     public:
00245 
00246         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
00247 
00248         virtual
00249         ~TranscoderInternalFailureException();
00250 
00251         const XalanDOMString&
00252         getEncoding() const
00253         {
00254             return m_encoding;
00255         }
00256 
00257     private:
00258 
00259         const XalanDOMString&   m_encoding;
00260     };
00261 
00262     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
00263     {
00264     public:
00265 
00266         explicit
00267         TranscodingException();
00268 
00269         virtual
00270         ~TranscodingException();
00271     };
00272 
00273 protected:
00274 
00281     void
00282     transcode(
00283             const XalanDOMChar*     theBuffer,
00284             TranscodeVectorType&    theDestination);
00285 
00293     void
00294     transcode(
00295             const XalanDOMChar*     theBuffer,
00296             unsigned long           theBufferLength,
00297             TranscodeVectorType&    theDestination);
00298 
00299     virtual void
00300     writeData(const char*       theBuffer,
00301               unsigned long     theBufferLength) = 0;
00302 
00303     virtual void
00304     doFlush() = 0;
00305 
00306 private:
00307 
00308     // These are not implemented...
00309     XalanOutputStream(const XalanOutputStream&);
00310 
00311     XalanOutputStream&
00312     operator=(const XalanOutputStream&);
00313 
00314     bool
00315     operator==(const XalanOutputStream&) const;
00316 
00317     // Utility functions...
00318     void
00319     flushBuffer();
00320 
00321     void
00322     doWrite(const XalanDOMChar*     theBuffer);
00323 
00324 
00325     const TranscodeVectorType::size_type    m_transcoderBlockSize;
00326 
00327     XalanOutputTranscoder*                  m_transcoder;
00328 
00329     BufferType::size_type                   m_bufferSize;
00330 
00331     BufferType                              m_buffer;
00332 
00333     XalanDOMString                          m_encoding;
00334 
00335     bool                                    m_writeAsUTF16;
00336 };
00337 
00338 
00339 
00340 #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.0
Copyright © 2000 The Apache Software Foundation. All Rights Reserved.