00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(DOMSTRINGHELPER_HEADER_GUARD_1357924680) 00017 #define DOMSTRINGHELPER_HEADER_GUARD_1357924680 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00023 00024 00025 00026 #include <algorithm> 00027 #include <cassert> 00028 #include <functional> 00029 #if defined(XALAN_CLASSIC_IOSTREAMS) 00030 class ostream; 00031 #else 00032 #include <iosfwd> 00033 #endif 00034 #include <vector> 00035 00036 00037 00038 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00039 00040 00041 00042 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00043 #include <xalanc/PlatformSupport/XalanUnicode.hpp> 00044 #include <xalanc/PlatformSupport/XalanXMLChar.hpp> 00045 00046 00047 00048 XALAN_CPP_NAMESPACE_BEGIN 00049 00050 00051 00052 class XalanOutputStream; 00053 00054 00055 00056 // This macro has been defined to deal with certain C++ compilers which 00057 // do not create Unicode strings when the "L" string constant prefix is 00058 // used. It is meant _only_ for use with static strings. 00059 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) 00060 00061 #define XALAN_STATIC_UCODE_STRING(str) L##str 00062 00073 inline const XalanDOMString 00074 StaticStringToDOMString(const XalanDOMChar* theString) 00075 { 00076 return XalanDOMString(theString); 00077 } 00078 00079 #else 00080 00081 #define XALAN_STATIC_UCODE_STRING(str) XALAN_CPP_NAMESPACE_QUALIFIER TranscodeFromLocalCodePage(str) 00082 00091 inline const XalanDOMString& 00092 StaticStringToDOMString(const XalanDOMString& theString) 00093 { 00094 return theString; 00095 } 00096 00097 #endif 00098 00099 00100 00101 #if defined(XALAN_NO_ALGORITHMS_WITH_BUILTINS) 00102 00103 template<class InputIteratorType, class OutputIteratorType> 00104 inline OutputIteratorType 00105 XalanCopy( 00106 InputIteratorType begin, 00107 InputIteratorType end, 00108 OutputIteratorType iterator) 00109 { 00110 for(; begin != end; ++iterator, ++begin) 00111 { 00112 *iterator = *begin; 00113 } 00114 00115 return iterator; 00116 } 00117 00118 00119 00120 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction> 00121 inline OutputIteratorType 00122 XalanTransform( 00123 InputIteratorType begin, 00124 InputIteratorType end, 00125 OutputIteratorType iterator, 00126 UnaryFunction function) 00127 { 00128 for(; begin != end; ++iterator, ++begin) 00129 { 00130 *iterator = function(*begin); 00131 } 00132 00133 return iterator; 00134 } 00135 00136 #else 00137 00138 template<class InputIteratorType, class OutputIteratorType> 00139 inline OutputIteratorType 00140 XalanCopy( 00141 InputIteratorType begin, 00142 InputIteratorType end, 00143 OutputIteratorType iterator) 00144 { 00145 return XALAN_STD_QUALIFIER copy(begin, end, iterator); 00146 } 00147 00148 00149 00150 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction> 00151 inline OutputIteratorType 00152 XalanTransform( 00153 InputIteratorType begin, 00154 InputIteratorType end, 00155 OutputIteratorType iterator, 00156 UnaryFunction function) 00157 { 00158 return XALAN_STD_QUALIFIER transform(begin, end, iterator); 00159 } 00160 00161 #endif 00162 00163 00164 00172 inline const XalanDOMChar* 00173 c_wstr(const XalanDOMString& theString) 00174 { 00175 return theString.c_str(); 00176 } 00177 00178 00179 00187 inline const char* 00188 c_str(const CharVectorType& theString) 00189 { 00190 if (theString.empty() == true) 00191 { 00192 return 0; 00193 } 00194 else 00195 { 00196 const char* const ptr = &theString[0]; 00197 00198 assert(ptr[theString.size() - 1] == '\0'); 00199 00200 return ptr; 00201 } 00202 } 00203 00204 00205 00221 inline const XalanDOMChar* 00222 c_wstr(const XalanDOMChar* theString) 00223 { 00224 return theString; 00225 } 00226 00227 00228 00236 inline const XalanDOMChar* 00237 toCharArray(const XalanDOMString& theString) 00238 { 00239 return theString.c_str(); 00240 } 00241 00242 00243 00250 inline const XalanDOMChar* 00251 toCharArray(const XalanDOMChar* theString) 00252 { 00253 return theString; 00254 } 00255 00256 00257 00265 inline const char* 00266 toCharArray(const CharVectorType& theString) 00267 { 00268 return theString.empty() == true ? 0 : &theString[0]; 00269 } 00270 00271 00272 00280 inline void 00281 reserve( 00282 XalanDOMString& theString, 00283 XalanDOMString::size_type theCount) 00284 { 00285 theString.reserve(theCount); 00286 } 00287 00288 00289 00296 inline XalanDOMString::size_type 00297 length(const XalanDOMString& theString) 00298 { 00299 return theString.length(); 00300 } 00301 00302 00303 00311 inline XalanDOMString::size_type 00312 length(const XalanDOMChar* theString) 00313 { 00314 assert(theString != 0); 00315 00316 const XalanDOMChar* theBufferPointer = theString; 00317 00318 while(*theBufferPointer != 0) 00319 { 00320 theBufferPointer++; 00321 } 00322 00323 return XalanDOMString::size_type(theBufferPointer - theString); 00324 } 00325 00326 00327 00334 inline XalanDOMString::size_type 00335 length(const char* theString) 00336 { 00337 assert(theString != 0); 00338 00339 return XalanDOMString::length(theString); 00340 } 00341 00342 00343 00350 inline bool 00351 isEmpty(const XalanDOMString& str) 00352 { 00353 return str.empty(); 00354 } 00355 00356 00357 00367 inline XalanDOMString::size_type 00368 indexOf( 00369 const XalanDOMChar* theString, 00370 XalanDOMChar theChar) 00371 { 00372 assert(theString != 0); 00373 00374 const XalanDOMChar* thePointer = theString; 00375 00376 while(*thePointer != theChar && *thePointer != 0) 00377 { 00378 ++thePointer; 00379 } 00380 00381 return XalanDOMString::size_type(thePointer - theString); 00382 } 00383 00384 00385 00396 inline XalanDOMString::size_type 00397 indexOf( 00398 const XalanDOMChar* theString, 00399 XalanDOMString::size_type theStringLength, 00400 XalanDOMChar theChar) 00401 { 00402 assert(theString != 0); 00403 00404 const XalanDOMChar* thePointer = theString; 00405 const XalanDOMChar* const theEndPointer = theString + theStringLength; 00406 00407 while(*thePointer != theChar && thePointer != theEndPointer) 00408 { 00409 ++thePointer; 00410 } 00411 00412 return XalanDOMString::size_type(thePointer - theString); 00413 } 00414 00415 00416 00426 inline XalanDOMString::size_type 00427 indexOf( 00428 const XalanDOMString& theString, 00429 XalanDOMChar theChar) 00430 { 00431 return length(theString) == 0 ? 0 : indexOf(c_wstr(theString), theChar); 00432 } 00433 00434 00435 00447 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00448 indexOf( 00449 const XalanDOMChar* theString, 00450 XalanDOMString::size_type theStringLength, 00451 const XalanDOMChar* theSubstring, 00452 XalanDOMString::size_type theSubstringLength); 00453 00454 00455 00465 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00466 indexOf( 00467 const XalanDOMChar* theString, 00468 const XalanDOMChar* theSubstring); 00469 00470 00471 00481 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00482 indexOf( 00483 const XalanDOMString& theString, 00484 const XalanDOMString& theSubstring); 00485 00486 00487 00498 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00499 lastIndexOf( 00500 const XalanDOMChar* theString, 00501 XalanDOMChar theChar); 00502 00503 00504 00514 inline XalanDOMString::size_type 00515 lastIndexOf( 00516 const XalanDOMString& theString, 00517 XalanDOMChar theChar) 00518 { 00519 return lastIndexOf(c_wstr(theString), theChar); 00520 } 00521 00522 00523 00533 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00534 startsWith( 00535 const XalanDOMChar* theString, 00536 XalanDOMString::size_type theStringLength, 00537 const XalanDOMChar* theSubstring, 00538 XalanDOMString::size_type theSubstringLength); 00539 00540 00541 00549 inline bool 00550 startsWith( 00551 const XalanDOMChar* theString, 00552 const XalanDOMChar* theSubstring) 00553 { 00554 assert(theString != 0 && theSubstring != 0); 00555 00556 return startsWith(theString, length(theString), theSubstring, length(theSubstring)); 00557 } 00558 00559 00560 00568 inline bool 00569 startsWith( 00570 const XalanDOMChar* theString, 00571 const XalanDOMString& theSubstring) 00572 { 00573 assert(theString != 0); 00574 00575 return startsWith(theString, length(theString), c_wstr(theSubstring), length(theSubstring)); 00576 } 00577 00578 00579 00587 inline bool 00588 startsWith( 00589 const XalanDOMString& theString, 00590 const XalanDOMChar* theSubstring) 00591 { 00592 assert(theSubstring != 0); 00593 00594 return startsWith(c_wstr(theString), length(theString), theSubstring, length(theSubstring)); 00595 } 00596 00597 00598 00607 inline bool 00608 startsWith( 00609 const XalanDOMString& theString, 00610 const XalanDOMChar* theSubstring, 00611 XalanDOMString::size_type theSubstringLength) 00612 { 00613 assert(theSubstring != 0); 00614 00615 return startsWith(c_wstr(theString), length(theString), theSubstring, theSubstringLength); 00616 } 00617 00618 00619 00627 inline bool 00628 startsWith( 00629 const XalanDOMString& theString, 00630 const XalanDOMString& theSubstring) 00631 { 00632 return startsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring)); 00633 } 00634 00635 00636 00644 inline bool 00645 startsWith( 00646 const XalanDOMString& theString, 00647 const char* theSubstring) 00648 { 00649 return startsWith( 00650 theString, 00651 XalanDOMString(theSubstring)); 00652 } 00653 00654 00655 00663 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00664 endsWith( 00665 const XalanDOMChar* theString, 00666 XalanDOMString::size_type theStringLength, 00667 const XalanDOMChar* theSubstring, 00668 XalanDOMString::size_type theSubstringLength); 00669 00670 00671 00679 inline bool 00680 endsWith( 00681 const XalanDOMChar* theString, 00682 const XalanDOMChar* theSubstring) 00683 { 00684 assert(theString != 0 && theSubstring != 0); 00685 00686 return endsWith(theString, length(theString), theSubstring, length(theSubstring)); 00687 } 00688 00689 00690 00698 inline bool 00699 endsWith( 00700 const XalanDOMString& theString, 00701 const XalanDOMString& theSubstring) 00702 { 00703 return endsWith(c_wstr(theString), length(theString), c_wstr(theSubstring), length(theSubstring)); 00704 } 00705 00706 00707 00715 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00716 PointerToDOMString( 00717 const void* theValue, 00718 XalanDOMString& theResult); 00719 00720 00721 00728 inline const XalanDOMString 00729 PointerToDOMString(const void* theValue) 00730 { 00731 XalanDOMString theResult; 00732 00733 PointerToDOMString(theValue, theResult); 00734 00735 return theResult; 00736 } 00737 00738 00739 00747 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00748 DoubleToDOMString( 00749 double theValue, 00750 XalanDOMString& theResult); 00751 00752 00753 00760 inline const XalanDOMString 00761 DoubleToDOMString(double theValue) 00762 { 00763 XalanDOMString theResult; 00764 00765 DoubleToDOMString(theValue, theResult); 00766 00767 return theResult; 00768 } 00769 00770 00771 00772 class XALAN_PLATFORMSUPPORT_EXPORT DOMStringHelper 00773 { 00774 public: 00775 00776 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const unsigned int); 00777 00778 static void 00779 DoubleToCharacters( 00780 double theDouble, 00781 FormatterListener& formatterListener, 00782 MemberFunctionPtr function); 00783 00784 static void 00785 LongToCharacters( 00786 long theLong, 00787 FormatterListener& formatterListener, 00788 MemberFunctionPtr function); 00789 }; 00790 00791 00792 00801 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00802 LongToHexDOMString( 00803 long theValue, 00804 XalanDOMString& theResult); 00805 00806 00807 00815 inline const XalanDOMString 00816 LongToHexDOMString(long theValue) 00817 { 00818 XalanDOMString theResult; 00819 00820 LongToHexDOMString(theValue, theResult); 00821 00822 return theResult; 00823 } 00824 00825 00826 00835 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00836 UnsignedLongToHexDOMString( 00837 unsigned long theValue, 00838 XalanDOMString& theResult); 00839 00840 00841 00849 inline const XalanDOMString 00850 UnsignedLongToHexDOMString(unsigned long theValue) 00851 { 00852 XalanDOMString theResult; 00853 00854 UnsignedLongToHexDOMString(theValue, theResult); 00855 00856 return theResult; 00857 } 00858 00859 00860 00868 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00869 LongToDOMString( 00870 long theValue, 00871 XalanDOMString& theResult); 00872 00873 00874 00881 inline const XalanDOMString 00882 LongToDOMString(long theValue) 00883 { 00884 XalanDOMString theResult; 00885 00886 LongToDOMString(theValue, theResult); 00887 00888 return theResult; 00889 } 00890 00891 00892 00901 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00902 UnsignedLongToDOMString( 00903 unsigned long theValue, 00904 XalanDOMString& theResult); 00905 00906 00907 00914 inline const XalanDOMString 00915 UnsignedLongToDOMString(unsigned long theValue) 00916 { 00917 XalanDOMString theResult; 00918 00919 UnsignedLongToDOMString(theValue, theResult); 00920 00921 return theResult; 00922 } 00923 00924 00925 00932 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00933 WideStringToInt(const XalanDOMChar* theString); 00934 00935 00936 00943 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00944 WideStringToLong(const XalanDOMChar* theString); 00945 00946 00947 00954 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00955 WideStringToUnsignedLong(const XalanDOMChar* theString); 00956 00957 00958 00965 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00966 WideStringToDouble(const XalanDOMChar* theString); 00967 00968 00969 00976 inline int 00977 DOMStringToInt(const XalanDOMString& theString) 00978 { 00979 return WideStringToInt(c_wstr(theString)); 00980 } 00981 00982 00983 00990 inline long 00991 DOMStringToLong(const XalanDOMString& theString) 00992 { 00993 return WideStringToLong(c_wstr(theString)); 00994 } 00995 00996 00997 01004 inline unsigned long 01005 DOMStringToUnsignedLong(const XalanDOMString& theString) 01006 { 01007 return WideStringToUnsignedLong(c_wstr(theString)); 01008 } 01009 01010 01011 01018 inline double 01019 DOMStringToDouble(const XalanDOMString& theString) 01020 { 01021 return WideStringToDouble(c_wstr(theString)); 01022 } 01023 01024 01025 01033 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01034 OutputString( 01035 XalanOutputStream& theStream, 01036 const CharVectorType& theString); 01037 01038 01039 01047 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01048 OutputString( 01049 #if defined(XALAN_NO_STD_NAMESPACE) 01050 ostream& theStream, 01051 #else 01052 std::ostream& theStream, 01053 #endif 01054 const CharVectorType& theString); 01055 01056 01057 01065 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01066 OutputString( 01067 XalanOutputStream& theStream, 01068 const XalanDOMChar* theString); 01069 01070 01071 01079 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01080 OutputString( 01081 #if defined(XALAN_NO_STD_NAMESPACE) 01082 ostream& theStream, 01083 #else 01084 std::ostream& theStream, 01085 #endif 01086 const XalanDOMChar* theString); 01087 01088 01089 01097 inline void 01098 OutputString( 01099 XalanOutputStream& theStream, 01100 const XalanDOMString& theString) 01101 { 01102 if (isEmpty(theString) == false) 01103 { 01104 OutputString(theStream, c_wstr(theString)); 01105 } 01106 } 01107 01108 01109 01117 inline void 01118 OutputString( 01119 #if defined(XALAN_NO_STD_NAMESPACE) 01120 ostream& theStream, 01121 #else 01122 std::ostream& theStream, 01123 #endif 01124 const XalanDOMString& theString) 01125 { 01126 OutputString(theStream, c_wstr(theString)); 01127 } 01128 01129 01130 01138 inline XalanOutputStream& 01139 operator<<( 01140 XalanOutputStream& theStream, 01141 const CharVectorType& theString) 01142 { 01143 OutputString(theStream, theString); 01144 01145 return theStream; 01146 } 01147 01148 01149 01157 #if defined(XALAN_NO_STD_NAMESPACE) 01158 inline ostream& 01159 operator<<( 01160 ostream& theStream, 01161 #else 01162 inline std::ostream& 01163 operator<<( 01164 std::ostream& theStream, 01165 #endif 01166 const CharVectorType& theString) 01167 { 01168 OutputString(theStream, theString); 01169 01170 return theStream; 01171 } 01172 01173 01174 01182 inline XalanOutputStream& 01183 operator<<( 01184 XalanOutputStream& theStream, 01185 const XalanDOMChar* theString) 01186 { 01187 OutputString(theStream, 01188 theString); 01189 01190 return theStream; 01191 } 01192 01193 01194 01202 #if defined(XALAN_NO_STD_NAMESPACE) 01203 inline ostream& 01204 operator<<( 01205 ostream& theStream, 01206 #else 01207 inline std::ostream& 01208 operator<<( 01209 std::ostream& theStream, 01210 #endif 01211 const XalanDOMChar* theString) 01212 { 01213 OutputString(theStream, 01214 theString); 01215 01216 return theStream; 01217 } 01218 01219 01220 01228 inline XalanOutputStream& 01229 operator<<( 01230 XalanOutputStream& theStream, 01231 const XalanDOMString& theString) 01232 { 01233 OutputString(theStream, 01234 theString); 01235 01236 return theStream; 01237 } 01238 01239 01240 01248 #if defined(XALAN_NO_STD_NAMESPACE) 01249 inline ostream& 01250 operator<<( 01251 ostream& theStream, 01252 #else 01253 inline std::ostream& 01254 operator<<( 01255 std::ostream& theStream, 01256 #endif 01257 const XalanDOMString& theString) 01258 { 01259 OutputString(theStream, 01260 theString); 01261 01262 return theStream; 01263 } 01264 01265 01266 01274 inline XalanDOMChar 01275 charAt( 01276 const XalanDOMString& theString, 01277 XalanDOMString::size_type theIndex) 01278 { 01279 return theString[theIndex]; 01280 } 01281 01282 01283 01290 inline bool 01291 isXMLWhitespace(XalanDOMChar theChar) 01292 { 01293 return XalanXMLChar::isWhitespace(theChar); 01294 } 01295 01296 01297 01304 inline bool 01305 isXMLDigit(XalanDOMChar theChar) 01306 { 01307 return XalanXMLChar::isDigit(theChar); 01308 } 01309 01310 01311 01318 inline bool 01319 isXMLLetterOrDigit(XalanDOMChar theChar) 01320 { 01321 return XalanXMLChar::isDigit(theChar) || 01322 XalanXMLChar::isLetter(theChar); 01323 } 01324 01325 01326 01338 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01339 substring( 01340 const XalanDOMChar* theString, 01341 XalanDOMString::size_type theStartIndex, 01342 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01343 01344 01345 01358 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01359 substring( 01360 const XalanDOMChar* theString, 01361 XalanDOMString& theSubstring, 01362 XalanDOMString::size_type theStartIndex, 01363 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01364 01365 01366 01378 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01379 substring( 01380 const XalanDOMString& theString, 01381 XalanDOMString& theSubstring, 01382 XalanDOMString::size_type theStartIndex, 01383 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01384 01385 01386 01398 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01399 substring( 01400 const XalanDOMString& theString, 01401 XalanDOMString::size_type theStartIndex, 01402 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01403 01404 01405 01414 inline XalanDOMChar 01415 toLowerASCII(XalanDOMChar theChar) 01416 { 01417 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01418 { 01419 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01420 } 01421 else 01422 { 01423 return theChar; 01424 } 01425 } 01426 01427 01428 01437 inline XalanDOMChar 01438 toUpperASCII(XalanDOMChar theChar) 01439 { 01440 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01441 { 01442 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01443 } 01444 else 01445 { 01446 return theChar; 01447 } 01448 } 01449 01450 01451 01460 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01461 toLowerCaseASCII(const XalanDOMChar* theString); 01462 01463 01464 01473 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01474 toLowerCaseASCII(const XalanDOMString& theString); 01475 01476 01477 01486 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01487 toUpperCaseASCII(const XalanDOMChar* theString); 01488 01489 01490 01499 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01500 toUpperCaseASCII(const XalanDOMString& theString); 01501 01502 01503 01516 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01517 compare( 01518 const CharVectorType& theLHS, 01519 const CharVectorType& theRHS); 01520 01521 01522 01536 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01537 compare( 01538 const XalanDOMChar* theLHS, 01539 XalanDOMString::size_type theLHSLength, 01540 const XalanDOMChar* theRHS, 01541 XalanDOMString::size_type theRHSLength); 01542 01543 01544 01556 inline int 01557 compare( 01558 const XalanDOMChar* theLHS, 01559 const XalanDOMChar* theRHS) 01560 { 01561 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01562 } 01563 01564 01565 01579 inline int 01580 compare( 01581 const XalanDOMString& theLHS, 01582 const XalanDOMString& theRHS) 01583 { 01584 return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01585 } 01586 01587 01588 01600 inline int 01601 compare( 01602 const XalanDOMChar* theLHS, 01603 const XalanDOMString& theRHS) 01604 { 01605 return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01606 } 01607 01608 01609 01621 inline int 01622 compare( 01623 const XalanDOMString& theLHS, 01624 const XalanDOMChar* theRHS) 01625 { 01626 return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01627 } 01628 01629 01630 01646 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01647 compareIgnoreCaseASCII( 01648 const XalanDOMChar* theLHS, 01649 XalanDOMString::size_type theLHSLength, 01650 const XalanDOMChar* theRHS, 01651 XalanDOMString::size_type theRHSLength); 01652 01653 01654 01668 inline int 01669 compareIgnoreCaseASCII( 01670 const XalanDOMChar* theLHS, 01671 const XalanDOMChar* theRHS) 01672 { 01673 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01674 } 01675 01676 01677 01693 inline int 01694 compareIgnoreCaseASCII( 01695 const XalanDOMString& theLHS, 01696 const XalanDOMString& theRHS) 01697 { 01698 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01699 } 01700 01701 01702 01716 inline int 01717 compareIgnoreCaseASCII( 01718 const XalanDOMString& theLHS, 01719 const XalanDOMChar* theRHS) 01720 { 01721 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01722 } 01723 01724 01725 01739 inline int 01740 compareIgnoreCaseASCII( 01741 const XalanDOMChar* theLHS, 01742 const XalanDOMString& theRHS) 01743 { 01744 return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01745 } 01746 01747 01748 01759 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01760 collationCompare( 01761 const XalanDOMChar* theLHS, 01762 XalanDOMString::size_type theLHSLength, 01763 const XalanDOMChar* theRHS, 01764 XalanDOMString::size_type theRHSLength); 01765 01766 01767 01778 inline int 01779 collationCompare( 01780 const XalanDOMChar* theLHS, 01781 const XalanDOMChar* theRHS) 01782 { 01783 return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS)); 01784 } 01785 01786 01787 01798 inline int 01799 collationCompare( 01800 const XalanDOMString& theLHS, 01801 const XalanDOMString& theRHS) 01802 { 01803 return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01804 } 01805 01806 01807 01816 inline int 01817 collationCompare( 01818 const XalanDOMChar* theLHS, 01819 const XalanDOMString& theRHS) 01820 { 01821 return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01822 } 01823 01824 01825 01834 inline int 01835 collationCompare( 01836 const XalanDOMString& theLHS, 01837 const XalanDOMChar* theRHS) 01838 { 01839 return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01840 } 01841 01842 01843 01852 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01853 equals( 01854 const XalanDOMChar* theLHS, 01855 const XalanDOMChar* theRHS, 01856 XalanDOMString::size_type theLength); 01857 01858 01859 01869 inline bool 01870 equals( 01871 const XalanDOMChar* theLHS, 01872 XalanDOMString::size_type theLHSLength, 01873 const XalanDOMChar* theRHS, 01874 XalanDOMString::size_type theRHSLength) 01875 { 01876 return theLHSLength != theRHSLength ? false : equals(theLHS, theRHS, theLHSLength); 01877 } 01878 01879 01880 01888 inline bool 01889 equals( 01890 const XalanDOMChar* theLHS, 01891 const XalanDOMChar* theRHS) 01892 { 01893 const XalanDOMString::size_type theLHSLength = length(theLHS); 01894 01895 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 01896 } 01897 01898 01899 01907 inline bool 01908 equals( 01909 const XalanDOMString& theLHS, 01910 const XalanDOMString& theRHS) 01911 { 01912 return theLHS == theRHS; 01913 } 01914 01915 01916 01924 inline bool 01925 equals( 01926 const XalanDOMChar* theLHS, 01927 const XalanDOMString& theRHS) 01928 { 01929 assert(theLHS != 0); 01930 01931 // Swap them... 01932 return theRHS == theLHS; 01933 } 01934 01935 01936 01944 inline bool 01945 equals(const XalanDOMString& theLHS, 01946 const XalanDOMChar* theRHS) 01947 { 01948 return equals(theRHS, theLHS); 01949 } 01950 01951 01952 01961 inline bool 01962 equals( 01963 const XalanDOMString& theLHS, 01964 const XalanDOMChar* theRHS, 01965 XalanDOMString::size_type theRHSLength) 01966 { 01967 return theRHSLength != length(theLHS) ? false : equals(c_wstr(theLHS), theRHSLength, theRHS, theRHSLength); 01968 } 01969 01970 01971 01979 inline bool 01980 equals(const XalanDOMString& theLHS, 01981 const char* theRHS) 01982 { 01983 assert(theRHS != 0); 01984 01985 const XalanDOMString::size_type theRHSLength = length(theRHS); 01986 01987 if (theRHSLength != length(theLHS)) 01988 { 01989 return false; 01990 } 01991 else 01992 { 01993 return theLHS == XalanDOMString(theRHS, theRHSLength); 01994 } 01995 } 01996 01997 01998 02006 inline bool 02007 equals(const char* theLHS, 02008 const XalanDOMString& theRHS) 02009 { 02010 return equals(theRHS, theLHS); 02011 } 02012 02013 02014 02022 inline bool 02023 equals(const XalanDOMChar* theLHS, 02024 const char* theRHS) 02025 { 02026 assert(theLHS != 0); 02027 assert(theRHS != 0); 02028 02029 const XalanDOMString::size_type theRHSLength = length(theRHS); 02030 02031 if (theRHSLength != length(theLHS)) 02032 { 02033 return false; 02034 } 02035 else 02036 { 02037 return equals(XalanDOMString(theRHS, theRHSLength), theLHS); 02038 } 02039 } 02040 02041 02042 02050 inline bool 02051 equals(const char* theLHS, 02052 const XalanDOMChar* theRHS) 02053 { 02054 return equals(theRHS, theLHS); 02055 } 02056 02057 02058 02067 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02068 equalsIgnoreCaseASCII( 02069 const XalanDOMChar* theLHS, 02070 const XalanDOMChar* theRHS, 02071 XalanDOMString::size_type theLength); 02072 02073 02074 02085 inline bool 02086 equalsIgnoreCaseASCII( 02087 const XalanDOMChar* theLHS, 02088 XalanDOMString::size_type theLHSLength, 02089 const XalanDOMChar* theRHS, 02090 XalanDOMString::size_type theRHSLength) 02091 { 02092 return theLHSLength != theRHSLength ? false : 02093 equalsIgnoreCaseASCII(theLHS, theRHS, theLHSLength); 02094 } 02095 02096 02097 02106 inline bool 02107 equalsIgnoreCaseASCII( 02108 const XalanDOMChar* theLHS, 02109 const XalanDOMChar* theRHS) 02110 { 02111 const XalanDOMString::size_type theLength = length(theLHS); 02112 02113 return theLength != length(theRHS) ? false : 02114 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 02115 } 02116 02117 02118 02127 inline bool 02128 equalsIgnoreCaseASCII( 02129 const XalanDOMString& theLHS, 02130 const XalanDOMString& theRHS) 02131 { 02132 const XalanDOMString::size_type theLength = length(theLHS); 02133 02134 return theLength != length(theRHS) ? false : 02135 equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength); 02136 } 02137 02138 02139 02148 inline bool 02149 equalsIgnoreCaseASCII( 02150 const XalanDOMChar* theLHS, 02151 const XalanDOMString& theRHS) 02152 { 02153 const XalanDOMString::size_type theRHSLength = length(theRHS); 02154 02155 return theRHSLength != length(theLHS) ? false : 02156 equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength); 02157 } 02158 02159 02160 02169 inline bool 02170 equalsIgnoreCaseASCII( 02171 const XalanDOMString& theLHS, 02172 const XalanDOMChar* theRHS) 02173 { 02174 return equalsIgnoreCaseASCII(theRHS, theLHS); 02175 } 02176 02177 02178 02188 inline bool 02189 operator<( 02190 const CharVectorType& theLHS, 02191 const CharVectorType& theRHS) 02192 { 02193 return compare(theLHS, theRHS) < 0 ? true : false; 02194 } 02195 02196 02197 02207 inline bool 02208 operator<( 02209 const XalanDOMString& theLHS, 02210 const XalanDOMString& theRHS) 02211 { 02212 return compare(theLHS, theRHS) < 0 ? true : false; 02213 } 02214 02215 02216 02225 inline XalanDOMString& 02226 assign( 02227 XalanDOMString& theString, 02228 const XalanDOMString& theStringToAssign) 02229 { 02230 theString = theStringToAssign; 02231 02232 return theString; 02233 } 02234 02235 02236 02245 inline XalanDOMString& 02246 assign( 02247 XalanDOMString& theString, 02248 const XalanDOMChar* theStringToAssign, 02249 XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos) 02250 { 02251 if (theStringToAssignLength == XalanDOMString::npos) 02252 { 02253 theString.assign(theStringToAssign); 02254 } 02255 else 02256 { 02257 theString.assign(theStringToAssign, theStringToAssignLength); 02258 } 02259 02260 return theString; 02261 } 02262 02263 02264 02272 inline XalanDOMString& 02273 append( 02274 XalanDOMString& theString, 02275 const XalanDOMString& theStringToAppend) 02276 { 02277 theString.append(theStringToAppend); 02278 02279 return theString; 02280 } 02281 02282 02283 02292 inline XalanDOMString& 02293 append( 02294 XalanDOMString& theString, 02295 const XalanDOMChar* theStringToAppend, 02296 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02297 { 02298 assert(theStringToAppend != 0); 02299 02300 if (theStringToAppendLength == XalanDOMString::npos) 02301 { 02302 theString.append(theStringToAppend); 02303 } 02304 else 02305 { 02306 theString.append(theStringToAppend, theStringToAppendLength); 02307 } 02308 02309 return theString; 02310 } 02311 02312 02313 02322 inline XalanDOMString& 02323 append( 02324 XalanDOMString& theString, 02325 const char* theStringToAppend, 02326 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02327 { 02328 theString.append(TranscodeFromLocalCodePage(theStringToAppend, theStringToAppendLength)); 02329 02330 return theString; 02331 } 02332 02333 02334 02342 inline XalanDOMString& 02343 append( 02344 XalanDOMString& theString, 02345 const XalanDOMChar theCharToAppend) 02346 { 02347 theString.append(1, theCharToAppend); 02348 02349 return theString; 02350 } 02351 02352 02353 02361 inline XalanDOMString& 02362 append( 02363 XalanDOMString& theString, 02364 char theCharToAppend) 02365 { 02366 // We have to transcode before appending... 02367 char theTempBuffer[] = { theCharToAppend, '\0' }; 02368 02369 return append(theString, theTempBuffer); 02370 } 02371 02372 02373 02382 inline XalanDOMString& 02383 insert( 02384 XalanDOMString& theString, 02385 XalanDOMString::size_type thePosition, 02386 const XalanDOMString& theStringToInsert) 02387 { 02388 theString.insert(thePosition, theStringToInsert); 02389 02390 return theString; 02391 } 02392 02393 02394 02403 inline XalanDOMString& 02404 insert( 02405 XalanDOMString& theString, 02406 XalanDOMString::size_type thePosition, 02407 const XalanDOMChar* theStringToInsert) 02408 { 02409 theString.insert(thePosition, theStringToInsert); 02410 02411 return theString; 02412 } 02413 02414 02415 02422 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 02423 trim(const XalanDOMString& theString); 02424 02425 02426 02432 inline void 02433 clear(XalanDOMString& theString) 02434 { 02435 theString.clear(); 02436 } 02437 02438 02439 02445 inline void 02446 erase(XalanDOMString& theString) 02447 { 02448 theString.erase(); 02449 } 02450 02451 02452 02459 inline void 02460 releaseMemory(XalanDOMString& theString) 02461 { 02462 XalanDOMString().swap(theString); 02463 } 02464 02465 02466 02467 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02468 CopyWideStringToVector( 02469 const XalanDOMChar* theString, 02470 CharVectorType& theVector); 02471 02472 02473 02474 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02475 CopyStringToVector( 02476 const char* theString, 02477 CharVectorType& theVector); 02478 02479 02480 02489 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02490 MakeXalanDOMCharVector( 02491 const char* data, 02492 bool fTranscode = true); 02493 02494 02495 02503 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02504 MakeXalanDOMCharVector(const XalanDOMChar* data); 02505 02506 02507 02515 inline XalanDOMCharVectorType 02516 MakeXalanDOMCharVector(const XalanDOMString& data) 02517 { 02518 return MakeXalanDOMCharVector(c_wstr(data)); 02519 } 02520 02521 02522 02523 #if defined(XALAN_NO_STD_NAMESPACE) 02524 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02525 #else 02526 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02527 #endif 02528 { 02529 result_type 02530 operator() (const argument_type& theString) const 02531 { 02532 return c_wstr(theString); 02533 } 02534 }; 02535 02536 02537 02544 #if defined(XALAN_NO_STD_NAMESPACE) 02545 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 02546 #else 02547 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 02548 #endif 02549 { 02550 result_type 02551 operator() (argument_type theKey) const 02552 { 02553 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 02554 02555 result_type theHashValue = 0; 02556 02557 if (theRawBuffer != 0) 02558 { 02559 while (*theRawBuffer) 02560 { 02561 theHashValue = 5 * theHashValue + *theRawBuffer; 02562 02563 theRawBuffer++; 02564 } 02565 } 02566 02567 return theHashValue++; 02568 } 02569 }; 02570 02571 02572 02580 #if defined(XALAN_NO_STD_NAMESPACE) 02581 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02582 #else 02583 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02584 #endif 02585 { 02586 result_type 02587 operator() (first_argument_type theLHS, 02588 second_argument_type theRHS) const 02589 { 02590 return equals(theLHS, theRHS); 02591 } 02592 }; 02593 02594 02595 02603 #if defined(XALAN_NO_STD_NAMESPACE) 02604 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02605 #else 02606 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02607 #endif 02608 { 02609 result_type 02610 operator() (first_argument_type theLHS, 02611 second_argument_type theRHS) const 02612 { 02613 return !equals(theLHS, theRHS); 02614 } 02615 }; 02616 02617 02618 02626 #if defined(XALAN_NO_STD_NAMESPACE) 02627 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02628 #else 02629 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02630 #endif 02631 { 02632 result_type 02633 operator() (first_argument_type theLHS, 02634 second_argument_type theRHS) const 02635 { 02636 return compare(theLHS, theRHS) < 0 ? true : false; 02637 } 02638 }; 02639 02640 02641 02649 #if defined(XALAN_NO_STD_NAMESPACE) 02650 struct DOMStringPointerLessThanFunction : public binary_function<const XalanDOMString*, const XalanDOMString*, bool> 02651 #else 02652 struct DOMStringPointerLessThanFunction : public std::binary_function<const XalanDOMString*, const XalanDOMString*, bool> 02653 #endif 02654 { 02655 result_type 02656 operator() (first_argument_type theLHS, 02657 second_argument_type theRHS) const 02658 { 02659 assert(theLHS != 0 && theRHS != 0); 02660 02661 return compare(*theLHS, *theRHS) < 0 ? true : false; 02662 } 02663 }; 02664 02665 02666 02674 #if defined(XALAN_NO_STD_NAMESPACE) 02675 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02676 #else 02677 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02678 #endif 02679 { 02680 result_type 02681 operator() (first_argument_type theLHS, 02682 second_argument_type theRHS) const 02683 { 02684 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02685 } 02686 }; 02687 02688 02689 02697 #if defined(XALAN_NO_STD_NAMESPACE) 02698 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02699 #else 02700 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02701 #endif 02702 { 02703 result_type 02704 operator() (first_argument_type theLHS, 02705 second_argument_type theRHS) const 02706 { 02707 return compare(theLHS, theRHS) <= 0 ? true : false; 02708 } 02709 }; 02710 02711 02712 02720 #if defined(XALAN_NO_STD_NAMESPACE) 02721 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02722 #else 02723 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02724 #endif 02725 { 02726 result_type 02727 operator() (first_argument_type theLHS, 02728 second_argument_type theRHS) const 02729 { 02730 return compare(theLHS, theRHS) > 0 ? true : false; 02731 } 02732 }; 02733 02734 02735 02743 #if defined(XALAN_NO_STD_NAMESPACE) 02744 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02745 #else 02746 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02747 #endif 02748 { 02749 result_type 02750 operator() (first_argument_type theLHS, 02751 second_argument_type theRHS) const 02752 { 02753 return compare(theLHS, theRHS) >= 0 ? true : false; 02754 } 02755 }; 02756 02757 02758 02764 #if defined(XALAN_NO_STD_NAMESPACE) 02765 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02766 #else 02767 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02768 #endif 02769 { 02778 result_type 02779 operator()( 02780 first_argument_type theLHS, 02781 second_argument_type theRHS) const 02782 { 02783 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02784 } 02785 }; 02786 02787 02788 02795 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02796 isXMLWhitespace(const XalanDOMString& string); 02797 02798 02799 02808 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02809 isXMLWhitespace( 02810 const XalanDOMChar ch[], 02811 XalanDOMString::size_type start, 02812 XalanDOMString::size_type length); 02813 02814 02815 02822 inline bool 02823 isXMLWhitespace(const XalanDOMChar* theString) 02824 { 02825 assert(theString != 0); 02826 02827 return isXMLWhitespace(theString, 0, length(theString)); 02828 } 02829 02830 02831 02832 XALAN_CPP_NAMESPACE_END 02833 02834 02835 02836 #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.8 |
|