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  

XalanTranscodingServices.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 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(XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680)
00058 #define XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <PlatformSupport/PlatformSupportDefinitions.hpp>
00064 
00065 
00066 
00067 #include <cassert>
00068 #include <map>
00069 #include <vector>
00070 
00071 
00072 
00073 #include <XalanDOM/XalanDOMString.hpp>
00074 
00075 
00076 
00077 #include <PlatformSupport/XSLException.hpp>
00078 
00079 
00080 
00081 class XalanOutputTranscoder;
00082 
00083 
00084 
00085 class XALAN_PLATFORMSUPPORT_EXPORT XalanTranscodingServices
00086 {
00087 public:
00088 
00092     static void
00093     initialize();
00094  
00098     static void
00099     terminate();
00100 
00101     typedef unsigned char   XalanXMLByte;
00102 
00103     static unsigned int
00104     length(const XalanXMLByte*  theBytes)
00105     {
00106         assert(theBytes != 0);
00107 
00108         const XalanXMLByte*     theCurrentByte = theBytes;
00109 
00110         while(*theCurrentByte != 0)
00111         {
00112             ++theCurrentByte;
00113         }
00114 
00115         return theCurrentByte - theBytes;
00116     }
00117 
00118 #if defined(XALAN_NO_NAMESPACES)
00119     typedef map<XalanDOMString,
00120                 XalanDOMChar,
00121                 less<XalanDOMString> >  MaximumCharacterValueMapType;
00122 #else
00123     typedef std::map<XalanDOMString,
00124                      XalanDOMChar>      MaximumCharacterValueMapType;
00125 #endif
00126 
00127     enum eCode
00128     {
00129         OK,
00130         UnsupportedEncoding,
00131         InternalFailure,
00132         SupportFilesNotFound
00133     };
00134 
00135 
00145     static XalanOutputTranscoder*
00146     makeNewTranscoder(
00147             const XalanDOMString&   theEncodingName,
00148             eCode&                  theResult,
00149             unsigned int            theBlockSize);
00150 
00156     static void
00157     destroyTranscoder(XalanOutputTranscoder*    theTranscoder);
00158 
00165     static bool
00166     encodingIsUTF8(const XalanDOMChar*      theEncodingName);
00167 
00174     static bool
00175     encodingIsUTF8(const XalanDOMString&    theEncodingName);
00176 
00183     static bool
00184     encodingIsUTF16(const XalanDOMChar*     theEncodingName);
00185 
00192     static bool
00193     encodingIsUTF16(const XalanDOMString&   theEncodingName);
00194 
00206     static const XalanXMLByte*
00207     getStreamProlog(const XalanDOMString&   theEncodingName);
00208 
00215     static XalanDOMChar
00216     getMaximumCharacterValue(const XalanDOMString&  theEncoding);
00217 
00223     static XalanDOMChar
00224     getMaximumCharacterValue();
00225 
00233     static bool
00234     getBytesEqualChars(const XalanDOMString&    theEncoding);
00235 
00236     static const XalanDOMChar   s_utf8String[];
00237 
00238     static const XalanDOMChar   s_utf16String[];
00239 
00240     static const XalanDOMChar   s_asciiString[];
00241 
00242     static const XalanDOMChar   s_usASCIIString[];
00243 
00244     static const XalanDOMChar   s_windows1250String[];
00245 
00246     class XALAN_PLATFORMSUPPORT_EXPORT UnrepresentableCharacterException : public XSLException
00247     {
00248     public:
00249 
00250         UnrepresentableCharacterException(
00251             XalanDOMChar            theCharacter,
00252             const XalanDOMString&   theEncoding);
00253 
00254         virtual
00255         ~UnrepresentableCharacterException();
00256 
00257         XalanDOMChar
00258         getCharacter() const
00259         {
00260             return m_badCharacter;
00261         }
00262 
00263         const XalanDOMString&
00264         getEncoding() const
00265         {
00266             return m_encoding;
00267         }
00268 
00269     private:
00270 
00271         const XalanDOMChar      m_badCharacter;
00272 
00273         const XalanDOMString    m_encoding;
00274     };
00275 
00276 private:
00277 
00278     static const XalanXMLByte   s_dummyByteOrderMark[];
00279     static const XalanXMLByte   s_UTF8ByteOrderMark[];
00280     static const XalanXMLByte   s_UTF16ByteOrderMark[];
00281 
00282     static const MaximumCharacterValueMapType&  s_maximumCharacterValues;
00283 };
00284 
00285 
00286 
00287 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputTranscoder
00288 {
00289 public:
00290 
00291     typedef XalanTranscodingServices::XalanXMLByte  XalanXMLByte;
00292     typedef XalanTranscodingServices::eCode         eCode;
00293 
00294     explicit
00295     XalanOutputTranscoder();
00296 
00297     virtual
00298     ~XalanOutputTranscoder();
00299 
00313     virtual eCode
00314     transcode(
00315             const XalanDOMChar*     theSourceData,
00316             unsigned int            theSourceCount,
00317             XalanXMLByte*           theTarget,
00318             unsigned int            theTargetSize,
00319             unsigned int&           theSourceCharsTranscoded,
00320             unsigned int&           theTargetBytesUsed) = 0;
00321 
00322 private:
00323 
00324     // Not implemented...
00325     XalanOutputTranscoder(const XalanOutputTranscoder&  theSource);
00326 
00327     bool
00328     operator==(const XalanOutputTranscoder& theRHS) const;
00329 
00330     XalanOutputTranscoder&
00331     operator=(const XalanOutputTranscoder&  theRHS);
00332 };
00333 
00334 
00335 
00336 #endif  // NULLTEXTOUTPUTSTREAM_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.