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 #if defined(XALAN_LSTRSUPPORT) 00081 #include <cwchar> 00082 #endif 00083 00084 #if defined(AIX) 00085 #include <wchar.h> 00086 #elif defined(__GNUC__) 00087 #include <wctype.h> 00088 #endif 00089 00090 00091 #include <XalanDOM/XalanDOMString.hpp> 00092 00093 00094 00095 #include <PlatformSupport/XalanUnicode.hpp> 00096 #include <PlatformSupport/XalanXMLChar.hpp> 00097 00098 00099 00100 class XalanOutputStream; 00101 00102 00103 00104 // This macro has been defined to deal with certain C++ compilers which 00105 // do not create Unicode strings when the "L" string constant prefix is 00106 // used. It is meant _only_ for use with static strings. 00107 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) 00108 00109 #define XALAN_STATIC_UCODE_STRING(str) L##str 00110 00121 inline const XalanDOMString 00122 StaticStringToDOMString(const XalanDOMChar* theString) 00123 { 00124 return XalanDOMString(theString); 00125 } 00126 00127 #else 00128 00129 #define XALAN_STATIC_UCODE_STRING(str) TranscodeFromLocalCodePage(str) 00130 00139 inline const XalanDOMString& 00140 StaticStringToDOMString(const XalanDOMString& theString) 00141 { 00142 return theString; 00143 } 00144 00145 #endif 00146 00147 00148 00153 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00154 DOMStringHelperInitialize(); 00155 00156 00157 00162 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00163 DOMStringHelperTerminate(); 00164 00165 00166 00174 inline const XalanDOMChar* 00175 c_wstr(const XalanDOMString& theString) 00176 { 00177 return theString.c_str(); 00178 } 00179 00180 00181 00189 inline const char* 00190 c_str(const CharVectorType& theString) 00191 { 00192 if (theString.size() == 0) 00193 { 00194 return 0; 00195 } 00196 else 00197 { 00198 const char* const ptr = &theString[0]; 00199 00200 assert(ptr[theString.size() - 1] == '\0'); 00201 00202 return ptr; 00203 } 00204 } 00205 00206 00207 00223 inline const XalanDOMChar* 00224 c_wstr(const XalanDOMChar* theString) 00225 { 00226 return theString; 00227 } 00228 00229 00230 00238 inline const XalanDOMChar* 00239 toCharArray(const XalanDOMString& theString) 00240 { 00241 return theString.c_str(); 00242 } 00243 00244 00245 00252 inline const XalanDOMChar* 00253 toCharArray(const XalanDOMChar* theString) 00254 { 00255 return theString; 00256 } 00257 00258 00259 00267 inline const char* 00268 toCharArray(const CharVectorType& theString) 00269 { 00270 return theString.size() == 0 ? 0 : &theString[0]; 00271 } 00272 00273 00274 00282 inline void 00283 reserve( 00284 XalanDOMString& theString, 00285 unsigned int theCount) 00286 { 00287 theString.reserve(theCount); 00288 } 00289 00290 00291 00298 inline unsigned int 00299 length(const XalanDOMString& theString) 00300 { 00301 return theString.length(); 00302 } 00303 00304 00305 00313 inline unsigned int 00314 length(const XalanDOMChar* theString) 00315 { 00316 assert(theString != 0); 00317 00318 const XalanDOMChar* theBufferPointer = theString; 00319 00320 while(*theBufferPointer != 0) 00321 { 00322 theBufferPointer++; 00323 } 00324 00325 return theBufferPointer - theString; 00326 } 00327 00328 00329 00336 inline unsigned int 00337 length(const char* theString) 00338 { 00339 assert(theString != 0); 00340 00341 return strlen(theString); 00342 } 00343 00344 00345 00352 inline bool 00353 isEmpty(const XalanDOMString& str) 00354 { 00355 return length(str) == 0 ? true : false; 00356 } 00357 00358 00359 00369 inline unsigned int 00370 indexOf( 00371 const XalanDOMChar* theString, 00372 XalanDOMChar theChar) 00373 { 00374 const XalanDOMChar* thePointer = theString; 00375 00376 while(*thePointer != theChar && *thePointer != 0) 00377 { 00378 ++thePointer; 00379 } 00380 00381 return thePointer - theString; 00382 } 00383 00384 00385 00395 inline unsigned int 00396 indexOf( 00397 const XalanDOMString& theString, 00398 XalanDOMChar theChar) 00399 { 00400 if (theString.length() == 0) 00401 { 00402 return 0; 00403 } 00404 else 00405 { 00406 return indexOf(c_wstr(theString), theChar); 00407 } 00408 } 00409 00410 00411 00421 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00422 indexOf( 00423 const XalanDOMChar* theString, 00424 const XalanDOMChar* theSubstring); 00425 00426 00436 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00437 indexOf( 00438 const XalanDOMString& theString, 00439 const XalanDOMString& theSubstring); 00440 00441 00442 00452 00453 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00454 lastIndexOf( 00455 const XalanDOMChar* theString, 00456 XalanDOMChar theChar); 00457 00458 00459 00469 inline unsigned int 00470 lastIndexOf( 00471 const XalanDOMString& theString, 00472 XalanDOMChar theChar) 00473 { 00474 return lastIndexOf(c_wstr(theString), theChar); 00475 } 00476 00477 00478 00486 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00487 startsWith( 00488 const XalanDOMChar* theString, 00489 const XalanDOMChar* theSubstring); 00490 00491 00492 00500 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00501 startsWith( 00502 const XalanDOMChar* theString, 00503 const XalanDOMString& theSubstring); 00504 00505 00506 00514 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00515 startsWith( 00516 const XalanDOMString& theString, 00517 const XalanDOMChar* theSubstring); 00518 00519 00520 00528 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00529 startsWith( 00530 const XalanDOMString& theString, 00531 const XalanDOMString& theSubstring); 00532 00533 00534 00542 inline bool 00543 startsWith( 00544 const XalanDOMString& theString, 00545 const char* theSubstring) 00546 { 00547 return startsWith( 00548 theString, 00549 XalanDOMString(theSubstring)); 00550 } 00551 00552 00553 00561 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00562 endsWith( 00563 const XalanDOMChar* theString, 00564 const XalanDOMChar* theSubstring); 00565 00566 00567 00575 inline bool 00576 endsWith( 00577 const XalanDOMString& theDOMString, 00578 const XalanDOMString& theSubstring) 00579 { 00580 return endsWith(c_wstr(theDOMString), c_wstr(theSubstring)); 00581 } 00582 00583 00584 00592 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00593 DoubleToDOMString( 00594 double theValue, 00595 XalanDOMString& theResult); 00596 00597 00598 00605 inline const XalanDOMString 00606 DoubleToDOMString(double theValue) 00607 { 00608 XalanDOMString theResult; 00609 00610 DoubleToDOMString(theValue, theResult); 00611 00612 return theResult; 00613 } 00614 00615 00616 00625 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00626 LongToHexDOMString( 00627 long theValue, 00628 XalanDOMString& theResult); 00629 00630 00631 00639 inline const XalanDOMString 00640 LongToHexDOMString(long theValue) 00641 { 00642 XalanDOMString theResult; 00643 00644 LongToHexDOMString(theValue, theResult); 00645 00646 return theResult; 00647 } 00648 00649 00650 00659 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00660 UnsignedLongToHexDOMString( 00661 unsigned long theValue, 00662 XalanDOMString& theResult); 00663 00664 00665 00673 inline const XalanDOMString 00674 UnsignedLongToHexDOMString(unsigned long theValue) 00675 { 00676 XalanDOMString theResult; 00677 00678 UnsignedLongToHexDOMString(theValue, theResult); 00679 00680 return theResult; 00681 } 00682 00683 00684 00692 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00693 LongToDOMString( 00694 long theValue, 00695 XalanDOMString& theResult); 00696 00697 00698 00705 inline const XalanDOMString 00706 LongToDOMString(long theValue) 00707 { 00708 XalanDOMString theResult; 00709 00710 LongToDOMString(theValue, theResult); 00711 00712 return theResult; 00713 } 00714 00715 00716 00725 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00726 UnsignedLongToDOMString( 00727 unsigned long theValue, 00728 XalanDOMString& theResult); 00729 00730 00731 00738 inline const XalanDOMString 00739 UnsignedLongToDOMString(unsigned long theValue) 00740 { 00741 XalanDOMString theResult; 00742 00743 UnsignedLongToDOMString(theValue, theResult); 00744 00745 return theResult; 00746 } 00747 00748 00749 00756 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00757 WideStringToInt(const XalanDOMChar* theString); 00758 00759 00760 00767 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00768 WideStringToLong(const XalanDOMChar* theString); 00769 00770 00771 00778 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00779 WideStringToUnsignedLong(const XalanDOMChar* theString); 00780 00781 00782 00789 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00790 WideStringToDouble(const XalanDOMChar* theString); 00791 00792 00793 00800 inline int 00801 DOMStringToInt(const XalanDOMString& theString) 00802 { 00803 return WideStringToInt(c_wstr(theString)); 00804 } 00805 00806 00807 00814 inline long 00815 DOMStringToLong(const XalanDOMString& theString) 00816 { 00817 return WideStringToLong(c_wstr(theString)); 00818 } 00819 00820 00821 00828 inline unsigned long 00829 DOMStringToUnsignedLong(const XalanDOMString& theString) 00830 { 00831 return WideStringToUnsignedLong(c_wstr(theString)); 00832 } 00833 00834 00835 00842 inline double 00843 DOMStringToDouble(const XalanDOMString& theString) 00844 { 00845 return WideStringToDouble(c_wstr(theString)); 00846 } 00847 00848 00849 00857 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00858 OutputString( 00859 XalanOutputStream& theStream, 00860 const CharVectorType& theString); 00861 00862 00863 00871 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00872 OutputString( 00873 #if defined(XALAN_NO_NAMESPACES) 00874 ostream& theStream, 00875 #else 00876 std::ostream& theStream, 00877 #endif 00878 const CharVectorType& theString); 00879 00880 00881 00889 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00890 OutputString( 00891 XalanOutputStream& theStream, 00892 const XalanDOMChar* theString); 00893 00894 00895 00903 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00904 OutputString( 00905 #if defined(XALAN_NO_NAMESPACES) 00906 ostream& theStream, 00907 #else 00908 std::ostream& theStream, 00909 #endif 00910 const XalanDOMChar* theString); 00911 00912 00913 00921 inline void 00922 OutputString( 00923 XalanOutputStream& theStream, 00924 const XalanDOMString& theString) 00925 { 00926 if (isEmpty(theString) == false) 00927 { 00928 OutputString(theStream, c_wstr(theString)); 00929 } 00930 } 00931 00932 00933 00941 inline void 00942 OutputString( 00943 #if defined(XALAN_NO_NAMESPACES) 00944 ostream& theStream, 00945 #else 00946 std::ostream& theStream, 00947 #endif 00948 const XalanDOMString& theString) 00949 { 00950 OutputString(theStream, c_wstr(theString)); 00951 } 00952 00953 00954 00962 inline XalanOutputStream& 00963 operator<<( 00964 XalanOutputStream& theStream, 00965 const CharVectorType& theString) 00966 { 00967 OutputString(theStream, theString); 00968 00969 return theStream; 00970 } 00971 00972 00973 00981 #if defined(XALAN_NO_NAMESPACES) 00982 inline ostream& 00983 operator<<( 00984 ostream& theStream, 00985 #else 00986 inline std::ostream& 00987 operator<<( 00988 std::ostream& theStream, 00989 #endif 00990 const CharVectorType& theString) 00991 { 00992 OutputString(theStream, theString); 00993 00994 return theStream; 00995 } 00996 00997 00998 01006 inline XalanOutputStream& 01007 operator<<( 01008 XalanOutputStream& theStream, 01009 const XalanDOMChar* theString) 01010 { 01011 OutputString(theStream, 01012 theString); 01013 01014 return theStream; 01015 } 01016 01017 01018 01026 #if defined(XALAN_NO_NAMESPACES) 01027 inline ostream& 01028 operator<<( 01029 ostream& theStream, 01030 #else 01031 inline std::ostream& 01032 operator<<( 01033 std::ostream& theStream, 01034 #endif 01035 const XalanDOMChar* theString) 01036 { 01037 OutputString(theStream, 01038 theString); 01039 01040 return theStream; 01041 } 01042 01043 01044 01052 inline XalanOutputStream& 01053 operator<<( 01054 XalanOutputStream& theStream, 01055 const XalanDOMString& theString) 01056 { 01057 OutputString(theStream, 01058 theString); 01059 01060 return theStream; 01061 } 01062 01063 01064 01072 #if defined(XALAN_NO_NAMESPACES) 01073 inline ostream& 01074 operator<<( 01075 ostream& theStream, 01076 #else 01077 inline std::ostream& 01078 operator<<( 01079 std::ostream& theStream, 01080 #endif 01081 const XalanDOMString& theString) 01082 { 01083 OutputString(theStream, 01084 theString); 01085 01086 return theStream; 01087 } 01088 01089 01090 01098 inline XalanDOMChar 01099 charAt( 01100 const XalanDOMString& theString, 01101 unsigned int theIndex) 01102 { 01103 return theString[theIndex]; 01104 } 01105 01106 01107 01114 inline bool 01115 isXMLWhitespace(XalanDOMChar theChar) 01116 { 01117 return XalanXMLChar::isWhitespace(theChar); 01118 } 01119 01120 01121 01128 inline bool 01129 isXMLDigit(XalanDOMChar theChar) 01130 { 01131 return XalanXMLChar::isDigit(theChar); 01132 } 01133 01134 01135 01142 inline bool 01143 isXMLLetterOrDigit(XalanDOMChar theChar) 01144 { 01145 return XalanXMLChar::isDigit(theChar) || 01146 XalanXMLChar::isLetter(theChar); 01147 } 01148 01149 01150 01162 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01163 substring( 01164 const XalanDOMChar* theString, 01165 unsigned int theStartIndex, 01166 unsigned int theEndIndex = unsigned(-1)); 01167 01168 01169 01181 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01182 substring( 01183 const XalanDOMString& theString, 01184 unsigned int theStartIndex, 01185 unsigned int theEndIndex = unsigned(-1)); 01186 01187 01188 01196 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01197 toLowerCase(const XalanDOMChar* theString); 01198 01199 01200 01208 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01209 toLowerCase(const XalanDOMString& theString); 01210 01211 01212 01220 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01221 toUpperCase(const XalanDOMChar* theString); 01222 01223 01224 01232 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01233 toUpperCase(const XalanDOMString& theString); 01234 01235 01236 01245 inline XalanDOMChar 01246 toLowerASCII(XalanDOMChar theChar) 01247 { 01248 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01249 { 01250 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01251 } 01252 else 01253 { 01254 return theChar; 01255 } 01256 } 01257 01258 01259 01268 inline XalanDOMChar 01269 toUpperASCII(XalanDOMChar theChar) 01270 { 01271 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01272 { 01273 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01274 } 01275 else 01276 { 01277 return theChar; 01278 } 01279 } 01280 01281 01282 01291 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01292 toLowerCaseASCII(const XalanDOMChar* theString); 01293 01294 01295 01304 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01305 toLowerCaseASCII(const XalanDOMString& theString); 01306 01307 01308 01317 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01318 toUpperCaseASCII(const XalanDOMChar* theString); 01319 01320 01321 01330 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01331 toUpperCaseASCII(const XalanDOMString& theString); 01332 01333 01334 01347 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01348 compare( 01349 const CharVectorType& theLHS, 01350 const CharVectorType& theRHS); 01351 01352 01353 01367 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01368 compare( 01369 const XalanDOMChar* theLHS, 01370 unsigned int theLHSLength, 01371 const XalanDOMChar* theRHS, 01372 unsigned int theRHSLength); 01373 01374 01375 01387 inline int 01388 compare( 01389 const XalanDOMChar* theLHS, 01390 const XalanDOMChar* theRHS) 01391 { 01392 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01393 } 01394 01395 01396 01407 inline int 01408 compare( 01409 const XalanDOMString& theLHS, 01410 const XalanDOMString& theRHS) 01411 { 01412 return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01413 } 01414 01415 01416 01428 inline int 01429 compare( 01430 const XalanDOMChar* theLHS, 01431 const XalanDOMString& theRHS) 01432 { 01433 return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01434 } 01435 01436 01437 01449 inline int 01450 compare( 01451 const XalanDOMString& theLHS, 01452 const XalanDOMChar* theRHS) 01453 { 01454 return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01455 } 01456 01457 01458 01473 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01474 compareIgnoreCase( 01475 const XalanDOMChar* theLHS, 01476 unsigned int theLHSLength, 01477 const XalanDOMChar* theRHS, 01478 unsigned int theRHSLength); 01479 01480 01481 01494 inline int 01495 compareIgnoreCase( 01496 const XalanDOMChar* theLHS, 01497 const XalanDOMChar* theRHS) 01498 { 01499 return compareIgnoreCase(theLHS, length(theLHS), theRHS, length(theRHS)); 01500 } 01501 01502 01503 01515 inline int 01516 compareIgnoreCase( 01517 const XalanDOMString& theLHS, 01518 const XalanDOMString& theRHS) 01519 { 01520 return compareIgnoreCase(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01521 } 01522 01523 01524 01537 inline int 01538 compareIgnoreCase( 01539 const XalanDOMChar* theLHS, 01540 const XalanDOMString& theRHS) 01541 { 01542 return compareIgnoreCase(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01543 } 01544 01545 01546 01559 inline int 01560 compareIgnoreCase( 01561 const XalanDOMString& theLHS, 01562 const XalanDOMChar* theRHS) 01563 { 01564 return compareIgnoreCase(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01565 } 01566 01567 01568 01581 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01582 compareIgnoreCaseASCII( 01583 const XalanDOMChar* theLHS, 01584 unsigned int theLHSLength, 01585 const XalanDOMChar* theRHS, 01586 unsigned int theRHSLength); 01587 01588 01589 01600 inline int 01601 compareIgnoreCaseASCII( 01602 const XalanDOMChar* theLHS, 01603 const XalanDOMChar* theRHS) 01604 { 01605 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01606 } 01607 01608 01609 01622 inline int 01623 compareIgnoreCaseASCII( 01624 const XalanDOMString& theLHS, 01625 const XalanDOMString& theRHS) 01626 { 01627 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01628 } 01629 01630 01631 01645 inline int 01646 compareIgnoreCaseASCII( 01647 const XalanDOMString& theLHS, 01648 const XalanDOMChar* theRHS) 01649 { 01650 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01651 } 01652 01653 01654 01668 inline int 01669 compareIgnoreCaseASCII( 01670 const XalanDOMChar* theLHS, 01671 const XalanDOMString& theRHS) 01672 { 01673 return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01674 } 01675 01676 01677 01688 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01689 collationCompare( 01690 const XalanDOMChar* theLHS, 01691 unsigned int theLHSLength, 01692 const XalanDOMChar* theRHS, 01693 unsigned int theRHSLength); 01694 01695 01696 01707 inline int 01708 collationCompare( 01709 const XalanDOMChar* theLHS, 01710 const XalanDOMChar* theRHS) 01711 { 01712 return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS)); 01713 } 01714 01715 01716 01727 inline int 01728 collationCompare( 01729 const XalanDOMString& theLHS, 01730 const XalanDOMString& theRHS) 01731 { 01732 return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01733 } 01734 01735 01736 01745 inline int 01746 collationCompare( 01747 const XalanDOMChar* theLHS, 01748 const XalanDOMString& theRHS) 01749 { 01750 return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01751 } 01752 01753 01754 01763 inline int 01764 collationCompare( 01765 const XalanDOMString& theLHS, 01766 const XalanDOMChar* theRHS) 01767 { 01768 return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01769 } 01770 01771 01772 01781 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01782 equals( 01783 const XalanDOMChar* theLHS, 01784 const XalanDOMChar* theRHS, 01785 unsigned int theLength); 01786 01787 01788 01796 inline bool 01797 equals( 01798 const XalanDOMChar* theLHS, 01799 const XalanDOMChar* theRHS) 01800 { 01801 const unsigned int theLHSLength = length(theLHS); 01802 01803 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 01804 } 01805 01806 01807 01815 inline bool 01816 equals( 01817 const XalanDOMString& theLHS, 01818 const XalanDOMString& theRHS) 01819 { 01820 return theLHS == theRHS; 01821 } 01822 01823 01824 01832 inline bool 01833 equals( 01834 const XalanDOMChar* theLHS, 01835 const XalanDOMString& theRHS) 01836 { 01837 assert(theLHS != 0); 01838 01839 // Swap them... 01840 return theRHS == theLHS; 01841 } 01842 01843 01844 01852 inline bool 01853 equals(const XalanDOMString& theLHS, 01854 const XalanDOMChar* theRHS) 01855 { 01856 return equals(theRHS, theLHS); 01857 } 01858 01859 01860 01868 inline bool 01869 equals(const XalanDOMString& theLHS, 01870 const char* theRHS) 01871 { 01872 assert(theRHS != 0); 01873 01874 const unsigned int theRHSLength = length(theRHS); 01875 01876 if (theRHSLength != length(theLHS)) 01877 { 01878 return false; 01879 } 01880 else 01881 { 01882 return theLHS == XalanDOMString(theRHS, theRHSLength); 01883 } 01884 } 01885 01886 01887 01895 inline bool 01896 equals(const char* theLHS, 01897 const XalanDOMString& theRHS) 01898 { 01899 return equals(theRHS, theLHS); 01900 } 01901 01902 01903 01911 inline bool 01912 equals(const XalanDOMChar* theLHS, 01913 const char* theRHS) 01914 { 01915 assert(theLHS != 0); 01916 assert(theRHS != 0); 01917 01918 const unsigned int theRHSLength = length(theRHS); 01919 01920 if (theRHSLength != length(theLHS)) 01921 { 01922 return false; 01923 } 01924 else 01925 { 01926 return equals(XalanDOMString(theRHS, theRHSLength), theLHS); 01927 } 01928 } 01929 01930 01931 01939 inline bool 01940 equals(const char* theLHS, 01941 const XalanDOMChar* theRHS) 01942 { 01943 return equals(theRHS, theLHS); 01944 } 01945 01946 01947 01956 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01957 equalsIgnoreCase( 01958 const XalanDOMChar* theLHS, 01959 const XalanDOMChar* theRHS, 01960 unsigned int theLength); 01961 01962 01963 01971 inline bool 01972 equalsIgnoreCase( 01973 const XalanDOMChar* theLHS, 01974 const XalanDOMChar* theRHS) 01975 { 01976 const unsigned int theLength = length(theLHS); 01977 01978 return theLength != length(theRHS) ? false : equalsIgnoreCase(theLHS, theRHS, theLength); 01979 } 01980 01981 01982 01990 inline bool 01991 equalsIgnoreCase( 01992 const XalanDOMString& theLHS, 01993 const XalanDOMString& theRHS) 01994 { 01995 const unsigned int theLHSLength = length(theLHS); 01996 01997 return theLHSLength != length(theRHS) ? false : 01998 equalsIgnoreCase(toCharArray(theLHS), toCharArray(theRHS), theLHSLength); 01999 } 02000 02001 02002 02010 inline bool 02011 equalsIgnoreCase( 02012 const XalanDOMChar* theLHS, 02013 const XalanDOMString& theRHS) 02014 { 02015 const unsigned int theRHSLength = length(theRHS); 02016 02017 return theRHSLength != length(theLHS) ? false : 02018 equalsIgnoreCase(theLHS, toCharArray(theRHS), theRHSLength); 02019 } 02020 02021 02022 02030 inline bool 02031 equalsIgnoreCase( 02032 const XalanDOMString& theLHS, 02033 const XalanDOMChar* theRHS) 02034 { 02035 return equalsIgnoreCase(theRHS, theLHS); 02036 } 02037 02038 02039 02048 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02049 equalsIgnoreCaseASCII( 02050 const XalanDOMChar* theLHS, 02051 const XalanDOMChar* theRHS, 02052 unsigned int theLength); 02053 02054 02055 02064 inline bool 02065 equalsIgnoreCaseASCII( 02066 const XalanDOMChar* theLHS, 02067 const XalanDOMChar* theRHS) 02068 { 02069 const unsigned int theLength = length(theLHS); 02070 02071 return theLength != length(theRHS) ? false : 02072 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 02073 } 02074 02075 02076 02085 inline bool 02086 equalsIgnoreCaseASCII( 02087 const XalanDOMString& theLHS, 02088 const XalanDOMString& theRHS) 02089 { 02090 const unsigned int theLength = length(theLHS); 02091 02092 return theLength != length(theRHS) ? false : 02093 equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength); 02094 } 02095 02096 02097 02106 inline bool 02107 equalsIgnoreCaseASCII( 02108 const XalanDOMChar* theLHS, 02109 const XalanDOMString& theRHS) 02110 { 02111 const unsigned int theRHSLength = length(theRHS); 02112 02113 return theRHSLength != length(theLHS) ? false : 02114 equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength); 02115 } 02116 02117 02118 02127 inline bool 02128 equalsIgnoreCaseASCII( 02129 const XalanDOMString& theLHS, 02130 const XalanDOMChar* theRHS) 02131 { 02132 return equalsIgnoreCaseASCII(theRHS, theLHS); 02133 } 02134 02135 02136 02146 inline bool 02147 operator<( 02148 const CharVectorType& theLHS, 02149 const CharVectorType& theRHS) 02150 { 02151 return compare(theLHS, theRHS) < 0 ? true : false; 02152 } 02153 02154 02155 02165 inline bool 02166 operator<( 02167 const XalanDOMString& theLHS, 02168 const XalanDOMString& theRHS) 02169 { 02170 return compare(theLHS, theRHS) < 0 ? true : false; 02171 } 02172 02173 02174 02183 inline XalanDOMString& 02184 assign( 02185 XalanDOMString& theString, 02186 const XalanDOMString& theStringToAssign) 02187 { 02188 theString = theStringToAssign; 02189 02190 return theString; 02191 } 02192 02193 02194 02203 inline XalanDOMString& 02204 assign( 02205 XalanDOMString& theString, 02206 const XalanDOMChar* theStringToAssign, 02207 unsigned int theStringToAssignLength = unsigned(-1)) 02208 { 02209 if (theStringToAssignLength == unsigned(-1)) 02210 { 02211 theString.assign(theStringToAssign); 02212 } 02213 else 02214 { 02215 theString.assign(theStringToAssign, theStringToAssignLength); 02216 } 02217 02218 return theString; 02219 } 02220 02221 02222 02230 inline XalanDOMString& 02231 append( 02232 XalanDOMString& theString, 02233 const XalanDOMString& theStringToAppend) 02234 { 02235 theString.append(theStringToAppend); 02236 02237 return theString; 02238 } 02239 02240 02241 02250 inline XalanDOMString& 02251 append( 02252 XalanDOMString& theString, 02253 const XalanDOMChar* theStringToAppend, 02254 unsigned int theStringToAppendLength = unsigned(-1)) 02255 { 02256 assert(theStringToAppend != 0); 02257 02258 if (theStringToAppendLength == unsigned(-1)) 02259 { 02260 theString.append(theStringToAppend); 02261 } 02262 else 02263 { 02264 theString.append(theStringToAppend, theStringToAppendLength); 02265 } 02266 02267 return theString; 02268 } 02269 02270 02271 02280 inline XalanDOMString& 02281 append( 02282 XalanDOMString& theString, 02283 const char* theStringToAppend, 02284 unsigned int theStringToAppendLength = unsigned(-1)) 02285 { 02286 theString.append(TranscodeFromLocalCodePage(theStringToAppend, theStringToAppendLength)); 02287 02288 return theString; 02289 } 02290 02291 02292 02300 inline XalanDOMString& 02301 append( 02302 XalanDOMString& theString, 02303 const XalanDOMChar theCharToAppend) 02304 { 02305 theString.append(1, theCharToAppend); 02306 02307 return theString; 02308 } 02309 02310 02311 02319 inline XalanDOMString& 02320 append( 02321 XalanDOMString& theString, 02322 char theCharToAppend) 02323 { 02324 // We have to transcode before appending... 02325 char theTempBuffer[] = { theCharToAppend, '\0' }; 02326 02327 return append(theString, theTempBuffer); 02328 } 02329 02330 02331 02340 inline XalanDOMString& 02341 insert( 02342 XalanDOMString& theString, 02343 unsigned int thePosition, 02344 const XalanDOMString& theStringToInsert) 02345 { 02346 theString.insert(thePosition, theStringToInsert); 02347 02348 return theString; 02349 } 02350 02351 02352 02361 inline XalanDOMString& 02362 insert( 02363 XalanDOMString& theString, 02364 unsigned int thePosition, 02365 const XalanDOMChar* theStringToInsert) 02366 { 02367 theString.insert(thePosition, theStringToInsert); 02368 02369 return theString; 02370 } 02371 02372 02373 02380 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 02381 trim(const XalanDOMString& theString); 02382 02383 02384 02390 inline void 02391 clear(XalanDOMString& theString) 02392 { 02393 theString.clear(); 02394 } 02395 02396 02397 02403 inline void 02404 erase(XalanDOMString& theString) 02405 { 02406 theString.erase(); 02407 } 02408 02409 02410 02417 inline void 02418 releaseMemory(XalanDOMString& theString) 02419 { 02420 XalanDOMString().swap(theString); 02421 } 02422 02423 02424 02425 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02426 CopyWideStringToVector( 02427 const XalanDOMChar* theString, 02428 CharVectorType& theVector); 02429 02430 02431 02432 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02433 CopyStringToVector( 02434 const char* theString, 02435 CharVectorType& theVector); 02436 02437 02438 02447 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02448 MakeXalanDOMCharVector( 02449 const char* data, 02450 bool fTranscode = true); 02451 02452 02453 02461 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02462 MakeXalanDOMCharVector(const XalanDOMChar* data); 02463 02464 02465 02473 inline XalanDOMCharVectorType 02474 MakeXalanDOMCharVector(const XalanDOMString& data) 02475 { 02476 return MakeXalanDOMCharVector(c_wstr(data)); 02477 } 02478 02479 02480 02481 #if defined(XALAN_NO_NAMESPACES) 02482 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02483 #else 02484 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02485 #endif 02486 { 02487 result_type 02488 operator() (const argument_type& theString) const 02489 { 02490 return c_wstr(theString); 02491 } 02492 }; 02493 02494 02495 02502 #if defined(XALAN_NO_NAMESPACES) 02503 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 02504 #else 02505 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 02506 #endif 02507 { 02508 result_type 02509 operator() (argument_type theKey) const 02510 { 02511 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 02512 02513 unsigned long theHashValue = 0L; 02514 02515 if (theRawBuffer != 0) 02516 { 02517 while (*theRawBuffer) 02518 { 02519 theHashValue = 5 * theHashValue + *theRawBuffer; 02520 02521 theRawBuffer++; 02522 } 02523 } 02524 02525 return result_type(theHashValue++); 02526 } 02527 }; 02528 02529 02530 02538 #if defined(XALAN_NO_NAMESPACES) 02539 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02540 #else 02541 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02542 #endif 02543 { 02544 result_type 02545 operator() (first_argument_type theLHS, 02546 second_argument_type theRHS) const 02547 { 02548 return equals(theLHS, theRHS); 02549 } 02550 }; 02551 02552 02553 02561 #if defined(XALAN_NO_NAMESPACES) 02562 struct DOMStringEqualsIgnoreCaseFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02563 #else 02564 struct DOMStringEqualsIgnoreCaseFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02565 #endif 02566 { 02567 result_type 02568 operator() (first_argument_type theLHS, 02569 second_argument_type theRHS) const 02570 { 02571 return equalsIgnoreCase(theLHS, theRHS); 02572 } 02573 }; 02574 02575 02576 02584 #if defined(XALAN_NO_NAMESPACES) 02585 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02586 #else 02587 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02588 #endif 02589 { 02590 result_type 02591 operator() (first_argument_type theLHS, 02592 second_argument_type theRHS) const 02593 { 02594 return !equals(theLHS, theRHS); 02595 } 02596 }; 02597 02598 02599 02607 #if defined(XALAN_NO_NAMESPACES) 02608 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02609 #else 02610 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02611 #endif 02612 { 02613 result_type 02614 operator() (first_argument_type theLHS, 02615 second_argument_type theRHS) const 02616 { 02617 return compare(theLHS, theRHS) < 0 ? true : false; 02618 } 02619 }; 02620 02621 02622 02630 #if defined(XALAN_NO_NAMESPACES) 02631 struct DOMStringLessThanIgnoreCaseFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02632 #else 02633 struct DOMStringLessThanIgnoreCaseFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02634 #endif 02635 { 02636 result_type 02637 operator() (first_argument_type theLHS, 02638 second_argument_type theRHS) const 02639 { 02640 return compareIgnoreCase(theLHS, theRHS) < 0 ? true : false; 02641 } 02642 }; 02643 02644 02645 02653 #if defined(XALAN_NO_NAMESPACES) 02654 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02655 #else 02656 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02657 #endif 02658 { 02659 result_type 02660 operator() (first_argument_type theLHS, 02661 second_argument_type theRHS) const 02662 { 02663 return compareIgnoreCase(theLHS, theRHS) < 0 ? true : false; 02664 } 02665 }; 02666 02667 02668 02676 #if defined(XALAN_NO_NAMESPACES) 02677 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02678 #else 02679 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02680 #endif 02681 { 02682 result_type 02683 operator() (first_argument_type theLHS, 02684 second_argument_type theRHS) const 02685 { 02686 return compare(theLHS, theRHS) <= 0 ? true : false; 02687 } 02688 }; 02689 02690 02691 02699 #if defined(XALAN_NO_NAMESPACES) 02700 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02701 #else 02702 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02703 #endif 02704 { 02705 result_type 02706 operator() (first_argument_type theLHS, 02707 second_argument_type theRHS) const 02708 { 02709 return compare(theLHS, theRHS) > 0 ? true : false; 02710 } 02711 }; 02712 02713 02714 02722 #if defined(XALAN_NO_NAMESPACES) 02723 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02724 #else 02725 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02726 #endif 02727 { 02728 result_type 02729 operator() (first_argument_type theLHS, 02730 second_argument_type theRHS) const 02731 { 02732 return compare(theLHS, theRHS) >= 0 ? true : false; 02733 } 02734 }; 02735 02736 02737 02743 #if defined(XALAN_NO_NAMESPACES) 02744 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02745 #else 02746 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02747 #endif 02748 { 02757 result_type 02758 operator()( 02759 first_argument_type theLHS, 02760 second_argument_type theRHS) const 02761 { 02762 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02763 } 02764 }; 02765 02766 02767 02774 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02775 isXMLWhitespace(const XalanDOMString& string); 02776 02777 02778 02787 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02788 isXMLWhitespace( 02789 const XalanDOMChar ch[], 02790 unsigned int start, 02791 unsigned int length); 02792 02793 02794 02801 inline bool 02802 isXMLWhitespace(const XalanDOMChar* theString) 02803 { 02804 assert(theString != 0); 02805 02806 return isXMLWhitespace(theString, 0, length(theString)); 02807 } 02808 02809 02810 02811 #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 |
|