00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000-2002 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 <PlatformSupport/DOMStringHelper.hpp> 00074 #include <PlatformSupport/XSLException.hpp> 00075 00076 00077 00078 class XalanOutputTranscoder; 00079 00080 00081 00082 class XALAN_PLATFORMSUPPORT_EXPORT XalanTranscodingServices 00083 { 00084 public: 00085 00089 static void 00090 initialize(); 00091 00095 static void 00096 terminate(); 00097 00098 typedef unsigned char XalanXMLByte; 00099 00100 static size_t 00101 length(const XalanXMLByte* theBytes) 00102 { 00103 assert(theBytes != 0); 00104 00105 const XalanXMLByte* theCurrentByte = theBytes; 00106 00107 while(*theCurrentByte != 0) 00108 { 00109 ++theCurrentByte; 00110 } 00111 00112 return theCurrentByte - theBytes; 00113 } 00114 00115 #if defined(XALAN_NO_NAMESPACES) 00116 typedef map<XalanDOMString, 00117 XalanDOMChar, 00118 DOMStringLessThanIgnoreCaseASCIIFunction> MaximumCharacterValueMapType; 00119 #else 00120 typedef std::map<XalanDOMString, 00121 XalanDOMChar, 00122 DOMStringLessThanIgnoreCaseASCIIFunction> MaximumCharacterValueMapType; 00123 #endif 00124 00125 enum eCode 00126 { 00127 OK, 00128 UnsupportedEncoding, 00129 InternalFailure, 00130 SupportFilesNotFound 00131 }; 00132 00133 00143 static XalanOutputTranscoder* 00144 makeNewTranscoder( 00145 const XalanDOMString& theEncodingName, 00146 eCode& theResult, 00147 size_t theBlockSize); 00148 00154 static void 00155 destroyTranscoder(XalanOutputTranscoder* theTranscoder); 00156 00163 static bool 00164 encodingIsUTF8(const XalanDOMChar* theEncodingName); 00165 00172 static bool 00173 encodingIsUTF8(const XalanDOMString& theEncodingName); 00174 00181 static bool 00182 encodingIsUTF16(const XalanDOMChar* theEncodingName); 00183 00190 static bool 00191 encodingIsUTF16(const XalanDOMString& theEncodingName); 00192 00199 static bool 00200 encodingIsUTF32(const XalanDOMChar* theEncodingName); 00201 00208 static bool 00209 encodingIsUTF32(const XalanDOMString& theEncodingName); 00221 static const XalanXMLByte* 00222 getStreamProlog(const XalanDOMString& theEncodingName); 00223 00230 static XalanDOMChar 00231 getMaximumCharacterValue(const XalanDOMString& theEncoding); 00232 00241 static XalanDOMChar 00242 getMaximumCharacterValue(); 00243 00251 static bool 00252 getBytesEqualChars(const XalanDOMString& theEncoding); 00253 00254 static bool 00255 canTranscodeToLocalCodePage(unsigned int theChar) 00256 { 00257 // Yuck!! See getMaximumCharacterValue() for more details. 00258 return theChar <= 0x7fu ? true : false; 00259 } 00260 00261 static const XalanDOMChar s_utf8String[]; 00262 00263 static const XalanDOMChar s_utf16String[]; 00264 00265 static const XalanDOMChar s_utf32String[]; 00266 00267 static const XalanDOMChar s_asciiString[]; 00268 00269 static const XalanDOMChar s_usASCIIString[]; 00270 00271 static const XalanDOMChar s_windows1250String[]; 00272 00273 class XALAN_PLATFORMSUPPORT_EXPORT UnrepresentableCharacterException : public XSLException 00274 { 00275 public: 00276 00277 UnrepresentableCharacterException( 00278 XalanDOMChar theCharacter, 00279 const XalanDOMString& theEncoding); 00280 00281 virtual 00282 ~UnrepresentableCharacterException(); 00283 00284 XalanDOMChar 00285 getCharacter() const 00286 { 00287 return m_badCharacter; 00288 } 00289 00290 const XalanDOMString& 00291 getEncoding() const 00292 { 00293 return m_encoding; 00294 } 00295 00296 private: 00297 00298 const XalanDOMChar m_badCharacter; 00299 00300 const XalanDOMString m_encoding; 00301 }; 00302 00303 private: 00304 00305 static const XalanXMLByte s_dummyByteOrderMark[]; 00306 static const XalanXMLByte s_UTF8ByteOrderMark[]; 00307 static const XalanDOMChar s_UTF16ByteOrderMark[]; 00308 00309 static const MaximumCharacterValueMapType& s_maximumCharacterValues; 00310 }; 00311 00312 00313 00314 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputTranscoder 00315 { 00316 public: 00317 00318 typedef XalanTranscodingServices::XalanXMLByte XalanXMLByte; 00319 typedef XalanTranscodingServices::eCode eCode; 00320 00321 explicit 00322 XalanOutputTranscoder(); 00323 00324 virtual 00325 ~XalanOutputTranscoder(); 00326 00340 virtual eCode 00341 transcode( 00342 const XalanDOMChar* theSourceData, 00343 size_t theSourceCount, 00344 XalanXMLByte* theTarget, 00345 size_t theTargetSize, 00346 size_t& theSourceCharsTranscoded, 00347 size_t& theTargetBytesUsed) = 0; 00348 00363 virtual eCode 00364 transcode( 00365 const XalanXMLByte* theSourceData, 00366 size_t theSourceCount, 00367 XalanDOMChar* theTarget, 00368 size_t theTargetSize, 00369 size_t& theSourceCharsTranscoded, 00370 size_t& theTargetBytesUsed, 00371 unsigned char* theCharSizes) = 0; 00372 00373 virtual bool 00374 canTranscodeTo(unsigned int theChar) const = 0; 00375 00376 private: 00377 00378 // Not implemented... 00379 XalanOutputTranscoder(const XalanOutputTranscoder& theSource); 00380 00381 bool 00382 operator==(const XalanOutputTranscoder& theRHS) const; 00383 00384 XalanOutputTranscoder& 00385 operator=(const XalanOutputTranscoder& theRHS); 00386 }; 00387 00388 00389 00390 #endif // XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.4 |
|