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 <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 00069 00070 00071 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00072 #include <xalanc/PlatformSupport/XSLException.hpp> 00073 00074 00075 00076 XALAN_CPP_NAMESPACE_BEGIN 00077 00078 00079 00080 class XalanOutputTranscoder; 00081 00082 00083 00084 class XALAN_PLATFORMSUPPORT_EXPORT XalanTranscodingServices 00085 { 00086 public: 00087 00091 static void 00092 initialize(); 00093 00097 static void 00098 terminate(); 00099 00100 typedef unsigned char XalanXMLByte; 00101 00102 static size_t 00103 length(const XalanXMLByte* theBytes) 00104 { 00105 assert(theBytes != 0); 00106 00107 const XalanXMLByte* theCurrentByte = theBytes; 00108 00109 while(*theCurrentByte != 0) 00110 { 00111 ++theCurrentByte; 00112 } 00113 00114 return theCurrentByte - theBytes; 00115 } 00116 00117 enum eCode 00118 { 00119 OK, 00120 UnsupportedEncoding, 00121 InternalFailure, 00122 SupportFilesNotFound 00123 }; 00124 00125 00135 static XalanOutputTranscoder* 00136 makeNewTranscoder( 00137 const XalanDOMString& theEncodingName, 00138 eCode& theResult, 00139 size_t theBlockSize); 00140 00146 static void 00147 destroyTranscoder(XalanOutputTranscoder* theTranscoder); 00148 00155 static bool 00156 encodingIsUTF8(const XalanDOMChar* theEncodingName); 00157 00164 static bool 00165 encodingIsUTF8(const XalanDOMString& theEncodingName); 00166 00173 static bool 00174 encodingIsUTF16(const XalanDOMChar* theEncodingName); 00175 00182 static bool 00183 encodingIsUTF16(const XalanDOMString& theEncodingName); 00184 00191 static bool 00192 encodingIsUTF32(const XalanDOMChar* theEncodingName); 00193 00200 static bool 00201 encodingIsUTF32(const XalanDOMString& theEncodingName); 00213 static const XalanXMLByte* 00214 getStreamProlog(const XalanDOMString& theEncodingName); 00215 00222 static XalanDOMChar 00223 getMaximumCharacterValue(const XalanDOMString& theEncoding); 00224 00233 static XalanDOMChar 00234 getMaximumCharacterValue(); 00235 00243 static bool 00244 getBytesEqualChars(const XalanDOMString& theEncoding); 00245 00246 static bool 00247 canTranscodeToLocalCodePage(unsigned int theChar) 00248 { 00249 // Yuck!! See getMaximumCharacterValue() for more details. 00250 return theChar <= 0x7fu ? true : false; 00251 } 00252 00253 static const XalanDOMChar s_utf8String[]; 00254 00255 static const XalanDOMChar s_utf16String[]; 00256 00257 static const XalanDOMChar s_utf16LEString[]; 00258 00259 static const XalanDOMChar s_utf16BEString[]; 00260 00261 static const XalanDOMChar s_utf32String[]; 00262 00263 static const XalanDOMChar s_asciiString[]; 00264 00265 static const XalanDOMChar s_usASCIIString[]; 00266 00267 static const XalanDOMChar s_windows1250String[]; 00268 00269 static const XalanDOMChar s_iso88591String[]; 00270 00271 static const XalanDOMChar s_shiftJISString[]; 00272 00273 00274 class XALAN_PLATFORMSUPPORT_EXPORT UnrepresentableCharacterException : public XSLException 00275 { 00276 public: 00277 00278 UnrepresentableCharacterException( 00279 XalanDOMChar theCharacter, 00280 const XalanDOMString& theEncoding); 00281 00282 virtual 00283 ~UnrepresentableCharacterException(); 00284 00285 XalanDOMChar 00286 getCharacter() const 00287 { 00288 return m_badCharacter; 00289 } 00290 00291 const XalanDOMString& 00292 getEncoding() const 00293 { 00294 return m_encoding; 00295 } 00296 00297 private: 00298 00299 const XalanDOMChar m_badCharacter; 00300 00301 const XalanDOMString m_encoding; 00302 }; 00303 00304 private: 00305 00306 static const XalanXMLByte s_dummyByteOrderMark[]; 00307 static const XalanXMLByte s_UTF8ByteOrderMark[]; 00308 static const XalanDOMChar s_UTF16ByteOrderMark[]; 00309 }; 00310 00311 00312 00313 class XALAN_PLATFORMSUPPORT_EXPORT XalanOutputTranscoder 00314 { 00315 public: 00316 00317 typedef XalanTranscodingServices::XalanXMLByte XalanXMLByte; 00318 typedef XalanTranscodingServices::eCode eCode; 00319 00320 explicit 00321 XalanOutputTranscoder(); 00322 00323 virtual 00324 ~XalanOutputTranscoder(); 00325 00339 virtual eCode 00340 transcode( 00341 const XalanDOMChar* theSourceData, 00342 size_t theSourceCount, 00343 XalanXMLByte* theTarget, 00344 size_t theTargetSize, 00345 size_t& theSourceCharsTranscoded, 00346 size_t& theTargetBytesUsed) = 0; 00347 00362 virtual eCode 00363 transcode( 00364 const XalanXMLByte* theSourceData, 00365 size_t theSourceCount, 00366 XalanDOMChar* theTarget, 00367 size_t theTargetSize, 00368 size_t& theSourceCharsTranscoded, 00369 size_t& theTargetBytesUsed, 00370 unsigned char* theCharSizes) = 0; 00371 00372 virtual bool 00373 canTranscodeTo(unsigned int theChar) const = 0; 00374 00375 private: 00376 00377 // Not implemented... 00378 XalanOutputTranscoder(const XalanOutputTranscoder& theSource); 00379 00380 bool 00381 operator==(const XalanOutputTranscoder& theRHS) const; 00382 00383 XalanOutputTranscoder& 00384 operator=(const XalanOutputTranscoder& theRHS); 00385 }; 00386 00387 00388 00389 XALAN_CPP_NAMESPACE_END 00390 00391 00392 00393 #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.6 |
|