## Xalan-C++ API Documentation

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

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  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *     http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016 #if !defined(XALANOUTPUTSTREAM_HEADER_GUARD_1357924680)
    00017 #define XALANOUTPUTSTREAM_HEADER_GUARD_1357924680
    00018
    00019
    00020
    00021 // Base include file.  Must be first.
    00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
    00023
    00024
    00025
    00026 #include <xalanc/Include/XalanVector.hpp>
    00027
    00028
    00029
    00030 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00031
    00032
    00033
    00034 #include <xalanc/PlatformSupport/XalanTranscodingServices.hpp>
    00035 #include <xalanc/PlatformSupport/XSLException.hpp>
    00036
    00037
    00038
    00039 XALAN_CPP_NAMESPACE_BEGIN
    00040
    00041
    00042
    00043 class XalanOutputTranscoder;
    00044
    00045
    00046
    00047 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStream
    00048 {
    00049 public :
    00050
    00051     enum { eDefaultBufferSize = 512u, eDefaultTranscoderBlockSize = 1024u };
    00052
    00053     typedef XalanVector<XalanDOMChar>       BufferType;
    00054     typedef XalanVector<char>               TranscodeVectorType;
    00055     typedef XalanTranscodingServices::size_type         size_type;
    00056     typedef XalanTranscodingServices::UnicodeCharType   UnicodeCharType;
    00057
    00065     explicit
    00066     XalanOutputStream(
    00067             MemoryManagerType&  theManager,
    00068             size_type           theBufferSize = eDefaultBufferSize,
    00069             size_type           theTranscoderBlockSize = eDefaultTranscoderBlockSize,
    00070             bool                fThrowTranscodeException = true);
    00071
    00072     virtual
    00073     ~XalanOutputStream();
    00074
    00075     MemoryManagerType&
    00076     getMemoryManager()
    00077     {
    00078         return m_buffer.getMemoryManager();
    00079     }
    00080
    00081     static const XalanDOMChar*
    00082     defaultNewlineString()
    00083     {
    00084 #if defined(XALAN_NEWLINE_IS_CRLF)
    00085         return s_nlCRString;
    00086 #else
    00087         return s_nlString;
    00088 #endif
    00089     }
    00090
    00094     virtual void
    00095     newline();
    00096
    00100     virtual const XalanDOMChar*
    00101     getNewlineString() const;
    00102
    00108     void
    00109     flushBuffer();
    00110
    00114     void
    00115     flush()
    00116     {
    00117         flushBuffer();
    00118
    00119         doFlush();
    00120     }
    00121
    00128     void
    00129     write(char  theChar)
    00130     {
    00131         write(&theChar, 1);
    00132     }
    00133
    00140     void
    00141     write(XalanDOMChar  theChar)
    00142     {
    00143         assert(m_bufferSize > 0);
    00144
    00145         if (m_buffer.size() == m_bufferSize)
    00146         {
    00147             flushBuffer();
    00148         }
    00149
    00150         m_buffer.push_back(theChar);
    00151     }
    00152
    00160     void
    00161     write(const char*   theBuffer)
    00162     {
    00163         assert(theBuffer != 0);
    00164         assert(m_buffer.empty() == true);
    00165
    00166         write(theBuffer, length(theBuffer));
    00167     }
    00168
    00175     void
    00176     write(const XalanDOMChar*   theBuffer)
    00177     {
    00178         write(theBuffer, length(theBuffer));
    00179     }
    00180
    00189     void
    00190     write(
    00191             const char*     theBuffer,
    00192             size_type       theBufferLength)
    00193     {
    00194         assert(theBuffer != 0);
    00195         assert(m_buffer.empty() == true);
    00196
    00197         writeData(theBuffer,
    00198                   theBufferLength);
    00199     }
    00200
    00208     void
    00209     write(
    00210             const XalanDOMChar*     theBuffer,
    00211             size_type               theBufferLength);
    00212
    00218     const XalanDOMString&
    00219     getOutputEncoding() const
    00220     {
    00221         return m_encoding;
    00222     }
    00223
    00229     void
    00230     setOutputEncoding(const XalanDOMString&     theEncoding);
    00231
    00238     bool
    00239     canTranscodeTo(UnicodeCharType  theChar) const;
    00240
    00241
    00242     const XalanOutputTranscoder*
    00243     getTranscoder() const
    00244     {
    00245         return m_transcoder;
    00246     }
    00247
    00257     bool
    00258     getThrowTranscodeException() const
    00259     {
    00260         return m_throwTranscodeException;
    00261     }
    00262
    00272     void
    00273     setThrowTranscodeException(bool     flag)
    00274     {
    00275         m_throwTranscodeException = flag;
    00276     }
    00277
    00283     void
    00284     setBufferSize(size_type     theBufferSize);
    00285
    00286
    00287     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
    00288     {
    00289     public:
    00290
    00291         XalanOutputStreamException(
    00292             const XalanDOMString&   theMessage,
    00293             MemoryManagerType&      theManager);
    00294
    00295         XalanOutputStreamException( const XalanOutputStreamException& other):
    00296             XSLException(other)
    00297             {
    00298             }
    00299
    00300         virtual
    00301         ~XalanOutputStreamException();
    00302
    00303         virtual const XalanDOMChar*
    00304         getType() const
    00305         {
    00306             return m_type;
    00307         }
    00308
    00309     private:
    00310         static const XalanDOMChar   m_type[];
    00311
    00312     };
    00313
    00314     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
    00315     {
    00316     public:
    00317
    00318         explicit
    00319         UnknownEncodingException(XalanDOMString& theBuffer);
    00320
    00321         virtual
    00322         ~UnknownEncodingException();
    00323
    00324         virtual const XalanDOMChar*
    00325         getType() const
    00326         {
    00327             return m_type;
    00328         }
    00329
    00330     private:
    00331         static const XalanDOMChar   m_type[];
    00332
    00333     };
    00334
    00335     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
    00336     {
    00337     public:
    00338
    00339         UnsupportedEncodingException(const XalanDOMString&  theEncoding,
    00340                                         XalanDOMString& theBuffer);
    00341
    00342         UnsupportedEncodingException(const UnsupportedEncodingException& other) :
    00343         XalanOutputStreamException(other),
    00344         m_encoding(other.getEncoding(),(const_cast<XalanDOMString*>(&(other.m_encoding)))->getMemoryManager())
    00345         {
    00346         }
    00347
    00348         virtual
    00349         ~UnsupportedEncodingException();
    00350
    00351         const XalanDOMString&
    00352         getEncoding() const
    00353         {
    00354             return m_encoding;
    00355         }
    00356
    00357
    00358         virtual const XalanDOMChar*
    00359         getType() const
    00360         {
    00361             return m_type;
    00362         }
    00363     private:
    00364
    00365         static const XalanDOMChar   m_type[];
    00366
    00367         const XalanDOMString    m_encoding;
    00368     };
    00369
    00370     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
    00371     {
    00372     public:
    00373
    00374         TranscoderInternalFailureException(const XalanDOMString&    theEncoding,
    00375                                             XalanDOMString& theBuffer);
    00376
    00377         TranscoderInternalFailureException(const TranscoderInternalFailureException& other) :
    00378             XalanOutputStreamException(other),
    00379             m_encoding(other.getEncoding(),(const_cast<XalanDOMString*>(&(other.m_encoding)))->getMemoryManager())
    00380             {
    00381             }
    00382
    00383         virtual
    00384         ~TranscoderInternalFailureException();
    00385
    00386         const XalanDOMString&
    00387         getEncoding() const
    00388         {
    00389             return m_encoding;
    00390         }
    00391
    00392     private:
    00393
    00394         const XalanDOMString    m_encoding;
    00395     };
    00396
    00397     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
    00398     {
    00399     public:
    00400
    00401         explicit
    00402         TranscodingException(XalanDOMString& theBuffer);
    00403
    00404         TranscodingException(const TranscodingException& other) :
    00405         XalanOutputStreamException(other)
    00406         {
    00407         }
    00408
    00409         virtual
    00410         ~TranscodingException();
    00411     };
    00412
    00413 protected:
    00414
    00422     void
    00423     transcode(
    00424             const XalanDOMChar*     theBuffer,
    00425             size_type               theBufferLength,
    00426             TranscodeVectorType&    theDestination);
    00427
    00434     virtual void
    00435     writeData(
    00436             const char*         theBuffer,
    00437             size_type           theBufferLength) = 0;
    00438
    00442     virtual void
    00443     doFlush() = 0;
    00444
    00445     static const XalanDOMChar               s_nlString[];
    00446     static const XalanDOMChar               s_nlCRString[];
    00447
    00448     static const XalanDOMString::size_type  s_nlStringLength;
    00449     static const XalanDOMString::size_type  s_nlCRStringLength;
    00450
    00451 private:
    00452
    00453     // These are not implemented...
    00454     XalanOutputStream(const XalanOutputStream&);
    00455
    00456     XalanOutputStream&
    00457     operator=(const XalanOutputStream&);
    00458
    00459     bool
    00460     operator==(const XalanOutputStream&) const;
    00461
    00462     void
    00463     doWrite(
    00464             const XalanDOMChar*     theBuffer,
    00465             size_type               theBufferLength);
    00466
    00467
    00468     const size_type         m_transcoderBlockSize;
    00469
    00470     XalanOutputTranscoder*  m_transcoder;
    00471
    00472     size_type               m_bufferSize;
    00473
    00474     BufferType              m_buffer;
    00475
    00476     XalanDOMString          m_encoding;
    00477
    00478     bool                    m_writeAsUTF16;
    00479
    00480     bool                    m_throwTranscodeException;
    00481
    00482     TranscodeVectorType     m_transcodingBuffer;
    00483 };
    00484
    00485
    00486
    00487 XALAN_CPP_NAMESPACE_END
    00488
    00489
    00490
    00491 #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.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.