## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.5

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 <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 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
    00192     void
    00193     write(const char*   theBuffer)
    00194     {
    00195         assert(theBuffer != 0);
    00196
    00197         XALAN_USING_XALAN(length)
    00198
    00199         write(theBuffer, length(theBuffer));
    00200     }
    00201
    00208     void
    00209     write(const XalanDOMChar*   theBuffer)
    00210     {
    00211         XALAN_USING_XALAN(length)
    00212
    00213         write(theBuffer, length(theBuffer));
    00214     }
    00215
    00223     void
    00224     write(
    00225             const char*     theBuffer,
    00226             size_type       theBufferLength)
    00227     {
    00228         assert(theBuffer != 0);
    00229
    00230         flushBuffer();
    00231
    00232         writeData(theBuffer,
    00233                   theBufferLength);
    00234     }
    00235
    00243     void
    00244     write(
    00245             const XalanDOMChar*     theBuffer,
    00246             size_type               theBufferLength);
    00247
    00253     const XalanDOMString&
    00254     getOutputEncoding() const
    00255     {
    00256         return m_encoding;
    00257     }
    00258
    00264     void
    00265     setOutputEncoding(const XalanDOMString&     theEncoding);
    00266
    00273     bool
    00274     canTranscodeTo(unsigned int     theChar) const;
    00275
    00276     const XalanOutputTranscoder*
    00277     getTranscoder() const
    00278     {
    00279         return m_transcoder;
    00280     }
    00281
    00291     bool
    00292     getThrowTranscodeException() const
    00293     {
    00294         return m_throwTranscodeException;
    00295     }
    00296
    00306     void
    00307     setThrowTranscodeException(bool flag)
    00308     {
    00309         m_throwTranscodeException = flag;
    00310     }
    00311
    00317     void
    00318     setBufferSize(BufferType::size_type     theBufferSize);
    00319
    00320
    00321     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
    00322     {
    00323     public:
    00324
    00325         XalanOutputStreamException(
    00326             const XalanDOMString&   theMessage,
    00327             const XalanDOMString&   theType);
    00328
    00329         virtual
    00330         ~XalanOutputStreamException();
    00331     };
    00332
    00333     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
    00334     {
    00335     public:
    00336
    00337         explicit
    00338         UnknownEncodingException();
    00339
    00340         virtual
    00341         ~UnknownEncodingException();
    00342     };
    00343
    00344     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
    00345     {
    00346     public:
    00347
    00348         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
    00349
    00350         virtual
    00351         ~UnsupportedEncodingException();
    00352
    00353         const XalanDOMString&
    00354         getEncoding() const
    00355         {
    00356             return m_encoding;
    00357         }
    00358
    00359     private:
    00360
    00361         const XalanDOMString    m_encoding;
    00362     };
    00363
    00364     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
    00365     {
    00366     public:
    00367
    00368         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
    00369
    00370         virtual
    00371         ~TranscoderInternalFailureException();
    00372
    00373         const XalanDOMString&
    00374         getEncoding() const
    00375         {
    00376             return m_encoding;
    00377         }
    00378
    00379     private:
    00380
    00381         const XalanDOMString    m_encoding;
    00382     };
    00383
    00384     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
    00385     {
    00386     public:
    00387
    00388         explicit
    00389         TranscodingException();
    00390
    00391         virtual
    00392         ~TranscodingException();
    00393     };
    00394
    00395 protected:
    00396
    00404     void
    00405     transcode(
    00406             const XalanDOMChar*     theBuffer,
    00407             size_type               theBufferLength,
    00408             TranscodeVectorType&    theDestination);
    00409
    00416     virtual void
    00417     writeData(
    00418             const char*     theBuffer,
    00419             size_type       theBufferLength) = 0;
    00420
    00424     virtual void
    00425     doFlush() = 0;
    00426
    00427     static const XalanDOMChar               s_nlString[];
    00428     static const XalanDOMChar               s_nlCRString[];
    00429
    00430     static const XalanDOMString::size_type  s_nlStringLength;
    00431     static const XalanDOMString::size_type  s_nlCRStringLength;
    00432
    00433 private:
    00434
    00435     // These are not implemented...
    00436     XalanOutputStream(const XalanOutputStream&);
    00437
    00438     XalanOutputStream&
    00439     operator=(const XalanOutputStream&);
    00440
    00441     bool
    00442     operator==(const XalanOutputStream&) const;
    00443
    00444     // Utility functions...
    00445     void
    00446     flushBuffer();
    00447
    00448     void
    00449     doWrite(
    00450             const XalanDOMChar*     theBuffer,
    00451             size_t                  theBufferLength);
    00452
    00453
    00454     const TranscodeVectorType::size_type    m_transcoderBlockSize;
    00455
    00456     XalanOutputTranscoder*                  m_transcoder;
    00457
    00458     BufferType::size_type                   m_bufferSize;
    00459
    00460     BufferType                              m_buffer;
    00461
    00462     XalanDOMString                          m_encoding;
    00463
    00464     bool                                    m_writeAsUTF16;
    00465
    00466     bool                                    m_throwTranscodeException;
    00467
    00468     TranscodeVectorType                     m_transcodingBuffer;
    00469 };
    00470
    00471
    00472
    00473 XALAN_CPP_NAMESPACE_END
    00474
    00475
    00476
    00477 #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.5 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.