00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 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(DOMSTRINGHELPER_HEADER_GUARD_1357924680) 00058 #define DOMSTRINGHELPER_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 <functional> 00069 #if defined(XALAN_NO_IOSFWD) 00070 #if defined(XALAN_OLD_STREAM_HEADERS) 00071 #include <iostream.h> 00072 #else 00073 #include <ostream> 00074 #endif 00075 #else 00076 #include <iosfwd> 00077 #endif 00078 #include <vector> 00079 00080 00081 00082 #include <XalanDOM/XalanDOMString.hpp> 00083 00084 00085 00086 #include <PlatformSupport/XalanUnicode.hpp> 00087 #include <PlatformSupport/XalanXMLChar.hpp> 00088 00089 00090 00091 class XalanOutputStream; 00092 00093 00094 00095 // This macro has been defined to deal with certain C++ compilers which 00096 // do not create Unicode strings when the "L" string constant prefix is 00097 // used. It is meant _only_ for use with static strings. 00098 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) 00099 00100 #define XALAN_STATIC_UCODE_STRING(str) L##str 00101 00112 inline const XalanDOMString 00113 StaticStringToDOMString(const XalanDOMChar* theString) 00114 { 00115 return XalanDOMString(theString); 00116 } 00117 00118 #else 00119 00120 #define XALAN_STATIC_UCODE_STRING(str) TranscodeFromLocalCodePage(str) 00121 00130 inline const XalanDOMString& 00131 StaticStringToDOMString(const XalanDOMString& theString) 00132 { 00133 return theString; 00134 } 00135 00136 #endif 00137 00138 00139 00144 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00145 DOMStringHelperInitialize(); 00146 00147 00148 00153 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00154 DOMStringHelperTerminate(); 00155 00156 00157 00165 inline const XalanDOMChar* 00166 c_wstr(const XalanDOMString& theString) 00167 { 00168 return theString.c_str(); 00169 } 00170 00171 00172 00180 inline const char* 00181 c_str(const CharVectorType& theString) 00182 { 00183 if (theString.size() == 0) 00184 { 00185 return 0; 00186 } 00187 else 00188 { 00189 const char* const ptr = &theString[0]; 00190 00191 assert(ptr[theString.size() - 1] == '\0'); 00192 00193 return ptr; 00194 } 00195 } 00196 00197 00198 00214 inline const XalanDOMChar* 00215 c_wstr(const XalanDOMChar* theString) 00216 { 00217 return theString; 00218 } 00219 00220 00221 00229 inline const XalanDOMChar* 00230 toCharArray(const XalanDOMString& theString) 00231 { 00232 return theString.c_str(); 00233 } 00234 00235 00236 00243 inline const XalanDOMChar* 00244 toCharArray(const XalanDOMChar* theString) 00245 { 00246 return theString; 00247 } 00248 00249 00250 00258 inline const char* 00259 toCharArray(const CharVectorType& theString) 00260 { 00261 return theString.size() == 0 ? 0 : &theString[0]; 00262 } 00263 00264 00265 00273 inline void 00274 reserve( 00275 XalanDOMString& theString, 00276 unsigned int theCount) 00277 { 00278 theString.reserve(theCount); 00279 } 00280 00281 00282 00289 inline unsigned int 00290 length(const XalanDOMString& theString) 00291 { 00292 return theString.length(); 00293 } 00294 00295 00296 00304 inline unsigned int 00305 length(const XalanDOMChar* theString) 00306 { 00307 assert(theString != 0); 00308 00309 const XalanDOMChar* theBufferPointer = theString; 00310 00311 while(*theBufferPointer != 0) 00312 { 00313 theBufferPointer++; 00314 } 00315 00316 return unsigned(theBufferPointer - theString); 00317 } 00318 00319 00320 00327 inline unsigned int 00328 length(const char* theString) 00329 { 00330 assert(theString != 0); 00331 00332 return unsigned(strlen(theString)); 00333 } 00334 00335 00336 00343 inline bool 00344 isEmpty(const XalanDOMString& str) 00345 { 00346 return str.empty(); 00347 } 00348 00349 00350 00360 inline unsigned int 00361 indexOf( 00362 const XalanDOMChar* theString, 00363 XalanDOMChar theChar) 00364 { 00365 assert(theString != 0); 00366 00367 const XalanDOMChar* thePointer = theString; 00368 00369 while(*thePointer != theChar && *thePointer != 0) 00370 { 00371 ++thePointer; 00372 } 00373 00374 return unsigned(thePointer - theString); 00375 } 00376 00377 00378 00389 inline unsigned int 00390 indexOf( 00391 const XalanDOMChar* theString, 00392 unsigned int theStringLength, 00393 XalanDOMChar theChar) 00394 { 00395 assert(theString != 0); 00396 00397 const XalanDOMChar* thePointer = theString; 00398 const XalanDOMChar* const theEndPointer = theString + theStringLength; 00399 00400 while(*thePointer != theChar && thePointer != theEndPointer) 00401 { 00402 ++thePointer; 00403 } 00404 00405 return unsigned(thePointer - theString); 00406 } 00407 00408 00409 00419 inline unsigned int 00420 indexOf( 00421 const XalanDOMString& theString, 00422 XalanDOMChar theChar) 00423 { 00424 return length(theString) == 0 ? 0 : indexOf(c_wstr(theString), theChar); 00425 } 00426 00427 00428 00438 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00439 indexOf( 00440 const XalanDOMChar* theString, 00441 const XalanDOMChar* theSubstring); 00442 00443 00453 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00454 indexOf( 00455 const XalanDOMString& theString, 00456 const XalanDOMString& theSubstring); 00457 00458 00459 00469 00470 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00471 lastIndexOf( 00472 const XalanDOMChar* theString, 00473 XalanDOMChar theChar); 00474 00475 00476 00486 inline unsigned int 00487 lastIndexOf( 00488 const XalanDOMString& theString, 00489 XalanDOMChar theChar) 00490 { 00491 return lastIndexOf(c_wstr(theString), theChar); 00492 } 00493 00494 00495 00503 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00504 startsWith( 00505 const XalanDOMChar* theString, 00506 const XalanDOMChar* theSubstring); 00507 00508 00509 00517 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00518 startsWith( 00519 const XalanDOMChar* theString, 00520 const XalanDOMString& theSubstring); 00521 00522 00523 00531 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00532 startsWith( 00533 const XalanDOMString& theString, 00534 const XalanDOMChar* theSubstring); 00535 00536 00537 00545 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00546 startsWith( 00547 const XalanDOMString& theString, 00548 const XalanDOMString& theSubstring); 00549 00550 00551 00559 inline bool 00560 startsWith( 00561 const XalanDOMString& theString, 00562 const char* theSubstring) 00563 { 00564 return startsWith( 00565 theString, 00566 XalanDOMString(theSubstring)); 00567 } 00568 00569 00570 00578 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00579 endsWith( 00580 const XalanDOMChar* theString, 00581 const XalanDOMChar* theSubstring); 00582 00583 00584 00592 inline bool 00593 endsWith( 00594 const XalanDOMString& theDOMString, 00595 const XalanDOMString& theSubstring) 00596 { 00597 return endsWith(c_wstr(theDOMString), c_wstr(theSubstring)); 00598 } 00599 00600 00601 00609 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00610 DoubleToDOMString( 00611 double theValue, 00612 XalanDOMString& theResult); 00613 00614 00615 00622 inline const XalanDOMString 00623 DoubleToDOMString(double theValue) 00624 { 00625 XalanDOMString theResult; 00626 00627 DoubleToDOMString(theValue, theResult); 00628 00629 return theResult; 00630 } 00631 00632 00633 00642 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00643 LongToHexDOMString( 00644 long theValue, 00645 XalanDOMString& theResult); 00646 00647 00648 00656 inline const XalanDOMString 00657 LongToHexDOMString(long theValue) 00658 { 00659 XalanDOMString theResult; 00660 00661 LongToHexDOMString(theValue, theResult); 00662 00663 return theResult; 00664 } 00665 00666 00667 00676 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00677 UnsignedLongToHexDOMString( 00678 unsigned long theValue, 00679 XalanDOMString& theResult); 00680 00681 00682 00690 inline const XalanDOMString 00691 UnsignedLongToHexDOMString(unsigned long theValue) 00692 { 00693 XalanDOMString theResult; 00694 00695 UnsignedLongToHexDOMString(theValue, theResult); 00696 00697 return theResult; 00698 } 00699 00700 00701 00709 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00710 LongToDOMString( 00711 long theValue, 00712 XalanDOMString& theResult); 00713 00714 00715 00722 inline const XalanDOMString 00723 LongToDOMString(long theValue) 00724 { 00725 XalanDOMString theResult; 00726 00727 LongToDOMString(theValue, theResult); 00728 00729 return theResult; 00730 } 00731 00732 00733 00742 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00743 UnsignedLongToDOMString( 00744 unsigned long theValue, 00745 XalanDOMString& theResult); 00746 00747 00748 00755 inline const XalanDOMString 00756 UnsignedLongToDOMString(unsigned long theValue) 00757 { 00758 XalanDOMString theResult; 00759 00760 UnsignedLongToDOMString(theValue, theResult); 00761 00762 return theResult; 00763 } 00764 00765 00766 00773 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00774 WideStringToInt(const XalanDOMChar* theString); 00775 00776 00777 00784 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00785 WideStringToLong(const XalanDOMChar* theString); 00786 00787 00788 00795 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00796 WideStringToUnsignedLong(const XalanDOMChar* theString); 00797 00798 00799 00806 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00807 WideStringToDouble(const XalanDOMChar* theString); 00808 00809 00810 00817 inline int 00818 DOMStringToInt(const XalanDOMString& theString) 00819 { 00820 return WideStringToInt(c_wstr(theString)); 00821 } 00822 00823 00824 00831 inline long 00832 DOMStringToLong(const XalanDOMString& theString) 00833 { 00834 return WideStringToLong(c_wstr(theString)); 00835 } 00836 00837 00838 00845 inline unsigned long 00846 DOMStringToUnsignedLong(const XalanDOMString& theString) 00847 { 00848 return WideStringToUnsignedLong(c_wstr(theString)); 00849 } 00850 00851 00852 00859 inline double 00860 DOMStringToDouble(const XalanDOMString& theString) 00861 { 00862 return WideStringToDouble(c_wstr(theString)); 00863 } 00864 00865 00866 00874 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00875 OutputString( 00876 XalanOutputStream& theStream, 00877 const CharVectorType& theString); 00878 00879 00880 00888 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00889 OutputString( 00890 #if defined(XALAN_NO_NAMESPACES) 00891 ostream& theStream, 00892 #else 00893 std::ostream& theStream, 00894 #endif 00895 const CharVectorType& theString); 00896 00897 00898 00906 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00907 OutputString( 00908 XalanOutputStream& theStream, 00909 const XalanDOMChar* theString); 00910 00911 00912 00920 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00921 OutputString( 00922 #if defined(XALAN_NO_NAMESPACES) 00923 ostream& theStream, 00924 #else 00925 std::ostream& theStream, 00926 #endif 00927 const XalanDOMChar* theString); 00928 00929 00930 00938 inline void 00939 OutputString( 00940 XalanOutputStream& theStream, 00941 const XalanDOMString& theString) 00942 { 00943 if (isEmpty(theString) == false) 00944 { 00945 OutputString(theStream, c_wstr(theString)); 00946 } 00947 } 00948 00949 00950 00958 inline void 00959 OutputString( 00960 #if defined(XALAN_NO_NAMESPACES) 00961 ostream& theStream, 00962 #else 00963 std::ostream& theStream, 00964 #endif 00965 const XalanDOMString& theString) 00966 { 00967 OutputString(theStream, c_wstr(theString)); 00968 } 00969 00970 00971 00979 inline XalanOutputStream& 00980 operator<<( 00981 XalanOutputStream& theStream, 00982 const CharVectorType& theString) 00983 { 00984 OutputString(theStream, theString); 00985 00986 return theStream; 00987 } 00988 00989 00990 00998 #if defined(XALAN_NO_NAMESPACES) 00999 inline ostream& 01000 operator<<( 01001 ostream& theStream, 01002 #else 01003 inline std::ostream& 01004 operator<<( 01005 std::ostream& theStream, 01006 #endif 01007 const CharVectorType& theString) 01008 { 01009 OutputString(theStream, theString); 01010 01011 return theStream; 01012 } 01013 01014 01015 01023 inline XalanOutputStream& 01024 operator<<( 01025 XalanOutputStream& theStream, 01026 const XalanDOMChar* theString) 01027 { 01028 OutputString(theStream, 01029 theString); 01030 01031 return theStream; 01032 } 01033 01034 01035 01043 #if defined(XALAN_NO_NAMESPACES) 01044 inline ostream& 01045 operator<<( 01046 ostream& theStream, 01047 #else 01048 inline std::ostream& 01049 operator<<( 01050 std::ostream& theStream, 01051 #endif 01052 const XalanDOMChar* theString) 01053 { 01054 OutputString(theStream, 01055 theString); 01056 01057 return theStream; 01058 } 01059 01060 01061 01069 inline XalanOutputStream& 01070 operator<<( 01071 XalanOutputStream& theStream, 01072 const XalanDOMString& theString) 01073 { 01074 OutputString(theStream, 01075 theString); 01076 01077 return theStream; 01078 } 01079 01080 01081 01089 #if defined(XALAN_NO_NAMESPACES) 01090 inline ostream& 01091 operator<<( 01092 ostream& theStream, 01093 #else 01094 inline std::ostream& 01095 operator<<( 01096 std::ostream& theStream, 01097 #endif 01098 const XalanDOMString& theString) 01099 { 01100 OutputString(theStream, 01101 theString); 01102 01103 return theStream; 01104 } 01105 01106 01107 01115 inline XalanDOMChar 01116 charAt( 01117 const XalanDOMString& theString, 01118 unsigned int theIndex) 01119 { 01120 return theString[theIndex]; 01121 } 01122 01123 01124 01131 inline bool 01132 isXMLWhitespace(XalanDOMChar theChar) 01133 { 01134 return XalanXMLChar::isWhitespace(theChar); 01135 } 01136 01137 01138 01145 inline bool 01146 isXMLDigit(XalanDOMChar theChar) 01147 { 01148 return XalanXMLChar::isDigit(theChar); 01149 } 01150 01151 01152 01159 inline bool 01160 isXMLLetterOrDigit(XalanDOMChar theChar) 01161 { 01162 return XalanXMLChar::isDigit(theChar) || 01163 XalanXMLChar::isLetter(theChar); 01164 } 01165 01166 01167 01179 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01180 substring( 01181 const XalanDOMChar* theString, 01182 unsigned int theStartIndex, 01183 unsigned int theEndIndex = unsigned(-1)); 01184 01185 01186 01199 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 01200 substring( 01201 const XalanDOMChar* theString, 01202 XalanDOMString& theSubstring, 01203 unsigned int theStartIndex, 01204 unsigned int theEndIndex = unsigned(-1)); 01205 01206 01207 01219 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01220 substring( 01221 const XalanDOMString& theString, 01222 XalanDOMString& theSubstring, 01223 unsigned int theStartIndex, 01224 unsigned int theEndIndex = unsigned(-1)); 01225 01226 01227 01239 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01240 substring( 01241 const XalanDOMString& theString, 01242 unsigned int theStartIndex, 01243 unsigned int theEndIndex = unsigned(-1)); 01244 01245 01246 01255 inline XalanDOMChar 01256 toLowerASCII(XalanDOMChar theChar) 01257 { 01258 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01259 { 01260 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01261 } 01262 else 01263 { 01264 return theChar; 01265 } 01266 } 01267 01268 01269 01278 inline XalanDOMChar 01279 toUpperASCII(XalanDOMChar theChar) 01280 { 01281 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01282 { 01283 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01284 } 01285 else 01286 { 01287 return theChar; 01288 } 01289 } 01290 01291 01292 01301 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01302 toLowerCaseASCII(const XalanDOMChar* theString); 01303 01304 01305 01314 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01315 toLowerCaseASCII(const XalanDOMString& theString); 01316 01317 01318 01327 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01328 toUpperCaseASCII(const XalanDOMChar* theString); 01329 01330 01331 01340 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01341 toUpperCaseASCII(const XalanDOMString& theString); 01342 01343 01344 01357 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01358 compare( 01359 const CharVectorType& theLHS, 01360 const CharVectorType& theRHS); 01361 01362 01363 01377 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01378 compare( 01379 const XalanDOMChar* theLHS, 01380 unsigned int theLHSLength, 01381 const XalanDOMChar* theRHS, 01382 unsigned int theRHSLength); 01383 01384 01385 01397 inline int 01398 compare( 01399 const XalanDOMChar* theLHS, 01400 const XalanDOMChar* theRHS) 01401 { 01402 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01403 } 01404 01405 01406 01417 inline int 01418 compare( 01419 const XalanDOMString& theLHS, 01420 const XalanDOMString& theRHS) 01421 { 01422 return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01423 } 01424 01425 01426 01438 inline int 01439 compare( 01440 const XalanDOMChar* theLHS, 01441 const XalanDOMString& theRHS) 01442 { 01443 return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01444 } 01445 01446 01447 01459 inline int 01460 compare( 01461 const XalanDOMString& theLHS, 01462 const XalanDOMChar* theRHS) 01463 { 01464 return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01465 } 01466 01467 01468 01481 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01482 compareIgnoreCaseASCII( 01483 const XalanDOMChar* theLHS, 01484 unsigned int theLHSLength, 01485 const XalanDOMChar* theRHS, 01486 unsigned int theRHSLength); 01487 01488 01489 01500 inline int 01501 compareIgnoreCaseASCII( 01502 const XalanDOMChar* theLHS, 01503 const XalanDOMChar* theRHS) 01504 { 01505 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01506 } 01507 01508 01509 01522 inline int 01523 compareIgnoreCaseASCII( 01524 const XalanDOMString& theLHS, 01525 const XalanDOMString& theRHS) 01526 { 01527 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01528 } 01529 01530 01531 01545 inline int 01546 compareIgnoreCaseASCII( 01547 const XalanDOMString& theLHS, 01548 const XalanDOMChar* theRHS) 01549 { 01550 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01551 } 01552 01553 01554 01568 inline int 01569 compareIgnoreCaseASCII( 01570 const XalanDOMChar* theLHS, 01571 const XalanDOMString& theRHS) 01572 { 01573 return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01574 } 01575 01576 01577 01588 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01589 collationCompare( 01590 const XalanDOMChar* theLHS, 01591 unsigned int theLHSLength, 01592 const XalanDOMChar* theRHS, 01593 unsigned int theRHSLength); 01594 01595 01596 01607 inline int 01608 collationCompare( 01609 const XalanDOMChar* theLHS, 01610 const XalanDOMChar* theRHS) 01611 { 01612 return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS)); 01613 } 01614 01615 01616 01627 inline int 01628 collationCompare( 01629 const XalanDOMString& theLHS, 01630 const XalanDOMString& theRHS) 01631 { 01632 return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01633 } 01634 01635 01636 01645 inline int 01646 collationCompare( 01647 const XalanDOMChar* theLHS, 01648 const XalanDOMString& theRHS) 01649 { 01650 return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01651 } 01652 01653 01654 01663 inline int 01664 collationCompare( 01665 const XalanDOMString& theLHS, 01666 const XalanDOMChar* theRHS) 01667 { 01668 return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01669 } 01670 01671 01672 01681 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01682 equals( 01683 const XalanDOMChar* theLHS, 01684 const XalanDOMChar* theRHS, 01685 unsigned int theLength); 01686 01687 01688 01696 inline bool 01697 equals( 01698 const XalanDOMChar* theLHS, 01699 const XalanDOMChar* theRHS) 01700 { 01701 const unsigned int theLHSLength = length(theLHS); 01702 01703 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 01704 } 01705 01706 01707 01715 inline bool 01716 equals( 01717 const XalanDOMString& theLHS, 01718 const XalanDOMString& theRHS) 01719 { 01720 return theLHS == theRHS; 01721 } 01722 01723 01724 01732 inline bool 01733 equals( 01734 const XalanDOMChar* theLHS, 01735 const XalanDOMString& theRHS) 01736 { 01737 assert(theLHS != 0); 01738 01739 // Swap them... 01740 return theRHS == theLHS; 01741 } 01742 01743 01744 01752 inline bool 01753 equals(const XalanDOMString& theLHS, 01754 const XalanDOMChar* theRHS) 01755 { 01756 return equals(theRHS, theLHS); 01757 } 01758 01759 01760 01768 inline bool 01769 equals(const XalanDOMString& theLHS, 01770 const char* theRHS) 01771 { 01772 assert(theRHS != 0); 01773 01774 const unsigned int theRHSLength = length(theRHS); 01775 01776 if (theRHSLength != length(theLHS)) 01777 { 01778 return false; 01779 } 01780 else 01781 { 01782 return theLHS == XalanDOMString(theRHS, theRHSLength); 01783 } 01784 } 01785 01786 01787 01795 inline bool 01796 equals(const char* theLHS, 01797 const XalanDOMString& theRHS) 01798 { 01799 return equals(theRHS, theLHS); 01800 } 01801 01802 01803 01811 inline bool 01812 equals(const XalanDOMChar* theLHS, 01813 const char* theRHS) 01814 { 01815 assert(theLHS != 0); 01816 assert(theRHS != 0); 01817 01818 const unsigned int theRHSLength = length(theRHS); 01819 01820 if (theRHSLength != length(theLHS)) 01821 { 01822 return false; 01823 } 01824 else 01825 { 01826 return equals(XalanDOMString(theRHS, theRHSLength), theLHS); 01827 } 01828 } 01829 01830 01831 01839 inline bool 01840 equals(const char* theLHS, 01841 const XalanDOMChar* theRHS) 01842 { 01843 return equals(theRHS, theLHS); 01844 } 01845 01846 01847 01856 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01857 equalsIgnoreCaseASCII( 01858 const XalanDOMChar* theLHS, 01859 const XalanDOMChar* theRHS, 01860 unsigned int theLength); 01861 01862 01863 01872 inline bool 01873 equalsIgnoreCaseASCII( 01874 const XalanDOMChar* theLHS, 01875 const XalanDOMChar* theRHS) 01876 { 01877 const unsigned int theLength = length(theLHS); 01878 01879 return theLength != length(theRHS) ? false : 01880 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 01881 } 01882 01883 01884 01893 inline bool 01894 equalsIgnoreCaseASCII( 01895 const XalanDOMString& theLHS, 01896 const XalanDOMString& theRHS) 01897 { 01898 const unsigned int theLength = length(theLHS); 01899 01900 return theLength != length(theRHS) ? false : 01901 equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength); 01902 } 01903 01904 01905 01914 inline bool 01915 equalsIgnoreCaseASCII( 01916 const XalanDOMChar* theLHS, 01917 const XalanDOMString& theRHS) 01918 { 01919 const unsigned int theRHSLength = length(theRHS); 01920 01921 return theRHSLength != length(theLHS) ? false : 01922 equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength); 01923 } 01924 01925 01926 01935 inline bool 01936 equalsIgnoreCaseASCII( 01937 const XalanDOMString& theLHS, 01938 const XalanDOMChar* theRHS) 01939 { 01940 return equalsIgnoreCaseASCII(theRHS, theLHS); 01941 } 01942 01943 01944 01954 inline bool 01955 operator<( 01956 const CharVectorType& theLHS, 01957 const CharVectorType& theRHS) 01958 { 01959 return compare(theLHS, theRHS) < 0 ? true : false; 01960 } 01961 01962 01963 01973 inline bool 01974 operator<( 01975 const XalanDOMString& theLHS, 01976 const XalanDOMString& theRHS) 01977 { 01978 return compare(theLHS, theRHS) < 0 ? true : false; 01979 } 01980 01981 01982 01991 inline XalanDOMString& 01992 assign( 01993 XalanDOMString& theString, 01994 const XalanDOMString& theStringToAssign) 01995 { 01996 theString = theStringToAssign; 01997 01998 return theString; 01999 } 02000 02001 02002 02011 inline XalanDOMString& 02012 assign( 02013 XalanDOMString& theString, 02014 const XalanDOMChar* theStringToAssign, 02015 unsigned int theStringToAssignLength = unsigned(-1)) 02016 { 02017 if (theStringToAssignLength == unsigned(-1)) 02018 { 02019 theString.assign(theStringToAssign); 02020 } 02021 else 02022 { 02023 theString.assign(theStringToAssign, theStringToAssignLength); 02024 } 02025 02026 return theString; 02027 } 02028 02029 02030 02038 inline XalanDOMString& 02039 append( 02040 XalanDOMString& theString, 02041 const XalanDOMString& theStringToAppend) 02042 { 02043 theString.append(theStringToAppend); 02044 02045 return theString; 02046 } 02047 02048 02049 02058 inline XalanDOMString& 02059 append( 02060 XalanDOMString& theString, 02061 const XalanDOMChar* theStringToAppend, 02062 unsigned int theStringToAppendLength = unsigned(-1)) 02063 { 02064 assert(theStringToAppend != 0); 02065 02066 if (theStringToAppendLength == unsigned(-1)) 02067 { 02068 theString.append(theStringToAppend); 02069 } 02070 else 02071 { 02072 theString.append(theStringToAppend, theStringToAppendLength); 02073 } 02074 02075 return theString; 02076 } 02077 02078 02079 02088 inline XalanDOMString& 02089 append( 02090 XalanDOMString& theString, 02091 const char* theStringToAppend, 02092 unsigned int theStringToAppendLength = unsigned(-1)) 02093 { 02094 theString.append(TranscodeFromLocalCodePage(theStringToAppend, theStringToAppendLength)); 02095 02096 return theString; 02097 } 02098 02099 02100 02108 inline XalanDOMString& 02109 append( 02110 XalanDOMString& theString, 02111 const XalanDOMChar theCharToAppend) 02112 { 02113 theString.append(1, theCharToAppend); 02114 02115 return theString; 02116 } 02117 02118 02119 02127 inline XalanDOMString& 02128 append( 02129 XalanDOMString& theString, 02130 char theCharToAppend) 02131 { 02132 // We have to transcode before appending... 02133 char theTempBuffer[] = { theCharToAppend, '\0' }; 02134 02135 return append(theString, theTempBuffer); 02136 } 02137 02138 02139 02148 inline XalanDOMString& 02149 insert( 02150 XalanDOMString& theString, 02151 unsigned int thePosition, 02152 const XalanDOMString& theStringToInsert) 02153 { 02154 theString.insert(thePosition, theStringToInsert); 02155 02156 return theString; 02157 } 02158 02159 02160 02169 inline XalanDOMString& 02170 insert( 02171 XalanDOMString& theString, 02172 unsigned int thePosition, 02173 const XalanDOMChar* theStringToInsert) 02174 { 02175 theString.insert(thePosition, theStringToInsert); 02176 02177 return theString; 02178 } 02179 02180 02181 02188 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 02189 trim(const XalanDOMString& theString); 02190 02191 02192 02198 inline void 02199 clear(XalanDOMString& theString) 02200 { 02201 theString.clear(); 02202 } 02203 02204 02205 02211 inline void 02212 erase(XalanDOMString& theString) 02213 { 02214 theString.erase(); 02215 } 02216 02217 02218 02225 inline void 02226 releaseMemory(XalanDOMString& theString) 02227 { 02228 XalanDOMString().swap(theString); 02229 } 02230 02231 02232 02233 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02234 CopyWideStringToVector( 02235 const XalanDOMChar* theString, 02236 CharVectorType& theVector); 02237 02238 02239 02240 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02241 CopyStringToVector( 02242 const char* theString, 02243 CharVectorType& theVector); 02244 02245 02246 02255 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02256 MakeXalanDOMCharVector( 02257 const char* data, 02258 bool fTranscode = true); 02259 02260 02261 02269 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02270 MakeXalanDOMCharVector(const XalanDOMChar* data); 02271 02272 02273 02281 inline XalanDOMCharVectorType 02282 MakeXalanDOMCharVector(const XalanDOMString& data) 02283 { 02284 return MakeXalanDOMCharVector(c_wstr(data)); 02285 } 02286 02287 02288 02289 #if defined(XALAN_NO_NAMESPACES) 02290 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02291 #else 02292 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02293 #endif 02294 { 02295 result_type 02296 operator() (const argument_type& theString) const 02297 { 02298 return c_wstr(theString); 02299 } 02300 }; 02301 02302 02303 02310 #if defined(XALAN_NO_NAMESPACES) 02311 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 02312 #else 02313 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 02314 #endif 02315 { 02316 result_type 02317 operator() (argument_type theKey) const 02318 { 02319 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 02320 02321 result_type theHashValue = 0; 02322 02323 if (theRawBuffer != 0) 02324 { 02325 while (*theRawBuffer) 02326 { 02327 theHashValue = 5 * theHashValue + *theRawBuffer; 02328 02329 theRawBuffer++; 02330 } 02331 } 02332 02333 return theHashValue++; 02334 } 02335 }; 02336 02337 02338 02346 #if defined(XALAN_NO_NAMESPACES) 02347 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02348 #else 02349 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02350 #endif 02351 { 02352 result_type 02353 operator() (first_argument_type theLHS, 02354 second_argument_type theRHS) const 02355 { 02356 return equals(theLHS, theRHS); 02357 } 02358 }; 02359 02360 02361 02369 #if defined(XALAN_NO_NAMESPACES) 02370 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02371 #else 02372 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02373 #endif 02374 { 02375 result_type 02376 operator() (first_argument_type theLHS, 02377 second_argument_type theRHS) const 02378 { 02379 return !equals(theLHS, theRHS); 02380 } 02381 }; 02382 02383 02384 02392 #if defined(XALAN_NO_NAMESPACES) 02393 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02394 #else 02395 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02396 #endif 02397 { 02398 result_type 02399 operator() (first_argument_type theLHS, 02400 second_argument_type theRHS) const 02401 { 02402 return compare(theLHS, theRHS) < 0 ? true : false; 02403 } 02404 }; 02405 02406 02407 02415 #if defined(XALAN_NO_NAMESPACES) 02416 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02417 #else 02418 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02419 #endif 02420 { 02421 result_type 02422 operator() (first_argument_type theLHS, 02423 second_argument_type theRHS) const 02424 { 02425 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02426 } 02427 }; 02428 02429 02430 02438 #if defined(XALAN_NO_NAMESPACES) 02439 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02440 #else 02441 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02442 #endif 02443 { 02444 result_type 02445 operator() (first_argument_type theLHS, 02446 second_argument_type theRHS) const 02447 { 02448 return compare(theLHS, theRHS) <= 0 ? true : false; 02449 } 02450 }; 02451 02452 02453 02461 #if defined(XALAN_NO_NAMESPACES) 02462 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02463 #else 02464 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02465 #endif 02466 { 02467 result_type 02468 operator() (first_argument_type theLHS, 02469 second_argument_type theRHS) const 02470 { 02471 return compare(theLHS, theRHS) > 0 ? true : false; 02472 } 02473 }; 02474 02475 02476 02484 #if defined(XALAN_NO_NAMESPACES) 02485 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02486 #else 02487 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02488 #endif 02489 { 02490 result_type 02491 operator() (first_argument_type theLHS, 02492 second_argument_type theRHS) const 02493 { 02494 return compare(theLHS, theRHS) >= 0 ? true : false; 02495 } 02496 }; 02497 02498 02499 02505 #if defined(XALAN_NO_NAMESPACES) 02506 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02507 #else 02508 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02509 #endif 02510 { 02519 result_type 02520 operator()( 02521 first_argument_type theLHS, 02522 second_argument_type theRHS) const 02523 { 02524 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02525 } 02526 }; 02527 02528 02529 02536 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02537 isXMLWhitespace(const XalanDOMString& string); 02538 02539 02540 02549 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02550 isXMLWhitespace( 02551 const XalanDOMChar ch[], 02552 unsigned int start, 02553 unsigned int length); 02554 02555 02556 02563 inline bool 02564 isXMLWhitespace(const XalanDOMChar* theString) 02565 { 02566 assert(theString != 0); 02567 02568 return isXMLWhitespace(theString, 0, length(theString)); 02569 } 02570 02571 02572 02573 #endif // DOMSTRINGHELPER_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|