00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-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(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_OLD_STREAMS) 00070 class ostream; 00071 #else 00072 #include <iosfwd> 00073 #endif 00074 #include <vector> 00075 00076 00077 00078 #include <XalanDOM/XalanDOMString.hpp> 00079 00080 00081 00082 #include <PlatformSupport/XalanUnicode.hpp> 00083 #include <PlatformSupport/XalanXMLChar.hpp> 00084 00085 00086 00087 class XalanOutputStream; 00088 00089 00090 00091 // This macro has been defined to deal with certain C++ compilers which 00092 // do not create Unicode strings when the "L" string constant prefix is 00093 // used. It is meant _only_ for use with static strings. 00094 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) 00095 00096 #define XALAN_STATIC_UCODE_STRING(str) L##str 00097 00108 inline const XalanDOMString 00109 StaticStringToDOMString(const XalanDOMChar* theString) 00110 { 00111 return XalanDOMString(theString); 00112 } 00113 00114 #else 00115 00116 #define XALAN_STATIC_UCODE_STRING(str) TranscodeFromLocalCodePage(str) 00117 00126 inline const XalanDOMString& 00127 StaticStringToDOMString(const XalanDOMString& theString) 00128 { 00129 return theString; 00130 } 00131 00132 #endif 00133 00134 00135 00143 inline const XalanDOMChar* 00144 c_wstr(const XalanDOMString& theString) 00145 { 00146 return theString.c_str(); 00147 } 00148 00149 00150 00158 inline const char* 00159 c_str(const CharVectorType& theString) 00160 { 00161 if (theString.empty() == true) 00162 { 00163 return 0; 00164 } 00165 else 00166 { 00167 const char* const ptr = &theString[0]; 00168 00169 assert(ptr[theString.size() - 1] == '\0'); 00170 00171 return ptr; 00172 } 00173 } 00174 00175 00176 00192 inline const XalanDOMChar* 00193 c_wstr(const XalanDOMChar* theString) 00194 { 00195 return theString; 00196 } 00197 00198 00199 00207 inline const XalanDOMChar* 00208 toCharArray(const XalanDOMString& theString) 00209 { 00210 return theString.c_str(); 00211 } 00212 00213 00214 00221 inline const XalanDOMChar* 00222 toCharArray(const XalanDOMChar* theString) 00223 { 00224 return theString; 00225 } 00226 00227 00228 00236 inline const char* 00237 toCharArray(const CharVectorType& theString) 00238 { 00239 return theString.empty() == true ? 0 : &theString[0]; 00240 } 00241 00242 00243 00251 inline void 00252 reserve( 00253 XalanDOMString& theString, 00254 XalanDOMString::size_type theCount) 00255 { 00256 theString.reserve(theCount); 00257 } 00258 00259 00260 00267 inline XalanDOMString::size_type 00268 length(const XalanDOMString& theString) 00269 { 00270 return theString.length(); 00271 } 00272 00273 00274 00282 inline XalanDOMString::size_type 00283 length(const XalanDOMChar* theString) 00284 { 00285 assert(theString != 0); 00286 00287 const XalanDOMChar* theBufferPointer = theString; 00288 00289 while(*theBufferPointer != 0) 00290 { 00291 theBufferPointer++; 00292 } 00293 00294 return XalanDOMString::size_type(theBufferPointer - theString); 00295 } 00296 00297 00298 00305 inline XalanDOMString::size_type 00306 length(const char* theString) 00307 { 00308 assert(theString != 0); 00309 00310 return XalanDOMString::length(theString); 00311 } 00312 00313 00314 00321 inline bool 00322 isEmpty(const XalanDOMString& str) 00323 { 00324 return str.empty(); 00325 } 00326 00327 00328 00338 inline XalanDOMString::size_type 00339 indexOf( 00340 const XalanDOMChar* theString, 00341 XalanDOMChar theChar) 00342 { 00343 assert(theString != 0); 00344 00345 const XalanDOMChar* thePointer = theString; 00346 00347 while(*thePointer != theChar && *thePointer != 0) 00348 { 00349 ++thePointer; 00350 } 00351 00352 return XalanDOMString::size_type(thePointer - theString); 00353 } 00354 00355 00356 00367 inline XalanDOMString::size_type 00368 indexOf( 00369 const XalanDOMChar* theString, 00370 XalanDOMString::size_type theStringLength, 00371 XalanDOMChar theChar) 00372 { 00373 assert(theString != 0); 00374 00375 const XalanDOMChar* thePointer = theString; 00376 const XalanDOMChar* const theEndPointer = theString + theStringLength; 00377 00378 while(*thePointer != theChar && thePointer != theEndPointer) 00379 { 00380 ++thePointer; 00381 } 00382 00383 return XalanDOMString::size_type(thePointer - theString); 00384 } 00385 00386 00387 00397 inline XalanDOMString::size_type 00398 indexOf( 00399 const XalanDOMString& theString, 00400 XalanDOMChar theChar) 00401 { 00402 return length(theString) == 0 ? 0 : indexOf(c_wstr(theString), theChar); 00403 } 00404 00405 00406 00416 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00417 indexOf( 00418 const XalanDOMChar* theString, 00419 const XalanDOMChar* theSubstring); 00420 00421 00431 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00432 indexOf( 00433 const XalanDOMString& theString, 00434 const XalanDOMString& theSubstring); 00435 00436 00437 00447 00448 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00449 lastIndexOf( 00450 const XalanDOMChar* theString, 00451 XalanDOMChar theChar); 00452 00453 00454 00464 inline XalanDOMString::size_type 00465 lastIndexOf( 00466 const XalanDOMString& theString, 00467 XalanDOMChar theChar) 00468 { 00469 return lastIndexOf(c_wstr(theString), theChar); 00470 } 00471 00472 00473 00481 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00482 startsWith( 00483 const XalanDOMChar* theString, 00484 XalanDOMString::size_type theStringLength, 00485 const XalanDOMChar* theSubstring, 00486 XalanDOMString::size_type theSubstringLength); 00487 00488 00489 00497 inline bool 00498 startsWith( 00499 const XalanDOMChar* theString, 00500 const XalanDOMChar* theSubstring) 00501 { 00502 assert(theString != 0 && theSubstring != 0); 00503 00504 return startsWith(theString, length(theString), theSubstring, length(theSubstring)); 00505 } 00506 00507 00508 00516 inline bool 00517 startsWith( 00518 const XalanDOMChar* theString, 00519 const XalanDOMString& theSubstring) 00520 { 00521 assert(theString != 0); 00522 00523 return startsWith(theString, length(theString), c_wstr(theSubstring), length(theSubstring)); 00524 } 00525 00526 00527 00535 inline bool 00536 startsWith( 00537 const XalanDOMString& theString, 00538 const XalanDOMChar* theSubstring) 00539 { 00540 assert(theSubstring != 0); 00541 00542 return startsWith(c_wstr(theString), length(theString), theSubstring, length(theSubstring)); 00543 } 00544 00545 00546 00554 inline bool 00555 startsWith( 00556 const XalanDOMString& theString, 00557 const XalanDOMString& theSubstring) 00558 { 00559 return startsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring)); 00560 } 00561 00562 00563 00571 inline bool 00572 startsWith( 00573 const XalanDOMString& theString, 00574 const char* theSubstring) 00575 { 00576 return startsWith( 00577 theString, 00578 XalanDOMString(theSubstring)); 00579 } 00580 00581 00582 00590 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00591 endsWith( 00592 const XalanDOMChar* theString, 00593 XalanDOMString::size_type theStringLength, 00594 const XalanDOMChar* theSubstring, 00595 XalanDOMString::size_type theSubstringLength); 00596 00597 00598 00606 inline bool 00607 endsWith( 00608 const XalanDOMChar* theString, 00609 const XalanDOMChar* theSubstring) 00610 { 00611 assert(theString != 0 && theSubstring != 0); 00612 00613 return endsWith(theString, length(theString), theSubstring, length(theSubstring)); 00614 } 00615 00616 00617 00625 inline bool 00626 endsWith( 00627 const XalanDOMString& theString, 00628 const XalanDOMString& theSubstring) 00629 { 00630 return endsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring)); 00631 } 00632 00633 00634 00642 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00643 PointerToDOMString( 00644 const void* theValue, 00645 XalanDOMString& theResult); 00646 00647 00648 00655 inline const XalanDOMString 00656 PointerToDOMString(const void* theValue) 00657 { 00658 XalanDOMString theResult; 00659 00660 PointerToDOMString(theValue, theResult); 00661 00662 return theResult; 00663 } 00664 00665 00666 00674 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00675 DoubleToDOMString( 00676 double theValue, 00677 XalanDOMString& theResult); 00678 00679 00680 00687 inline const XalanDOMString 00688 DoubleToDOMString(double theValue) 00689 { 00690 XalanDOMString theResult; 00691 00692 DoubleToDOMString(theValue, theResult); 00693 00694 return theResult; 00695 } 00696 00697 00698 00707 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00708 LongToHexDOMString( 00709 long theValue, 00710 XalanDOMString& theResult); 00711 00712 00713 00721 inline const XalanDOMString 00722 LongToHexDOMString(long theValue) 00723 { 00724 XalanDOMString theResult; 00725 00726 LongToHexDOMString(theValue, theResult); 00727 00728 return theResult; 00729 } 00730 00731 00732 00741 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00742 UnsignedLongToHexDOMString( 00743 unsigned long theValue, 00744 XalanDOMString& theResult); 00745 00746 00747 00755 inline const XalanDOMString 00756 UnsignedLongToHexDOMString(unsigned long theValue) 00757 { 00758 XalanDOMString theResult; 00759 00760 UnsignedLongToHexDOMString(theValue, theResult); 00761 00762 return theResult; 00763 } 00764 00765 00766 00774 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00775 LongToDOMString( 00776 long theValue, 00777 XalanDOMString& theResult); 00778 00779 00780 00787 inline const XalanDOMString 00788 LongToDOMString(long theValue) 00789 { 00790 XalanDOMString theResult; 00791 00792 LongToDOMString(theValue, theResult); 00793 00794 return theResult; 00795 } 00796 00797 00798 00807 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00808 UnsignedLongToDOMString( 00809 unsigned long theValue, 00810 XalanDOMString& theResult); 00811 00812 00813 00820 inline const XalanDOMString 00821 UnsignedLongToDOMString(unsigned long theValue) 00822 { 00823 XalanDOMString theResult; 00824 00825 UnsignedLongToDOMString(theValue, theResult); 00826 00827 return theResult; 00828 } 00829 00830 00831 00838 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00839 WideStringToInt(const XalanDOMChar* theString); 00840 00841 00842 00849 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00850 WideStringToLong(const XalanDOMChar* theString); 00851 00852 00853 00860 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00861 WideStringToUnsignedLong(const XalanDOMChar* theString); 00862 00863 00864 00871 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00872 WideStringToDouble(const XalanDOMChar* theString); 00873 00874 00875 00882 inline int 00883 DOMStringToInt(const XalanDOMString& theString) 00884 { 00885 return WideStringToInt(c_wstr(theString)); 00886 } 00887 00888 00889 00896 inline long 00897 DOMStringToLong(const XalanDOMString& theString) 00898 { 00899 return WideStringToLong(c_wstr(theString)); 00900 } 00901 00902 00903 00910 inline unsigned long 00911 DOMStringToUnsignedLong(const XalanDOMString& theString) 00912 { 00913 return WideStringToUnsignedLong(c_wstr(theString)); 00914 } 00915 00916 00917 00924 inline double 00925 DOMStringToDouble(const XalanDOMString& theString) 00926 { 00927 return WideStringToDouble(c_wstr(theString)); 00928 } 00929 00930 00931 00939 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00940 OutputString( 00941 XalanOutputStream& theStream, 00942 const CharVectorType& theString); 00943 00944 00945 00953 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00954 OutputString( 00955 #if defined(XALAN_NO_NAMESPACES) 00956 ostream& theStream, 00957 #else 00958 std::ostream& theStream, 00959 #endif 00960 const CharVectorType& theString); 00961 00962 00963 00971 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00972 OutputString( 00973 XalanOutputStream& theStream, 00974 const XalanDOMChar* theString); 00975 00976 00977 00985 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00986 OutputString( 00987 #if defined(XALAN_NO_NAMESPACES) 00988 ostream& theStream, 00989 #else 00990 std::ostream& theStream, 00991 #endif 00992 const XalanDOMChar* theString); 00993 00994 00995 01003 inline void 01004 OutputString( 01005 XalanOutputStream& theStream, 01006 const XalanDOMString& theString) 01007 { 01008 if (isEmpty(theString) == false) 01009 { 01010 OutputString(theStream, c_wstr(theString)); 01011 } 01012 } 01013 01014 01015 01023 inline void 01024 OutputString( 01025 #if defined(XALAN_NO_NAMESPACES) 01026 ostream& theStream, 01027 #else 01028 std::ostream& theStream, 01029 #endif 01030 const XalanDOMString& theString) 01031 { 01032 OutputString(theStream, c_wstr(theString)); 01033 } 01034 01035 01036 01044 inline XalanOutputStream& 01045 operator<<( 01046 XalanOutputStream& theStream, 01047 const CharVectorType& theString) 01048 { 01049 OutputString(theStream, theString); 01050 01051 return theStream; 01052 } 01053 01054 01055 01063 #if defined(XALAN_NO_NAMESPACES) 01064 inline ostream& 01065 operator<<( 01066 ostream& theStream, 01067 #else 01068 inline std::ostream& 01069 operator<<( 01070 std::ostream& theStream, 01071 #endif 01072 const CharVectorType& theString) 01073 { 01074 OutputString(theStream, theString); 01075 01076 return theStream; 01077 } 01078 01079 01080 01088 inline XalanOutputStream& 01089 operator<<( 01090 XalanOutputStream& theStream, 01091 const XalanDOMChar* theString) 01092 { 01093 OutputString(theStream, 01094 theString); 01095 01096 return theStream; 01097 } 01098 01099 01100 01108 #if defined(XALAN_NO_NAMESPACES) 01109 inline ostream& 01110 operator<<( 01111 ostream& theStream, 01112 #else 01113 inline std::ostream& 01114 operator<<( 01115 std::ostream& theStream, 01116 #endif 01117 const XalanDOMChar* theString) 01118 { 01119 OutputString(theStream, 01120 theString); 01121 01122 return theStream; 01123 } 01124 01125 01126 01134 inline XalanOutputStream& 01135 operator<<( 01136 XalanOutputStream& theStream, 01137 const XalanDOMString& theString) 01138 { 01139 OutputString(theStream, 01140 theString); 01141 01142 return theStream; 01143 } 01144 01145 01146 01154 #if defined(XALAN_NO_NAMESPACES) 01155 inline ostream& 01156 operator<<( 01157 ostream& theStream, 01158 #else 01159 inline std::ostream& 01160 operator<<( 01161 std::ostream& theStream, 01162 #endif 01163 const XalanDOMString& theString) 01164 { 01165 OutputString(theStream, 01166 theString); 01167 01168 return theStream; 01169 } 01170 01171 01172 01180 inline XalanDOMChar 01181 charAt( 01182 const XalanDOMString& theString, 01183 XalanDOMString::size_type theIndex) 01184 { 01185 return theString[theIndex]; 01186 } 01187 01188 01189 01196 inline bool 01197 isXMLWhitespace(XalanDOMChar theChar) 01198 { 01199 return XalanXMLChar::isWhitespace(theChar); 01200 } 01201 01202 01203 01210 inline bool 01211 isXMLDigit(XalanDOMChar theChar) 01212 { 01213 return XalanXMLChar::isDigit(theChar); 01214 } 01215 01216 01217 01224 inline bool 01225 isXMLLetterOrDigit(XalanDOMChar theChar) 01226 { 01227 return XalanXMLChar::isDigit(theChar) || 01228 XalanXMLChar::isLetter(theChar); 01229 } 01230 01231 01232 01244 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01245 substring( 01246 const XalanDOMChar* theString, 01247 XalanDOMString::size_type theStartIndex, 01248 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01249 01250 01251 01264 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 01265 substring( 01266 const XalanDOMChar* theString, 01267 XalanDOMString& theSubstring, 01268 XalanDOMString::size_type theStartIndex, 01269 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01270 01271 01272 01284 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01285 substring( 01286 const XalanDOMString& theString, 01287 XalanDOMString& theSubstring, 01288 XalanDOMString::size_type theStartIndex, 01289 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01290 01291 01292 01304 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01305 substring( 01306 const XalanDOMString& theString, 01307 XalanDOMString::size_type theStartIndex, 01308 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01309 01310 01311 01320 inline XalanDOMChar 01321 toLowerASCII(XalanDOMChar theChar) 01322 { 01323 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01324 { 01325 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01326 } 01327 else 01328 { 01329 return theChar; 01330 } 01331 } 01332 01333 01334 01343 inline XalanDOMChar 01344 toUpperASCII(XalanDOMChar theChar) 01345 { 01346 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01347 { 01348 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01349 } 01350 else 01351 { 01352 return theChar; 01353 } 01354 } 01355 01356 01357 01366 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01367 toLowerCaseASCII(const XalanDOMChar* theString); 01368 01369 01370 01379 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01380 toLowerCaseASCII(const XalanDOMString& theString); 01381 01382 01383 01392 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01393 toUpperCaseASCII(const XalanDOMChar* theString); 01394 01395 01396 01405 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01406 toUpperCaseASCII(const XalanDOMString& theString); 01407 01408 01409 01422 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01423 compare( 01424 const CharVectorType& theLHS, 01425 const CharVectorType& theRHS); 01426 01427 01428 01442 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01443 compare( 01444 const XalanDOMChar* theLHS, 01445 XalanDOMString::size_type theLHSLength, 01446 const XalanDOMChar* theRHS, 01447 XalanDOMString::size_type theRHSLength); 01448 01449 01450 01462 inline int 01463 compare( 01464 const XalanDOMChar* theLHS, 01465 const XalanDOMChar* theRHS) 01466 { 01467 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01468 } 01469 01470 01471 01485 inline int 01486 compare( 01487 const XalanDOMString& theLHS, 01488 const XalanDOMString& theRHS) 01489 { 01490 return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01491 } 01492 01493 01494 01506 inline int 01507 compare( 01508 const XalanDOMChar* theLHS, 01509 const XalanDOMString& theRHS) 01510 { 01511 return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01512 } 01513 01514 01515 01527 inline int 01528 compare( 01529 const XalanDOMString& theLHS, 01530 const XalanDOMChar* theRHS) 01531 { 01532 return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01533 } 01534 01535 01536 01552 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01553 compareIgnoreCaseASCII( 01554 const XalanDOMChar* theLHS, 01555 XalanDOMString::size_type theLHSLength, 01556 const XalanDOMChar* theRHS, 01557 XalanDOMString::size_type theRHSLength); 01558 01559 01560 01574 inline int 01575 compareIgnoreCaseASCII( 01576 const XalanDOMChar* theLHS, 01577 const XalanDOMChar* theRHS) 01578 { 01579 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01580 } 01581 01582 01583 01599 inline int 01600 compareIgnoreCaseASCII( 01601 const XalanDOMString& theLHS, 01602 const XalanDOMString& theRHS) 01603 { 01604 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01605 } 01606 01607 01608 01622 inline int 01623 compareIgnoreCaseASCII( 01624 const XalanDOMString& theLHS, 01625 const XalanDOMChar* theRHS) 01626 { 01627 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01628 } 01629 01630 01631 01645 inline int 01646 compareIgnoreCaseASCII( 01647 const XalanDOMChar* theLHS, 01648 const XalanDOMString& theRHS) 01649 { 01650 return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01651 } 01652 01653 01654 01665 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01666 collationCompare( 01667 const XalanDOMChar* theLHS, 01668 XalanDOMString::size_type theLHSLength, 01669 const XalanDOMChar* theRHS, 01670 XalanDOMString::size_type theRHSLength); 01671 01672 01673 01684 inline int 01685 collationCompare( 01686 const XalanDOMChar* theLHS, 01687 const XalanDOMChar* theRHS) 01688 { 01689 return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS)); 01690 } 01691 01692 01693 01704 inline int 01705 collationCompare( 01706 const XalanDOMString& theLHS, 01707 const XalanDOMString& theRHS) 01708 { 01709 return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01710 } 01711 01712 01713 01722 inline int 01723 collationCompare( 01724 const XalanDOMChar* theLHS, 01725 const XalanDOMString& theRHS) 01726 { 01727 return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01728 } 01729 01730 01731 01740 inline int 01741 collationCompare( 01742 const XalanDOMString& theLHS, 01743 const XalanDOMChar* theRHS) 01744 { 01745 return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01746 } 01747 01748 01749 01758 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01759 equals( 01760 const XalanDOMChar* theLHS, 01761 const XalanDOMChar* theRHS, 01762 XalanDOMString::size_type theLength); 01763 01764 01765 01775 inline bool 01776 equals( 01777 const XalanDOMChar* theLHS, 01778 XalanDOMString::size_type theLHSLength, 01779 const XalanDOMChar* theRHS, 01780 XalanDOMString::size_type theRHSLength) 01781 { 01782 return theLHSLength != theRHSLength ? false : equals(theLHS, theRHS, theLHSLength); 01783 } 01784 01785 01786 01794 inline bool 01795 equals( 01796 const XalanDOMChar* theLHS, 01797 const XalanDOMChar* theRHS) 01798 { 01799 const XalanDOMString::size_type theLHSLength = length(theLHS); 01800 01801 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 01802 } 01803 01804 01805 01813 inline bool 01814 equals( 01815 const XalanDOMString& theLHS, 01816 const XalanDOMString& theRHS) 01817 { 01818 return theLHS == theRHS; 01819 } 01820 01821 01822 01830 inline bool 01831 equals( 01832 const XalanDOMChar* theLHS, 01833 const XalanDOMString& theRHS) 01834 { 01835 assert(theLHS != 0); 01836 01837 // Swap them... 01838 return theRHS == theLHS; 01839 } 01840 01841 01842 01850 inline bool 01851 equals(const XalanDOMString& theLHS, 01852 const XalanDOMChar* theRHS) 01853 { 01854 return equals(theRHS, theLHS); 01855 } 01856 01857 01858 01867 inline bool 01868 equals( 01869 const XalanDOMString& theLHS, 01870 const XalanDOMChar* theRHS, 01871 XalanDOMString::size_type theRHSLength) 01872 { 01873 return theRHSLength != length(theLHS) ? false : equals(c_wstr(theLHS), theRHSLength, theRHS, theRHSLength); 01874 } 01875 01876 01877 01885 inline bool 01886 equals(const XalanDOMString& theLHS, 01887 const char* theRHS) 01888 { 01889 assert(theRHS != 0); 01890 01891 const XalanDOMString::size_type theRHSLength = length(theRHS); 01892 01893 if (theRHSLength != length(theLHS)) 01894 { 01895 return false; 01896 } 01897 else 01898 { 01899 return theLHS == XalanDOMString(theRHS, theRHSLength); 01900 } 01901 } 01902 01903 01904 01912 inline bool 01913 equals(const char* theLHS, 01914 const XalanDOMString& theRHS) 01915 { 01916 return equals(theRHS, theLHS); 01917 } 01918 01919 01920 01928 inline bool 01929 equals(const XalanDOMChar* theLHS, 01930 const char* theRHS) 01931 { 01932 assert(theLHS != 0); 01933 assert(theRHS != 0); 01934 01935 const XalanDOMString::size_type theRHSLength = length(theRHS); 01936 01937 if (theRHSLength != length(theLHS)) 01938 { 01939 return false; 01940 } 01941 else 01942 { 01943 return equals(XalanDOMString(theRHS, theRHSLength), theLHS); 01944 } 01945 } 01946 01947 01948 01956 inline bool 01957 equals(const char* theLHS, 01958 const XalanDOMChar* theRHS) 01959 { 01960 return equals(theRHS, theLHS); 01961 } 01962 01963 01964 01973 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01974 equalsIgnoreCaseASCII( 01975 const XalanDOMChar* theLHS, 01976 const XalanDOMChar* theRHS, 01977 XalanDOMString::size_type theLength); 01978 01979 01980 01991 inline bool 01992 equalsIgnoreCaseASCII( 01993 const XalanDOMChar* theLHS, 01994 XalanDOMString::size_type theLHSLength, 01995 const XalanDOMChar* theRHS, 01996 XalanDOMString::size_type theRHSLength) 01997 { 01998 return theLHSLength != theRHSLength ? false : 01999 equalsIgnoreCaseASCII(theLHS, theRHS, theLHSLength); 02000 } 02001 02002 02003 02012 inline bool 02013 equalsIgnoreCaseASCII( 02014 const XalanDOMChar* theLHS, 02015 const XalanDOMChar* theRHS) 02016 { 02017 const XalanDOMString::size_type theLength = length(theLHS); 02018 02019 return theLength != length(theRHS) ? false : 02020 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 02021 } 02022 02023 02024 02033 inline bool 02034 equalsIgnoreCaseASCII( 02035 const XalanDOMString& theLHS, 02036 const XalanDOMString& theRHS) 02037 { 02038 const XalanDOMString::size_type theLength = length(theLHS); 02039 02040 return theLength != length(theRHS) ? false : 02041 equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength); 02042 } 02043 02044 02045 02054 inline bool 02055 equalsIgnoreCaseASCII( 02056 const XalanDOMChar* theLHS, 02057 const XalanDOMString& theRHS) 02058 { 02059 const XalanDOMString::size_type theRHSLength = length(theRHS); 02060 02061 return theRHSLength != length(theLHS) ? false : 02062 equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength); 02063 } 02064 02065 02066 02075 inline bool 02076 equalsIgnoreCaseASCII( 02077 const XalanDOMString& theLHS, 02078 const XalanDOMChar* theRHS) 02079 { 02080 return equalsIgnoreCaseASCII(theRHS, theLHS); 02081 } 02082 02083 02084 02094 inline bool 02095 operator<( 02096 const CharVectorType& theLHS, 02097 const CharVectorType& theRHS) 02098 { 02099 return compare(theLHS, theRHS) < 0 ? true : false; 02100 } 02101 02102 02103 02113 inline bool 02114 operator<( 02115 const XalanDOMString& theLHS, 02116 const XalanDOMString& theRHS) 02117 { 02118 return compare(theLHS, theRHS) < 0 ? true : false; 02119 } 02120 02121 02122 02131 inline XalanDOMString& 02132 assign( 02133 XalanDOMString& theString, 02134 const XalanDOMString& theStringToAssign) 02135 { 02136 theString = theStringToAssign; 02137 02138 return theString; 02139 } 02140 02141 02142 02151 inline XalanDOMString& 02152 assign( 02153 XalanDOMString& theString, 02154 const XalanDOMChar* theStringToAssign, 02155 XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos) 02156 { 02157 if (theStringToAssignLength == XalanDOMString::npos) 02158 { 02159 theString.assign(theStringToAssign); 02160 } 02161 else 02162 { 02163 theString.assign(theStringToAssign, theStringToAssignLength); 02164 } 02165 02166 return theString; 02167 } 02168 02169 02170 02178 inline XalanDOMString& 02179 append( 02180 XalanDOMString& theString, 02181 const XalanDOMString& theStringToAppend) 02182 { 02183 theString.append(theStringToAppend); 02184 02185 return theString; 02186 } 02187 02188 02189 02198 inline XalanDOMString& 02199 append( 02200 XalanDOMString& theString, 02201 const XalanDOMChar* theStringToAppend, 02202 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02203 { 02204 assert(theStringToAppend != 0); 02205 02206 if (theStringToAppendLength == XalanDOMString::npos) 02207 { 02208 theString.append(theStringToAppend); 02209 } 02210 else 02211 { 02212 theString.append(theStringToAppend, theStringToAppendLength); 02213 } 02214 02215 return theString; 02216 } 02217 02218 02219 02228 inline XalanDOMString& 02229 append( 02230 XalanDOMString& theString, 02231 const char* theStringToAppend, 02232 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02233 { 02234 theString.append(TranscodeFromLocalCodePage(theStringToAppend, theStringToAppendLength)); 02235 02236 return theString; 02237 } 02238 02239 02240 02248 inline XalanDOMString& 02249 append( 02250 XalanDOMString& theString, 02251 const XalanDOMChar theCharToAppend) 02252 { 02253 theString.append(1, theCharToAppend); 02254 02255 return theString; 02256 } 02257 02258 02259 02267 inline XalanDOMString& 02268 append( 02269 XalanDOMString& theString, 02270 char theCharToAppend) 02271 { 02272 // We have to transcode before appending... 02273 char theTempBuffer[] = { theCharToAppend, '\0' }; 02274 02275 return append(theString, theTempBuffer); 02276 } 02277 02278 02279 02288 inline XalanDOMString& 02289 insert( 02290 XalanDOMString& theString, 02291 XalanDOMString::size_type thePosition, 02292 const XalanDOMString& theStringToInsert) 02293 { 02294 theString.insert(thePosition, theStringToInsert); 02295 02296 return theString; 02297 } 02298 02299 02300 02309 inline XalanDOMString& 02310 insert( 02311 XalanDOMString& theString, 02312 XalanDOMString::size_type thePosition, 02313 const XalanDOMChar* theStringToInsert) 02314 { 02315 theString.insert(thePosition, theStringToInsert); 02316 02317 return theString; 02318 } 02319 02320 02321 02328 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 02329 trim(const XalanDOMString& theString); 02330 02331 02332 02338 inline void 02339 clear(XalanDOMString& theString) 02340 { 02341 theString.clear(); 02342 } 02343 02344 02345 02351 inline void 02352 erase(XalanDOMString& theString) 02353 { 02354 theString.erase(); 02355 } 02356 02357 02358 02365 inline void 02366 releaseMemory(XalanDOMString& theString) 02367 { 02368 XalanDOMString().swap(theString); 02369 } 02370 02371 02372 02373 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02374 CopyWideStringToVector( 02375 const XalanDOMChar* theString, 02376 CharVectorType& theVector); 02377 02378 02379 02380 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02381 CopyStringToVector( 02382 const char* theString, 02383 CharVectorType& theVector); 02384 02385 02386 02395 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02396 MakeXalanDOMCharVector( 02397 const char* data, 02398 bool fTranscode = true); 02399 02400 02401 02409 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02410 MakeXalanDOMCharVector(const XalanDOMChar* data); 02411 02412 02413 02421 inline XalanDOMCharVectorType 02422 MakeXalanDOMCharVector(const XalanDOMString& data) 02423 { 02424 return MakeXalanDOMCharVector(c_wstr(data)); 02425 } 02426 02427 02428 02429 #if defined(XALAN_NO_NAMESPACES) 02430 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02431 #else 02432 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02433 #endif 02434 { 02435 result_type 02436 operator() (const argument_type& theString) const 02437 { 02438 return c_wstr(theString); 02439 } 02440 }; 02441 02442 02443 02450 #if defined(XALAN_NO_NAMESPACES) 02451 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 02452 #else 02453 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 02454 #endif 02455 { 02456 result_type 02457 operator() (argument_type theKey) const 02458 { 02459 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 02460 02461 result_type theHashValue = 0; 02462 02463 if (theRawBuffer != 0) 02464 { 02465 while (*theRawBuffer) 02466 { 02467 theHashValue = 5 * theHashValue + *theRawBuffer; 02468 02469 theRawBuffer++; 02470 } 02471 } 02472 02473 return theHashValue++; 02474 } 02475 }; 02476 02477 02478 02486 #if defined(XALAN_NO_NAMESPACES) 02487 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02488 #else 02489 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02490 #endif 02491 { 02492 result_type 02493 operator() (first_argument_type theLHS, 02494 second_argument_type theRHS) const 02495 { 02496 return equals(theLHS, theRHS); 02497 } 02498 }; 02499 02500 02501 02509 #if defined(XALAN_NO_NAMESPACES) 02510 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02511 #else 02512 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02513 #endif 02514 { 02515 result_type 02516 operator() (first_argument_type theLHS, 02517 second_argument_type theRHS) const 02518 { 02519 return !equals(theLHS, theRHS); 02520 } 02521 }; 02522 02523 02524 02532 #if defined(XALAN_NO_NAMESPACES) 02533 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02534 #else 02535 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02536 #endif 02537 { 02538 result_type 02539 operator() (first_argument_type theLHS, 02540 second_argument_type theRHS) const 02541 { 02542 return compare(theLHS, theRHS) < 0 ? true : false; 02543 } 02544 }; 02545 02546 02547 02555 #if defined(XALAN_NO_NAMESPACES) 02556 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02557 #else 02558 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02559 #endif 02560 { 02561 result_type 02562 operator() (first_argument_type theLHS, 02563 second_argument_type theRHS) const 02564 { 02565 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02566 } 02567 }; 02568 02569 02570 02578 #if defined(XALAN_NO_NAMESPACES) 02579 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02580 #else 02581 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02582 #endif 02583 { 02584 result_type 02585 operator() (first_argument_type theLHS, 02586 second_argument_type theRHS) const 02587 { 02588 return compare(theLHS, theRHS) <= 0 ? true : false; 02589 } 02590 }; 02591 02592 02593 02601 #if defined(XALAN_NO_NAMESPACES) 02602 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02603 #else 02604 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02605 #endif 02606 { 02607 result_type 02608 operator() (first_argument_type theLHS, 02609 second_argument_type theRHS) const 02610 { 02611 return compare(theLHS, theRHS) > 0 ? true : false; 02612 } 02613 }; 02614 02615 02616 02624 #if defined(XALAN_NO_NAMESPACES) 02625 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02626 #else 02627 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02628 #endif 02629 { 02630 result_type 02631 operator() (first_argument_type theLHS, 02632 second_argument_type theRHS) const 02633 { 02634 return compare(theLHS, theRHS) >= 0 ? true : false; 02635 } 02636 }; 02637 02638 02639 02645 #if defined(XALAN_NO_NAMESPACES) 02646 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02647 #else 02648 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02649 #endif 02650 { 02659 result_type 02660 operator()( 02661 first_argument_type theLHS, 02662 second_argument_type theRHS) const 02663 { 02664 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02665 } 02666 }; 02667 02668 02669 02676 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02677 isXMLWhitespace(const XalanDOMString& string); 02678 02679 02680 02689 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02690 isXMLWhitespace( 02691 const XalanDOMChar ch[], 02692 XalanDOMString::size_type start, 02693 XalanDOMString::size_type length); 02694 02695 02696 02703 inline bool 02704 isXMLWhitespace(const XalanDOMChar* theString) 02705 { 02706 assert(theString != 0); 02707 02708 return isXMLWhitespace(theString, 0, length(theString)); 02709 } 02710 02711 02712 02713 #endif // DOMSTRINGHELPER_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 |
|