Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

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 <vector>
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 = 512, eDefaultTranscoderBlockSize = 1024 };
00052 
00053 
00054 #if defined(XALAN_NO_STD_NAMESPACE)
00055     typedef vector<XalanDOMChar>        BufferType;
00056 
00057     typedef vector<char>                TranscodeVectorType;
00058 #else
00059     typedef std::vector<XalanDOMChar>   BufferType;
00060 
00061     typedef std::vector<char>           TranscodeVectorType;
00062 #endif
00063 
00064     typedef XalanTranscodingServices::size_type         size_type;
00065     typedef XalanTranscodingServices::UnicodeCharType   UnicodeCharType;
00066 
00074     explicit
00075     XalanOutputStream(
00076             size_type   theBufferSize = eDefaultBufferSize,
00077             size_type   theTranscoderBlockSize = eDefaultTranscoderBlockSize,
00078             bool        fThrowTranscodeException = true);
00079 
00080     virtual
00081     ~XalanOutputStream();
00082 
00083     static const XalanDOMChar*
00084     defaultNewlineString()
00085     {
00086 #if defined(XALAN_NEWLINE_IS_CRLF)
00087         return s_nlCRString;
00088 #else
00089         return s_nlString;
00090 #endif
00091     }
00092 
00096     virtual void
00097     newline();
00098 
00102     virtual const XalanDOMChar*
00103     getNewlineString() const;
00104 
00110     void
00111     flushBuffer();
00112 
00116     void
00117     flush()
00118     {
00119         flushBuffer();
00120 
00121         doFlush();
00122     }
00123 
00130     void
00131     write(char  theChar)
00132     {
00133         write(&theChar, 1);
00134     }
00135 
00142     void
00143     write(XalanDOMChar  theChar)
00144     {
00145         assert(m_bufferSize > 0);
00146 
00147         if (m_buffer.size() == m_bufferSize)
00148         {
00149             flushBuffer();
00150         }
00151 
00152         m_buffer.push_back(theChar);
00153     }
00154 
00162     void
00163     write(const char*   theBuffer)
00164     {
00165         assert(theBuffer != 0);
00166         assert(m_buffer.empty() == true);
00167 
00168         write(theBuffer, length(theBuffer));
00169     }
00170 
00177     void
00178     write(const XalanDOMChar*   theBuffer)
00179     {
00180         write(theBuffer, length(theBuffer));
00181     }
00182 
00191     void
00192     write(
00193             const char*     theBuffer,
00194             size_type       theBufferLength)
00195     {
00196         assert(theBuffer != 0);
00197         assert(m_buffer.empty() == true);
00198 
00199         writeData(theBuffer,
00200                   theBufferLength);
00201     }
00202 
00210     void
00211     write(
00212             const XalanDOMChar*     theBuffer,
00213             size_type               theBufferLength);
00214 
00220     const XalanDOMString&
00221     getOutputEncoding() const
00222     {
00223         return m_encoding;
00224     }
00225 
00231     void
00232     setOutputEncoding(const XalanDOMString&     theEncoding);
00233 
00240     bool
00241     canTranscodeTo(UnicodeCharType  theChar) const;
00242 
00243     const XalanOutputTranscoder*
00244     getTranscoder() const
00245     {
00246         return m_transcoder;
00247     }
00248 
00258     bool
00259     getThrowTranscodeException() const
00260     {
00261         return m_throwTranscodeException;
00262     }
00263 
00273     void
00274     setThrowTranscodeException(bool     flag)
00275     {
00276         m_throwTranscodeException = flag;
00277     }
00278 
00284     void
00285     setBufferSize(size_type     theBufferSize);
00286 
00287 
00288     class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputStreamException : public XSLException
00289     {
00290     public:
00291 
00292         XalanOutputStreamException(
00293             const XalanDOMString&   theMessage,
00294             const XalanDOMString&   theType);
00295 
00296         virtual
00297         ~XalanOutputStreamException();
00298     };
00299 
00300     class XALAN_PLATFORMSUPPORT_EXPORT UnknownEncodingException : public XalanOutputStreamException
00301     {
00302     public:
00303 
00304         explicit
00305         UnknownEncodingException();
00306 
00307         virtual
00308         ~UnknownEncodingException();
00309     };
00310 
00311     class XALAN_PLATFORMSUPPORT_EXPORT UnsupportedEncodingException : public XalanOutputStreamException
00312     {
00313     public:
00314 
00315         UnsupportedEncodingException(const XalanDOMString&  theEncoding);
00316 
00317         virtual
00318         ~UnsupportedEncodingException();
00319 
00320         const XalanDOMString&
00321         getEncoding() const
00322         {
00323             return m_encoding;
00324         }
00325 
00326     private:
00327 
00328         const XalanDOMString    m_encoding;
00329     };
00330 
00331     class XALAN_PLATFORMSUPPORT_EXPORT TranscoderInternalFailureException : public XalanOutputStreamException
00332     {
00333     public:
00334 
00335         TranscoderInternalFailureException(const XalanDOMString&    theEncoding);
00336 
00337         virtual
00338         ~TranscoderInternalFailureException();
00339 
00340         const XalanDOMString&
00341         getEncoding() const
00342         {
00343             return m_encoding;
00344         }
00345 
00346     private:
00347 
00348         const XalanDOMString    m_encoding;
00349     };
00350 
00351     class XALAN_PLATFORMSUPPORT_EXPORT TranscodingException : public XalanOutputStreamException
00352     {
00353     public:
00354 
00355         explicit
00356         TranscodingException();
00357 
00358         virtual
00359         ~TranscodingException();
00360     };
00361 
00362 protected:
00363 
00371     void
00372     transcode(
00373             const XalanDOMChar*     theBuffer,
00374             size_type               theBufferLength,
00375             TranscodeVectorType&    theDestination);
00376 
00383     virtual void
00384     writeData(
00385             const char*     theBuffer,
00386             size_type       theBufferLength) = 0;
00387 
00391     virtual void
00392     doFlush() = 0;
00393 
00394     static const XalanDOMChar               s_nlString[];
00395     static const XalanDOMChar               s_nlCRString[];
00396 
00397     static const XalanDOMString::size_type  s_nlStringLength;
00398     static const XalanDOMString::size_type  s_nlCRStringLength;
00399 
00400 private:
00401 
00402     // These are not implemented...
00403     XalanOutputStream(const XalanOutputStream&);
00404 
00405     XalanOutputStream&
00406     operator=(const XalanOutputStream&);
00407 
00408     bool
00409     operator==(const XalanOutputStream&) const;
00410 
00411     void
00412     doWrite(
00413             const XalanDOMChar*     theBuffer,
00414             size_type               theBufferLength);
00415 
00416 
00417     const size_type         m_transcoderBlockSize;
00418 
00419     XalanOutputTranscoder*  m_transcoder;
00420 
00421     size_type               m_bufferSize;
00422 
00423     BufferType              m_buffer;
00424 
00425     XalanDOMString          m_encoding;
00426 
00427     bool                    m_writeAsUTF16;
00428 
00429     bool                    m_throwTranscodeException;
00430 
00431     TranscodeVectorType     m_transcodingBuffer;
00432 };
00433 
00434 
00435 
00436 XALAN_CPP_NAMESPACE_END
00437 
00438 
00439 
00440 #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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.