Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

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

XalanTranscodingServices.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(XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680)
00017 #define XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
00023 
00024 
00025 
00026 #include <cassert>
00027 
00028 
00029 
00030 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00031 #include <xalanc/PlatformSupport/XSLException.hpp>
00032 
00033 
00034 
00035 XALAN_CPP_NAMESPACE_BEGIN
00036 
00037 
00038 
00039 class XalanOutputTranscoder;
00040 
00041 
00042 
00043 class XALAN_PLATFORMSUPPORT_EXPORT XalanTranscodingServices
00044 {
00045 public:
00046 
00050     static void
00051     initialize();
00052  
00056     static void
00057     terminate();
00058 
00059     typedef unsigned char   XalanXMLByte;
00060     typedef unsigned int    size_type;
00061     typedef unsigned int    UnicodeCharType;
00062 
00063     static size_type
00064     length(const XalanXMLByte*  theBytes)
00065     {
00066         assert(theBytes != 0);
00067 
00068         size_type   i = 0;
00069 
00070         while(theBytes[i] != 0)
00071         {
00072             ++i;
00073         }
00074 
00075         return i;
00076     }
00077 
00078     enum eCode
00079     {
00080         OK,
00081         UnsupportedEncoding,
00082         InternalFailure,
00083         SupportFilesNotFound
00084     };
00085 
00086 
00096     static XalanOutputTranscoder*
00097     makeNewTranscoder(
00098             const XalanDOMString&   theEncodingName,
00099             eCode&                  theResult,
00100             size_type               theBlockSize);
00101 
00107     static void
00108     destroyTranscoder(XalanOutputTranscoder*    theTranscoder);
00109 
00116     static bool
00117     encodingIsUTF8(const XalanDOMChar*      theEncodingName);
00118 
00125     static bool
00126     encodingIsUTF8(const XalanDOMString&    theEncodingName);
00127 
00134     static bool
00135     encodingIsUTF16(const XalanDOMChar*     theEncodingName);
00136 
00143     static bool
00144     encodingIsUTF16(const XalanDOMString&   theEncodingName);
00145 
00152     static bool
00153     encodingIsUTF32(const XalanDOMChar*     theEncodingName);
00154 
00161     static bool
00162     encodingIsUTF32(const XalanDOMString&   theEncodingName);
00174     static const XalanXMLByte*
00175     getStreamProlog(const XalanDOMString&   theEncodingName);
00176 
00183     static XalanDOMChar
00184     getMaximumCharacterValue(const XalanDOMString&  theEncoding);
00185 
00194     static XalanDOMChar
00195     getMaximumCharacterValue();
00196 
00204     static bool
00205     getBytesEqualChars(const XalanDOMString&    theEncoding);
00206 
00207     static bool
00208     canTranscodeToLocalCodePage(UnicodeCharType     theChar)
00209     {
00210         // Yuck!! See getMaximumCharacterValue() for more details.
00211         return theChar <= 0x7fu ? true : false;
00212     }
00213 
00214     static const XalanDOMChar   s_utf8String[];
00215 
00216     static const XalanDOMChar   s_utf16String[];
00217 
00218     static const XalanDOMChar   s_utf16LEString[];
00219 
00220     static const XalanDOMChar   s_utf16BEString[];
00221 
00222     static const XalanDOMChar   s_utf32String[];
00223 
00224     static const XalanDOMChar   s_asciiString[];
00225 
00226     static const XalanDOMChar   s_usASCIIString[];
00227 
00228     static const XalanDOMChar   s_windows1250String[];
00229 
00230     static const XalanDOMChar   s_iso88591String[];
00231 
00232     static const XalanDOMChar   s_shiftJISString[];
00233 
00234 
00235     class XALAN_PLATFORMSUPPORT_EXPORT UnrepresentableCharacterException : public XSLException
00236     {
00237     public:
00238 
00239         UnrepresentableCharacterException(
00240             UnicodeCharType         theCharacter,
00241             const XalanDOMString&   theEncoding);
00242 
00243         virtual
00244         ~UnrepresentableCharacterException();
00245 
00246         UnicodeCharType
00247         getCharacter() const
00248         {
00249             return m_badCharacter;
00250         }
00251 
00252         const XalanDOMString&
00253         getEncoding() const
00254         {
00255             return m_encoding;
00256         }
00257 
00258     private:
00259 
00260         const UnicodeCharType   m_badCharacter;
00261 
00262         const XalanDOMString    m_encoding;
00263     };
00264 
00265 private:
00266 
00267     static const XalanXMLByte   s_dummyByteOrderMark[];
00268     static const XalanXMLByte   s_UTF8ByteOrderMark[];
00269     static const XalanDOMChar   s_UTF16ByteOrderMark[];
00270 };
00271 
00272 
00273 
00274 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputTranscoder
00275 {
00276 public:
00277 
00278     typedef XalanTranscodingServices::XalanXMLByte      XalanXMLByte;
00279     typedef XalanTranscodingServices::eCode             eCode;
00280     typedef XalanTranscodingServices::size_type         size_type;
00281     typedef XalanTranscodingServices::UnicodeCharType   UnicodeCharType;
00282 
00283     explicit
00284     XalanOutputTranscoder();
00285 
00286     virtual
00287     ~XalanOutputTranscoder();
00288 
00302     virtual eCode
00303     transcode(
00304             const XalanDOMChar*     theSourceData,
00305             size_type               theSourceCount,
00306             XalanXMLByte*           theTarget,
00307             size_type               theTargetSize,
00308             size_type&              theSourceCharsTranscoded,
00309             size_type&              theTargetBytesUsed) = 0;
00310 
00325     virtual eCode
00326     transcode(
00327             const XalanXMLByte*     theSourceData,
00328             size_type               theSourceCount,
00329             XalanDOMChar*           theTarget,
00330             size_type               theTargetSize,
00331             size_type&              theSourceCharsTranscoded,
00332             size_type&              theTargetBytesUsed,
00333             unsigned char*          theCharSizes) = 0;
00334 
00335     virtual bool
00336     canTranscodeTo(UnicodeCharType  theChar) const = 0;
00337 
00338 private:
00339 
00340     // Not implemented...
00341     XalanOutputTranscoder(const XalanOutputTranscoder&  theSource);
00342 
00343     bool
00344     operator==(const XalanOutputTranscoder& theRHS) const;
00345 
00346     XalanOutputTranscoder&
00347     operator=(const XalanOutputTranscoder&  theRHS);
00348 };
00349 
00350 
00351 
00352 XALAN_CPP_NAMESPACE_END
00353 
00354 
00355 
00356 #endif  // XALANTRANSCODINGSERVICES_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.