00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(DOMSTRINGHELPER_HEADER_GUARD_1357924680) 00019 #define DOMSTRINGHELPER_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <algorithm> 00029 #include <cassert> 00030 #include <functional> 00031 #if defined(XALAN_CLASSIC_IOSTREAMS) 00032 class ostream; 00033 #else 00034 #include <iosfwd> 00035 #endif 00036 00037 00038 00039 #include <xalanc/Include/XalanVector.hpp> 00040 #include <xalanc/Include/XalanMap.hpp> 00041 #include <xalanc/Include/XalanMemoryManagement.hpp> 00042 #include <xalanc/Include/STLHelper.hpp> 00043 00044 00045 00046 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00047 00048 00049 00050 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00051 #include <xalanc/PlatformSupport/XalanUnicode.hpp> 00052 #include <xalanc/PlatformSupport/XalanXMLChar.hpp> 00053 00054 00055 00056 XALAN_CPP_NAMESPACE_BEGIN 00057 00058 00059 00060 XALAN_USING_XERCES(MemoryManager) 00061 00062 00063 00064 class XalanOutputStream; 00065 00066 00067 00068 template<class InputIteratorType, class OutputIteratorType> 00069 inline OutputIteratorType 00070 XalanCopy( 00071 InputIteratorType begin, 00072 InputIteratorType end, 00073 OutputIteratorType iterator) 00074 { 00075 return XALAN_STD_QUALIFIER copy(begin, end, iterator); 00076 } 00077 00078 00079 00080 template<class InputIteratorType, class OutputIteratorType, class UnaryFunction> 00081 inline OutputIteratorType 00082 XalanTransform( 00083 InputIteratorType begin, 00084 InputIteratorType end, 00085 OutputIteratorType iterator, 00086 UnaryFunction function) 00087 { 00088 return XALAN_STD_QUALIFIER transform(begin, end, iterator); 00089 } 00090 00091 00092 00093 /** 00094 * Get the underlying representation of the target XalanDOMString as a 00095 * null-terminated string 00096 * 00097 * @deprecated This function is deprecated. 00098 * 00099 * @param theString target string 00100 * @return null-terminated string of XalanDOMChar 00101 */ 00102 inline const XalanDOMChar* 00103 c_wstr(const XalanDOMString& theString) 00104 { 00105 return theString.c_str(); 00106 } 00107 00108 00109 00110 /** 00111 * Get the underlying representation of the target CharVectorType as a 00112 * null-terminated string 00113 * 00114 * @param theString target string 00115 * @return null-terminated string of chars 00116 */ 00117 inline const char* 00118 c_str(const CharVectorType& theString) 00119 { 00120 if (theString.empty() == true) 00121 { 00122 return 0; 00123 } 00124 else 00125 { 00126 const char* const ptr = &theString[0]; 00127 00128 assert(ptr[theString.size() - 1] == '\0'); 00129 00130 return ptr; 00131 } 00132 } 00133 00134 00135 00136 /** 00137 * Get the underlying representation of the wide string as a 00138 * UNICODE null-terminated string. This is here simply for 00139 * consistency in the code. On certain platforms, compiler- 00140 * generated wide strings will not contain Unicode code 00141 * points. Another macro converts those into XalanDOMStrings, 00142 * which are then transcoded. In these cases, the previous 00143 * defined c_sstr() function gets called. 00144 * 00145 * On platforms where the compiler does generate Unicode wide 00146 * strings, this function will be called instead. 00147 * 00148 * @deprecated This function is deprecated. 00149 * 00150 * @param theString target string 00151 * @return null-terminated string of XalanDOMChar 00152 */ 00153 inline const XalanDOMChar* 00154 c_wstr(const XalanDOMChar* theString) 00155 { 00156 return theString; 00157 } 00158 00159 00160 00161 /** 00162 * Get the underlying representation of the target XalanDOMString as an array of 00163 * XalanDOMChar, not guaranteed to be null-terminated. 00164 * 00165 * @deprecated This function is deprecated. 00166 * 00167 * @param theString target string 00168 * @return array of XalanDOMChar 00169 */ 00170 inline const XalanDOMChar* 00171 toCharArray(const XalanDOMString& theString) 00172 { 00173 return theString.c_str(); 00174 } 00175 00176 00177 00178 /** 00179 * Get the underlying representation of a XalanDOMChar. 00180 * 00181 * @deprecated This function is deprecated. 00182 * 00183 * @param theString target string 00184 * @return array of XalanDOMChar 00185 */ 00186 inline const XalanDOMChar* 00187 toCharArray(const XalanDOMChar* theString) 00188 { 00189 return theString; 00190 } 00191 00192 00193 00194 /** 00195 * Get the underlying representation of the target CharVectorType as a 00196 * pointer to an array of characters 00197 * 00198 * @deprecated This function is deprecated. 00199 * 00200 * @param theString target string 00201 * @return the pointer 00202 */ 00203 inline const char* 00204 toCharArray(const CharVectorType& theString) 00205 { 00206 return theString.empty() == true ? 0 : &theString[0]; 00207 } 00208 00209 00210 00211 /** 00212 * Reserve some space in the string for more efficient 00213 * concatenation... 00214 * 00215 * @deprecated This function is deprecated. 00216 * 00217 * @param theString target string 00218 * @param theCount The amount of space to reserve 00219 */ 00220 inline void 00221 reserve( 00222 XalanDOMString& theString, 00223 XalanDOMString::size_type theCount) 00224 { 00225 theString.reserve(theCount); 00226 } 00227 00228 00229 00230 /** 00231 * Get the length of a XalanDOMString 00232 * 00233 * @deprecated This function is deprecated. 00234 * 00235 * @param theString target string 00236 * @return the length of the target string 00237 */ 00238 inline XalanDOMString::size_type 00239 length(const XalanDOMString& theString) 00240 { 00241 return theString.length(); 00242 } 00243 00244 00245 00246 /** 00247 * Get the length of a null-terminated string of 00248 * XalanDOMChar characters 00249 * 00250 * @param theString target string 00251 * @return the length of the target string 00252 */ 00253 inline XalanDOMString::size_type 00254 length(const XalanDOMChar* theString) 00255 { 00256 assert(theString != 0); 00257 00258 const XalanDOMChar* theBufferPointer = theString; 00259 00260 while(*theBufferPointer != 0) 00261 { 00262 theBufferPointer++; 00263 } 00264 00265 return XalanDOMString::size_type(theBufferPointer - theString); 00266 } 00267 00268 00269 00270 /** 00271 * Get the length of a null-terminated string. 00272 * 00273 * @param theString target string 00274 * @return the length of the target string 00275 */ 00276 inline XalanDOMString::size_type 00277 length(const char* theString) 00278 { 00279 assert(theString != 0); 00280 00281 return XalanDOMString::length(theString); 00282 } 00283 00284 00285 00286 /** 00287 * Determines if the target string contains any elements 00288 * 00289 * @deprecated This function is deprecated. 00290 * 00291 * @param str target string 00292 * @return true if the target string has a non-zero length 00293 */ 00294 inline bool 00295 isEmpty(const XalanDOMString& str) 00296 { 00297 return str.empty(); 00298 } 00299 00300 00301 00302 /** 00303 * Simulates the java String method indexOf(). 00304 * 00305 * @param theString string to search 00306 * @param theChar character searched for 00307 * @return the index of theChar in theString, 00308 * or length(theString) if the character is not 00309 * found. 00310 */ 00311 inline XalanDOMString::size_type 00312 indexOf( 00313 const XalanDOMChar* theString, 00314 XalanDOMChar theChar) 00315 { 00316 assert(theString != 0); 00317 00318 const XalanDOMChar* thePointer = theString; 00319 00320 while(*thePointer != theChar && *thePointer != 0) 00321 { 00322 ++thePointer; 00323 } 00324 00325 return XalanDOMString::size_type(thePointer - theString); 00326 } 00327 00328 00329 00330 /** 00331 * Simulates the java String method indexOf(). 00332 * 00333 * @param theString string to search 00334 * @param theStringLength the length of theString 00335 * @param theChar character searched for 00336 * @return the index of theChar in theString, 00337 * or length(theString) if the character is not 00338 * found. 00339 */ 00340 inline XalanDOMString::size_type 00341 indexOf( 00342 const XalanDOMChar* theString, 00343 XalanDOMString::size_type theStringLength, 00344 XalanDOMChar theChar) 00345 { 00346 assert(theString != 0); 00347 00348 const XalanDOMChar* thePointer = theString; 00349 const XalanDOMChar* const theEndPointer = theString + theStringLength; 00350 00351 while(*thePointer != theChar && thePointer != theEndPointer) 00352 { 00353 ++thePointer; 00354 } 00355 00356 return XalanDOMString::size_type(thePointer - theString); 00357 } 00358 00359 00360 00361 /** 00362 * Simulates the java String method indexOf(). 00363 * 00364 * @param theString string to search 00365 * @param theChar character searched for 00366 * @return the index of theChar in theString, 00367 * or length(theString) if the character is not 00368 * found. 00369 */ 00370 inline XalanDOMString::size_type 00371 indexOf( 00372 const XalanDOMString& theString, 00373 XalanDOMChar theChar) 00374 { 00375 return theString.length() == 0 ? 0 : indexOf(theString.c_str(), theChar); 00376 } 00377 00378 00379 00380 /** 00381 * Simulates the java String method indexOf(). 00382 * 00383 * @param theString string to search 00384 * @param theStringLength length of the string to search 00385 * @param theSubstring substring searched for 00386 * @param theSubstringLength length of the substring searched for 00387 * @return the index of theSubstring in theString, 00388 * or length(theString) if the string is not 00389 * found. 00390 */ 00391 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00392 indexOf( 00393 const XalanDOMChar* theString, 00394 XalanDOMString::size_type theStringLength, 00395 const XalanDOMChar* theSubstring, 00396 XalanDOMString::size_type theSubstringLength); 00397 00398 00399 00400 /** 00401 * Simulates the java String method indexOf(). 00402 * 00403 * @param theString string to search 00404 * @param theSubstring substring searched for 00405 * @return the index of theSubstring in theString, 00406 * or length(theString) if the string is not 00407 * found. 00408 */ 00409 inline XalanDOMString::size_type 00410 indexOf( 00411 const XalanDOMChar* theString, 00412 const XalanDOMChar* theSubstring) 00413 { 00414 assert(theString != 0 && theSubstring != 0); 00415 00416 return indexOf(theString, length(theString), theSubstring, length(theSubstring)); 00417 } 00418 00419 00420 00421 /** 00422 * Simulates the java String method indexOf(). 00423 * 00424 * @param theString string to search 00425 * @param theSubstring substring searched for 00426 * @return the index of theSubstring in theString, 00427 * or length(theString) if the string is not 00428 * found. 00429 */ 00430 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00431 indexOf( 00432 const XalanDOMString& theString, 00433 const XalanDOMString& theSubstring); 00434 00435 00436 00437 /** 00438 * Simulates the java String method lastIndexOf(). 00439 * 00440 * @param theString string to search 00441 * @param theChar character searched for 00442 * @return the index of theChar in theString, 00443 * or length(theString) if the character is not 00444 * found. 00445 */ 00446 00447 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00448 lastIndexOf( 00449 const XalanDOMChar* theString, 00450 XalanDOMChar theChar); 00451 00452 00453 00454 /** 00455 * Simulates the java String method lastIndexOf(). 00456 * 00457 * @param theString string to search 00458 * @param theChar character searched for 00459 * @return the index of theChar in theString, 00460 * or length(theString) if the character is not 00461 * found. 00462 */ 00463 inline XalanDOMString::size_type 00464 lastIndexOf( 00465 const XalanDOMString& theString, 00466 XalanDOMChar theChar) 00467 { 00468 return lastIndexOf(theString.c_str(), theChar); 00469 } 00470 00471 00472 00473 /** 00474 * Simulates the java String method startsWith(). 00475 * 00476 * @param theString target string to search 00477 * @param theStringLength the length of theString 00478 * @param theSubstring substring searched for 00479 * @param theSubstringLength the length of theSubstring 00480 * @return true if the target string begins with the substring 00481 */ 00482 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00483 startsWith( 00484 const XalanDOMChar* theString, 00485 XalanDOMString::size_type theStringLength, 00486 const XalanDOMChar* theSubstring, 00487 XalanDOMString::size_type theSubstringLength); 00488 00489 00490 00491 /** 00492 * Simulates the java String method startsWith(). 00493 * 00494 * @param theDOMString target string to search 00495 * @param theSubstring substring searched for 00496 * @return true if the target string begins with the substring 00497 */ 00498 inline bool 00499 startsWith( 00500 const XalanDOMChar* theString, 00501 const XalanDOMChar* theSubstring) 00502 { 00503 assert(theString != 0 && theSubstring != 0); 00504 00505 return startsWith(theString, length(theString), theSubstring, length(theSubstring)); 00506 } 00507 00508 00509 00510 /** 00511 * Simulates the java String method startsWith(). 00512 * 00513 * @param theDOMString target string to search 00514 * @param theSubstring substring searched for 00515 * @return true if the target string begins with the substring 00516 */ 00517 inline bool 00518 startsWith( 00519 const XalanDOMChar* theString, 00520 const XalanDOMString& theSubstring) 00521 { 00522 assert(theString != 0); 00523 00524 return startsWith( 00525 theString, 00526 length(theString), 00527 theSubstring.c_str(), 00528 theSubstring.length()); 00529 } 00530 00531 00532 00533 /** 00534 * Simulates the java String method startsWith(). 00535 * 00536 * @param theDOMString target string to search 00537 * @param theSubstring substring searched for 00538 * @return true if the target string begins with the substring 00539 */ 00540 inline bool 00541 startsWith( 00542 const XalanDOMString& theString, 00543 const XalanDOMChar* theSubstring) 00544 { 00545 assert(theSubstring != 0); 00546 00547 return startsWith( 00548 theString.c_str(), 00549 theString.length(), 00550 theSubstring, 00551 length(theSubstring)); 00552 } 00553 00554 00555 00556 /** 00557 * Simulates the java String method startsWith(). 00558 * 00559 * @param theDOMString target string to search 00560 * @param theSubstring substring searched for 00561 * @param theSubstringLength the length of theSubstring 00562 * @return true if the target string begins with the substring 00563 */ 00564 inline bool 00565 startsWith( 00566 const XalanDOMString& theString, 00567 const XalanDOMChar* theSubstring, 00568 XalanDOMString::size_type theSubstringLength) 00569 { 00570 assert(theSubstring != 0); 00571 00572 return startsWith( 00573 theString.c_str(), 00574 theString.length(), 00575 theSubstring, 00576 theSubstringLength); 00577 } 00578 00579 00580 00581 /** 00582 * Simulates the java String method startsWith(). 00583 * 00584 * @param theDOMString target string to search 00585 * @param theSubstring substring searched for 00586 * @return true if the target string begins with the substring 00587 */ 00588 inline bool 00589 startsWith( 00590 const XalanDOMString& theString, 00591 const XalanDOMString& theSubstring) 00592 { 00593 return startsWith( 00594 theString.c_str(), 00595 theString.length(), 00596 theSubstring.c_str(), 00597 theSubstring.length()); 00598 } 00599 00600 00601 00602 /** 00603 * Simulates the java String method endsWith(). 00604 * 00605 * @param theString target string to search 00606 * @param theSubstring substring searched for 00607 * @return true if the target string ends with the substring 00608 */ 00609 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00610 endsWith( 00611 const XalanDOMChar* theString, 00612 XalanDOMString::size_type theStringLength, 00613 const XalanDOMChar* theSubstring, 00614 XalanDOMString::size_type theSubstringLength); 00615 00616 00617 00618 /** 00619 * Simulates the java String method endsWith(). 00620 * 00621 * @param theString target string to search 00622 * @param theSubstring substring searched for 00623 * @return true if the target string ends with the substring 00624 */ 00625 inline bool 00626 endsWith( 00627 const XalanDOMChar* theString, 00628 const XalanDOMChar* theSubstring) 00629 { 00630 assert(theString != 0 && theSubstring != 0); 00631 00632 return endsWith( 00633 theString, 00634 length(theString), 00635 theSubstring, 00636 length(theSubstring)); 00637 } 00638 00639 00640 00641 /** 00642 * Simulates the java String method endsWith(). 00643 * 00644 * @param theString target string to search 00645 * @param theSubstring substring searched for 00646 * @return true if the target string ends with the substring 00647 */ 00648 inline bool 00649 endsWith( 00650 const XalanDOMString& theString, 00651 const XalanDOMString& theSubstring) 00652 { 00653 return endsWith( 00654 theString.c_str(), 00655 theString.length(), 00656 theSubstring.c_str(), 00657 theSubstring.length()); 00658 } 00659 00660 00661 00662 /** 00663 * Converts a pointer into a XalanDOMString 00664 * 00665 * @param theValue pointer to be converted 00666 * @param theResult the string to append with the result 00667 * @return a reference to the passed string result. 00668 */ 00669 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00670 PointerToDOMString( 00671 const void* theValue, 00672 XalanDOMString& theResult); 00673 00674 00675 00676 class XALAN_PLATFORMSUPPORT_EXPORT DOMStringHelper 00677 { 00678 public: 00679 00680 typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const FormatterListener::size_type); 00681 00682 00683 static void 00684 initialize(MemoryManager& theMemoryManager); 00685 00686 static void 00687 terminate(); 00688 00689 static void 00690 NumberToCharacters( 00691 double theValue, 00692 FormatterListener& formatterListener, 00693 MemberFunctionPtr function); 00694 00695 static void 00696 NumberToCharacters( 00697 long theValue, 00698 FormatterListener& formatterListener, 00699 MemberFunctionPtr function); 00700 00701 static void 00702 NumberToCharacters( 00703 XALAN_INT64 theValue, 00704 FormatterListener& formatterListener, 00705 MemberFunctionPtr function); 00706 }; 00707 00708 00709 00710 /** 00711 * Converts a double value into a XalanDOMString 00712 * 00713 * @param theValue number to be converted 00714 * @param theResult the string to append with the result 00715 * @return a reference to the passed string result. 00716 */ 00717 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00718 NumberToDOMString( 00719 double theValue, 00720 XalanDOMString& theResult); 00721 00722 00723 00724 /** 00725 * Converts an 64-bit unsigned value into a XalanDOMString 00726 * 00727 * @param theValue number to be converted 00728 * @param theResult the string to append with the result 00729 * @return a reference to the passed string result. 00730 */ 00731 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00732 NumberToDOMString( 00733 XALAN_UINT64 theValue, 00734 XalanDOMString& theResult); 00735 00736 00737 00738 /** 00739 * Converts an 64-bit signed value into a XalanDOMString 00740 * 00741 * @param theValue number to be converted 00742 * @param theResult the string to append with the result 00743 * @return a reference to the passed string result. 00744 */ 00745 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00746 NumberToDOMString( 00747 XALAN_INT64 theValue, 00748 XalanDOMString& theResult); 00749 00750 00751 00752 /** 00753 * Converts an unsigned long value into a XalanDOMString 00754 * 00755 * @param theValue number to be converted 00756 * @param theResult the string to append with the result 00757 * @return a reference to the passed string result. 00758 */ 00759 inline XalanDOMString& 00760 NumberToDOMString( 00761 unsigned long theValue, 00762 XalanDOMString& theResult) 00763 { 00764 return NumberToDOMString( 00765 static_cast<XALAN_UINT64>(theValue), 00766 theResult); 00767 } 00768 00769 00770 00771 /** 00772 * Converts a XalanSSize_t value into a XalanDOMString 00773 * 00774 * @param theValue number to be converted 00775 * @param theResult the string to append with the result 00776 * @return a reference to the passed string result. 00777 */ 00778 inline XalanDOMString& 00779 NumberToDOMString( 00780 long theValue, 00781 XalanDOMString& theResult) 00782 { 00783 return NumberToDOMString( 00784 static_cast<XALAN_INT64>(theValue), 00785 theResult); 00786 } 00787 00788 00789 00790 /** 00791 * Converts an unsigned int value into a XalanDOMString 00792 * 00793 * @param theValue number to be converted 00794 * @param theResult the string to append with the result 00795 * @return a reference to the passed string result. 00796 */ 00797 inline XalanDOMString& 00798 NumberToDOMString( 00799 unsigned int theValue, 00800 XalanDOMString& theResult) 00801 { 00802 return NumberToDOMString( 00803 static_cast<XALAN_UINT64>(theValue), 00804 theResult); 00805 } 00806 00807 00808 00809 /** 00810 * Converts an int value into a XalanDOMString 00811 * 00812 * @param theValue number to be converted 00813 * @param theResult the string to append with the result 00814 * @return a reference to the passed string result. 00815 */ 00816 inline XalanDOMString& 00817 NumberToDOMString( 00818 int theValue, 00819 XalanDOMString& theResult) 00820 { 00821 return NumberToDOMString( 00822 static_cast<XALAN_INT64>(theValue), 00823 theResult); 00824 } 00825 00826 00827 00828 /** 00829 * Converts an unsigned short value into a XalanDOMString 00830 * 00831 * @param theValue number to be converted 00832 * @param theResult the string to append with the result 00833 * @return a reference to the passed string result. 00834 */ 00835 inline XalanDOMString& 00836 NumberToDOMString( 00837 unsigned short theValue, 00838 XalanDOMString& theResult) 00839 { 00840 return NumberToDOMString( 00841 static_cast<XALAN_UINT64>(theValue), 00842 theResult); 00843 } 00844 00845 00846 00847 /** 00848 * Converts a short value into a XalanDOMString 00849 * 00850 * @param theValue number to be converted 00851 * @param theResult the string to append with the result 00852 * @return a reference to the passed string result. 00853 */ 00854 inline XalanDOMString& 00855 NumberToDOMString( 00856 short theValue, 00857 XalanDOMString& theResult) 00858 { 00859 return NumberToDOMString( 00860 static_cast<XALAN_INT64>(theValue), 00861 theResult); 00862 } 00863 00864 00865 00866 /** 00867 * Converts an 64-bit unsigned value into a XalanDOMString 00868 * 00869 * @param theValue number to be converted 00870 * @param theResult the string to append with the result 00871 * @return a reference to the passed string result. 00872 */ 00873 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00874 NumberToHexDOMString( 00875 XALAN_UINT64 theValue, 00876 XalanDOMString& theResult); 00877 00878 00879 00880 /** 00881 * Converts an 64-bit signed value into a XalanDOMString 00882 * 00883 * @param theValue number to be converted 00884 * @param theResult the string to append with the result 00885 * @return a reference to the passed string result. 00886 */ 00887 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 00888 NumberToHexDOMString( 00889 XALAN_INT64 theValue, 00890 XalanDOMString& theResult); 00891 00892 00893 00894 /** 00895 * Converts a XalanSSize_t value into a XalanDOMString 00896 * 00897 * @param theValue number to be converted 00898 * @param theResult the string to append with the result 00899 * @return a reference to the passed string result. 00900 */ 00901 inline XalanDOMString& 00902 NumberToHexDOMString( 00903 unsigned long theValue, 00904 XalanDOMString& theResult) 00905 { 00906 return NumberToHexDOMString( 00907 static_cast<XALAN_UINT64>(theValue), 00908 theResult); 00909 } 00910 00911 00912 00913 /** 00914 * Converts a XalanSSize_t value into a XalanDOMString 00915 * 00916 * @param theValue number to be converted 00917 * @param theResult the string to append with the result 00918 * @return a reference to the passed string result. 00919 */ 00920 inline XalanDOMString& 00921 NumberToHexDOMString( 00922 long theValue, 00923 XalanDOMString& theResult) 00924 { 00925 return NumberToHexDOMString( 00926 static_cast<XALAN_INT64>(theValue), 00927 theResult); 00928 } 00929 00930 00931 00932 /** 00933 * Converts an unsigned int value into a XalanDOMString 00934 * 00935 * @param theValue number to be converted 00936 * @param theResult the string to append with the result 00937 * @return a reference to the passed string result. 00938 */ 00939 inline XalanDOMString& 00940 NumberToHexDOMString( 00941 unsigned int theValue, 00942 XalanDOMString& theResult) 00943 { 00944 return NumberToHexDOMString( 00945 static_cast<XALAN_UINT64>(theValue), 00946 theResult); 00947 } 00948 00949 00950 00951 /** 00952 * Converts an int value into a XalanDOMString 00953 * 00954 * @param theValue number to be converted 00955 * @param theResult the string to append with the result 00956 * @return a reference to the passed string result. 00957 */ 00958 inline XalanDOMString& 00959 NumberToHexDOMString( 00960 int theValue, 00961 XalanDOMString& theResult) 00962 { 00963 return NumberToHexDOMString( 00964 static_cast<XALAN_INT64>(theValue), 00965 theResult); 00966 } 00967 00968 00969 00970 /** 00971 * Converts an unsigned short value into a XalanDOMString 00972 * 00973 * @param theValue number to be converted 00974 * @param theResult the string to append with the result 00975 * @return a reference to the passed string result. 00976 */ 00977 inline XalanDOMString& 00978 NumberToHexDOMString( 00979 unsigned short theValue, 00980 XalanDOMString& theResult) 00981 { 00982 return NumberToHexDOMString( 00983 static_cast<XALAN_UINT64>(theValue), 00984 theResult); 00985 } 00986 00987 00988 00989 /** 00990 * Converts a short value into a XalanDOMString 00991 * 00992 * @param theValue number to be converted 00993 * @param theResult the string to append with the result 00994 * @return a reference to the passed string result. 00995 */ 00996 inline XalanDOMString& 00997 NumberToHexDOMString( 00998 short theValue, 00999 XalanDOMString& theResult) 01000 { 01001 return NumberToHexDOMString( 01002 static_cast<XALAN_INT64>(theValue), 01003 theResult); 01004 } 01005 01006 01007 01008 /** 01009 * Converts a wide string into an integer value 01010 * 01011 * @param theString target string 01012 * @return integer value of target string 01013 */ 01014 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01015 WideStringToInt(const XalanDOMChar* theString); 01016 01017 01018 01019 /** 01020 * Converts a wide string into a long value 01021 * 01022 * @param theString target string 01023 * @return long value of target string 01024 */ 01025 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 01026 WideStringToLong(const XalanDOMChar* theString); 01027 01028 01029 01030 /** 01031 * Converts a wide string into an unsigned long value 01032 * 01033 * @param theString target string 01034 * @return unsigned long value of target string 01035 */ 01036 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 01037 WideStringToUnsignedLong(const XalanDOMChar* theString); 01038 01039 01040 01041 /** 01042 * Converts a wide string into a double value 01043 * 01044 * @param theString target string 01045 * @param theMemoryManager The MemoryManager instance to use. 01046 * @return double value of target string 01047 */ 01048 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 01049 WideStringToDouble( 01050 const XalanDOMChar* theString, 01051 MemoryManager& theMemoryManager); 01052 01053 01054 01055 /** 01056 * Converts a XalanDOMString into an integer value 01057 * 01058 * @param theString target string 01059 * @return integer value of target string 01060 */ 01061 inline int 01062 DOMStringToInt(const XalanDOMString& theString) 01063 { 01064 return WideStringToInt(theString.c_str()); 01065 } 01066 01067 01068 01069 /** 01070 * Converts a XalanDOMString into a long value 01071 * 01072 * @param theString target string 01073 * @return long value of target string 01074 */ 01075 inline long 01076 DOMStringToLong(const XalanDOMString& theString) 01077 { 01078 return WideStringToLong(theString.c_str()); 01079 } 01080 01081 01082 01083 /** 01084 * Converts a XalanDOMString into a long value 01085 * 01086 * @param theString target string 01087 * @return unsigned long value of target string 01088 */ 01089 inline unsigned long 01090 DOMStringToUnsignedLong(const XalanDOMString& theString) 01091 { 01092 return WideStringToUnsignedLong(theString.c_str()); 01093 } 01094 01095 01096 01097 /** 01098 * Converts a XalanDOMString into a double value 01099 * 01100 * @param theString target string 01101 * @param theMemoryManager The MemoryManager instance to use. 01102 * @return double value of target string 01103 */ 01104 inline double 01105 DOMStringToDouble( 01106 const XalanDOMString& theString, 01107 MemoryManager& theMemoryManager) 01108 { 01109 return WideStringToDouble( 01110 theString.c_str(), 01111 theMemoryManager); 01112 } 01113 01114 01115 01116 /** 01117 * Outputs the target string to the specified stream 01118 * 01119 * @param theStream output stream 01120 * @param theString target string 01121 * @see operator<< 01122 */ 01123 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01124 OutputString( 01125 XalanOutputStream& theStream, 01126 const CharVectorType& theString); 01127 01128 01129 01130 /** 01131 * Outputs the target string to the specified stream 01132 * 01133 * @param theStream output stream 01134 * @param theString target string 01135 * @see operator<< 01136 */ 01137 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01138 OutputString( 01139 #if defined(XALAN_NO_STD_NAMESPACE) 01140 ostream& theStream, 01141 #else 01142 std::ostream& theStream, 01143 #endif 01144 const CharVectorType& theString); 01145 01146 01147 01148 /** 01149 * Outputs the target string to the specified stream 01150 * 01151 * @param theStream output stream 01152 * @param theString target string 01153 * @see operator<< 01154 */ 01155 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01156 OutputString( 01157 XalanOutputStream& theStream, 01158 const XalanDOMChar* theString); 01159 01160 01161 01162 /** 01163 * Outputs the target string to the specified stream 01164 * 01165 * @param theStream output stream 01166 * @param theString target string 01167 * @see operator<< 01168 */ 01169 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01170 OutputString( 01171 #if defined(XALAN_NO_STD_NAMESPACE) 01172 ostream& theStream, 01173 #else 01174 std::ostream& theStream, 01175 #endif 01176 const XalanDOMChar* theString, 01177 MemoryManager& theMemoryManager); 01178 01179 01180 01181 /** 01182 * Outputs the target string to the specified stream 01183 * 01184 * @param theStream output stream 01185 * @param theString target string 01186 * @see operator<< 01187 */ 01188 inline void 01189 OutputString( 01190 XalanOutputStream& theStream, 01191 const XalanDOMString& theString) 01192 { 01193 if (theString.empty() == false) 01194 { 01195 OutputString( 01196 theStream, 01197 theString.c_str()); 01198 } 01199 } 01200 01201 01202 01203 /** 01204 * Outputs the target string to the specified stream 01205 * 01206 * @param theStream output stream 01207 * @param theString target string 01208 * @param theMemoryManager The MemoryManager instance to use. 01209 * @see operator<< 01210 */ 01211 inline void 01212 OutputString( 01213 #if defined(XALAN_NO_STD_NAMESPACE) 01214 ostream& theStream, 01215 #else 01216 std::ostream& theStream, 01217 #endif 01218 const XalanDOMString& theString, 01219 MemoryManager& theMemoryManager) 01220 { 01221 OutputString( 01222 theStream, 01223 theString.c_str(), 01224 theMemoryManager); 01225 } 01226 01227 01228 01229 /** 01230 * Outputs the string to the specified stream 01231 * 01232 * @param theStream output stream 01233 * @param theString the string to output 01234 * @see OutputString 01235 */ 01236 inline XalanOutputStream& 01237 operator<<( 01238 XalanOutputStream& theStream, 01239 const CharVectorType& theString) 01240 { 01241 OutputString( 01242 theStream, 01243 theString); 01244 01245 return theStream; 01246 } 01247 01248 01249 01250 /** 01251 * Outputs the string to the specified stream 01252 * 01253 * @param theStream output stream 01254 * @param theString the string to output 01255 * @see OutputString 01256 */ 01257 #if defined(XALAN_NO_STD_NAMESPACE) 01258 inline ostream& 01259 operator<<( 01260 ostream& theStream, 01261 #else 01262 inline std::ostream& 01263 operator<<( 01264 std::ostream& theStream, 01265 #endif 01266 const CharVectorType& theString) 01267 { 01268 OutputString( 01269 theStream, 01270 theString); 01271 01272 return theStream; 01273 } 01274 01275 01276 01277 /** 01278 * Outputs the target string to the specified stream 01279 * 01280 * @param theStream output stream 01281 * @param theString target string 01282 * @see OutputString 01283 */ 01284 inline XalanOutputStream& 01285 operator<<( 01286 XalanOutputStream& theStream, 01287 const XalanDOMChar* theString) 01288 { 01289 OutputString( 01290 theStream, 01291 theString); 01292 01293 return theStream; 01294 } 01295 01296 01297 01298 /** 01299 * Outputs the target string to the specified stream 01300 * 01301 * @param theStream output stream 01302 * @param theString target string 01303 * @see OutputString 01304 */ 01305 #if defined(XALAN_NO_STD_NAMESPACE) 01306 inline ostream& 01307 operator<<( 01308 ostream& theStream, 01309 #else 01310 inline std::ostream& 01311 operator<<( 01312 std::ostream& theStream, 01313 #endif 01314 const XalanDOMChar* theString) 01315 { 01316 OutputString( 01317 theStream, 01318 theString, 01319 XalanMemMgrs::getDefault()); 01320 01321 return theStream; 01322 } 01323 01324 01325 01326 /** 01327 * Outputs the target string to the specified stream 01328 * 01329 * @param theStream output stream 01330 * @param theString target string 01331 * @see OutputString 01332 */ 01333 inline XalanOutputStream& 01334 operator<<( 01335 XalanOutputStream& theStream, 01336 const XalanDOMString& theString) 01337 { 01338 OutputString(theStream, 01339 theString); 01340 01341 return theStream; 01342 } 01343 01344 01345 01346 /** 01347 * Outputs the target string to the specified stream 01348 * 01349 * @param theStream output stream 01350 * @param theString target string 01351 * @see OutputString 01352 */ 01353 #if defined(XALAN_NO_STD_NAMESPACE) 01354 inline ostream& 01355 operator<<( 01356 ostream& theStream, 01357 #else 01358 inline std::ostream& 01359 operator<<( 01360 std::ostream& theStream, 01361 #endif 01362 const XalanDOMString& theString) 01363 { 01364 OutputString( 01365 theStream, 01366 theString, 01367 XalanMemMgrs::getDefault()); 01368 01369 return theStream; 01370 } 01371 01372 01373 01374 /** 01375 * Outputs the target string to the specified stream 01376 * 01377 * @param theStream output stream 01378 * @param theString target string 01379 * @see OutputString 01380 */ 01381 #if defined(XALAN_NO_STD_NAMESPACE) 01382 inline ostream& 01383 operator<<( 01384 ostream& theStream, 01385 #else 01386 inline std::ostream& 01387 operator<<( 01388 std::ostream& theStream, 01389 #endif 01390 XalanDOMString& theString) 01391 { 01392 OutputString( 01393 theStream, 01394 theString, 01395 theString.getMemoryManager()); 01396 01397 return theStream; 01398 } 01399 01400 01401 01402 /** 01403 * Retrieves a character at a specified index in the target string 01404 * 01405 * @deprecated This function is deprecated. 01406 * 01407 * @param theString target string 01408 * @param theIndex index of character 01409 * @return character at specified index 01410 */ 01411 inline XalanDOMChar 01412 charAt( 01413 const XalanDOMString& theString, 01414 XalanDOMString::size_type theIndex) 01415 { 01416 return theString[theIndex]; 01417 } 01418 01419 01420 01421 /** 01422 * Determines whether character represents white space 01423 * 01424 * @param theChar target character 01425 * @return true if character represents white space 01426 */ 01427 inline bool 01428 isXMLWhitespace(XalanDOMChar theChar) 01429 { 01430 return XalanXMLChar::isWhitespace(theChar); 01431 } 01432 01433 01434 01435 /** 01436 * Determines whether character represents a digit 01437 * 01438 * @param theChar target character 01439 * @return true if character represents a digit 01440 */ 01441 inline bool 01442 isXMLDigit(XalanDOMChar theChar) 01443 { 01444 return XalanXMLChar::isDigit(theChar); 01445 } 01446 01447 01448 01449 /** 01450 * Determines whether character represents a letter or digit 01451 * 01452 * @param theChar target character 01453 * @return true if character represents a letter or digit 01454 */ 01455 inline bool 01456 isXMLLetterOrDigit(XalanDOMChar theChar) 01457 { 01458 return XalanXMLChar::isDigit(theChar) || 01459 XalanXMLChar::isLetter(theChar); 01460 } 01461 01462 01463 01464 01465 01466 01467 /** 01468 * Simulates the java String method substring(). Returns a new string that is 01469 * a substring of this string. The substring begins at the specified 01470 * theStartIndex and extends to the character at index theEndIndex - 1. Thus 01471 * the length of the substring is theEndIndex - theStartIndex. 01472 * 01473 * @param theString source string 01474 * @param theSubstring target string 01475 * @param theStartIndex starting index, inclusive 01476 * @param theEndIndex ending index, exclusive 01477 * @return A reference to theSubstring 01478 */ 01479 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01480 substring( 01481 const XalanDOMChar* theString, 01482 XalanDOMString& theSubstring, 01483 XalanDOMString::size_type theStartIndex, 01484 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01485 01486 01487 01488 /** 01489 * Simulates the java String method substring(). Returns a new string that is 01490 * a substring of this string. The substring begins at the specified 01491 * theStartIndex and extends to the character at index theEndIndex - 1. Thus 01492 * the length of the substring is theEndIndex - theStartIndex. 01493 * 01494 * @param theString source string 01495 * @param theSubstring target string 01496 * @param theStartIndex starting index, inclusive 01497 * @param theEndIndex ending index, exclusive 01498 */ 01499 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01500 substring( 01501 const XalanDOMString& theString, 01502 XalanDOMString& theSubstring, 01503 XalanDOMString::size_type theStartIndex, 01504 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01505 01506 01507 01508 /** 01509 * Simulates the java String method substring(). Returns a new string that is 01510 * a substring of this string. The substring begins at the specified 01511 * theStartIndex and extends to the character at index theEndIndex - 1. Thus 01512 * the length of the substring is theEndIndex-theStartIndex. 01513 * 01514 * @param theString source string 01515 * @param theStartIndex starting index, inclusive 01516 * @param theEndIndex ending index, exclusive 01517 * @return string containing the specified range of characters from target 01518 */ 01519 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01520 substring( 01521 const XalanDOMString& theString, 01522 XalanDOMString::size_type theStartIndex, 01523 XalanDOMString& theResult, 01524 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01525 01526 01527 01528 /** 01529 * Converts ASCII alphabetic characters from upper case to 01530 * lower case. This function works only with the Unicode 01531 * characters A-Z. 01532 * 01533 * @param theString target string 01534 * @return string containing lower case characters 01535 */ 01536 inline XalanDOMChar 01537 toLowerASCII(XalanDOMChar theChar) 01538 { 01539 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01540 { 01541 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01542 } 01543 else 01544 { 01545 return theChar; 01546 } 01547 } 01548 01549 01550 01551 /** 01552 * Converts ASCII alphabetic characters from lower case to 01553 * upper case. This function works only with the Unicode 01554 * characters a-z. 01555 * 01556 * @param theString target string 01557 * @return string containing upper case characters 01558 */ 01559 inline XalanDOMChar 01560 toUpperASCII(XalanDOMChar theChar) 01561 { 01562 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01563 { 01564 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01565 } 01566 else 01567 { 01568 return theChar; 01569 } 01570 } 01571 01572 01573 01574 /** 01575 * Flips the case to of the supplied character. This function works only with 01576 * the Unicode characters A-Z and a-z. 01577 * 01578 * @param theString target string 01579 * @return string containing lower case characters 01580 */ 01581 inline XalanDOMChar 01582 flipCaseASCII(XalanDOMChar theChar) 01583 { 01584 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01585 { 01586 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01587 } 01588 else if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01589 { 01590 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01591 } 01592 else 01593 { 01594 return theChar; 01595 } 01596 } 01597 01598 01599 01600 /** 01601 * Converts ASCII alphabetic characters from upper case to 01602 * lower case. This function works only with the characters 01603 * a-z and A-Z. 01604 * 01605 * @param theString The source string 01606 * @param theResult The target string 01607 * @return A reference to theResult 01608 */ 01609 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01610 toLowerCaseASCII( 01611 const XalanDOMChar* theString, 01612 XalanDOMString& theResult); 01613 01614 01615 01616 /** 01617 * Converts ASCII alphabetic characters from upper case to 01618 * lower case. This function works only with the characters 01619 * a-z and A-Z. 01620 * 01621 * @param theString The source string 01622 * @param theResult The target string 01623 * @return A reference to theResult 01624 */ 01625 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01626 toLowerCaseASCII( 01627 const XalanDOMString& theString, 01628 XalanDOMString& theResult); 01629 01630 01631 01632 /** 01633 * Converts ASCII alphabetic characters from upper case to 01634 * lower case. This function works only with the characters 01635 * a-z and A-Z. 01636 * 01637 * @param theString The string to convert 01638 * @return A reference to theString 01639 */ 01640 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01641 toLowerCaseASCII(XalanDOMString& theString); 01642 01643 01644 01645 /** 01646 * Converts ASCII alphabetic characters from lower case to 01647 * upper case. This function works only with the characters 01648 * a-z and A-Z. 01649 * 01650 * @param theString The source string 01651 * @param theResult The target string 01652 * @return A reference to theResult 01653 */ 01654 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01655 toUpperCaseASCII( 01656 const XalanDOMChar* theString, 01657 XalanDOMString& theResult); 01658 01659 01660 01661 /** 01662 * Converts ASCII alphabetic characters from lower case to 01663 * upper case. This function works only with the characters 01664 * a-z and A-Z. 01665 * 01666 * @param theString The source string 01667 * @param theResult The target string 01668 * @return A reference to theResult 01669 */ 01670 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01671 toUpperCaseASCII( 01672 const XalanDOMString& theString, 01673 XalanDOMString& theResult); 01674 01675 01676 01677 /** 01678 * Converts ASCII alphabetic characters from lower case to 01679 * upper case. This function works only with the characters 01680 * a-z and A-Z. 01681 * 01682 * @param theString The string to convert 01683 * @return A reference to theString 01684 */ 01685 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 01686 toUpperCaseASCII(XalanDOMString& theString); 01687 01688 01689 01690 /** 01691 * Compare the contents of two strings. 01692 * 01693 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01694 * OTHER "COLLATION" ALGORITHM. 01695 * 01696 * @param theLHS first string to compare 01697 * @param theRHS second string to compare 01698 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01699 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01700 * @see operator<() 01701 */ 01702 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01703 compare( 01704 const CharVectorType& theLHS, 01705 const CharVectorType& theRHS); 01706 01707 01708 01709 /** 01710 * Compare the contents of two character arrays. 01711 * 01712 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01713 * OTHER "COLLATION" ALGORITHM. 01714 * 01715 * @param theLHS first array to compare 01716 * @param theLHSLength the length of the first array 01717 * @param theRHS second array to compare 01718 * @param theRHSLength the length of the second array 01719 * @return Returns 0 for equal arrays, less than 0 if theLHS is less 01720 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01721 */ 01722 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01723 compare( 01724 const XalanDOMChar* theLHS, 01725 XalanDOMString::size_type theLHSLength, 01726 const XalanDOMChar* theRHS, 01727 XalanDOMString::size_type theRHSLength); 01728 01729 01730 01731 /** 01732 * Compare the contents of two null-terminated strings. 01733 * 01734 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01735 * OTHER "COLLATION" ALGORITHM. 01736 * 01737 * @param theLHS first string to compare 01738 * @param theRHS second string to compare 01739 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01740 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01741 */ 01742 inline int 01743 compare( 01744 const XalanDOMChar* theLHS, 01745 const XalanDOMChar* theRHS) 01746 { 01747 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01748 } 01749 01750 01751 01752 /** 01753 * Compare the contents of two strings. 01754 * 01755 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01756 * OTHER "COLLATION" ALGORITHM. 01757 * 01758 * @param theLHS first string to compare 01759 * @param theRHS second string to compare 01760 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01761 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01762 * @see operator<() 01763 * @see collationCompare() 01764 */ 01765 inline int 01766 compare( 01767 const XalanDOMString& theLHS, 01768 const XalanDOMString& theRHS) 01769 { 01770 return compare( 01771 theLHS.c_str(), 01772 theLHS.length(), 01773 theRHS.c_str(), 01774 theRHS.length()); 01775 } 01776 01777 01778 01779 /** 01780 * Compare the contents of two strings. 01781 * 01782 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01783 * OTHER "COLLATION" ALGORITHM. 01784 * 01785 * @param theLHS first string to compare 01786 * @param theRHS second string to compare 01787 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01788 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01789 */ 01790 inline int 01791 compare( 01792 const XalanDOMChar* theLHS, 01793 const XalanDOMString& theRHS) 01794 { 01795 return compare( 01796 theLHS, 01797 length(theLHS), 01798 theRHS.c_str(), 01799 theRHS.length()); 01800 } 01801 01802 01803 01804 /** 01805 * Compare the contents of two strings. 01806 * 01807 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01808 * OTHER "COLLATION" ALGORITHM. 01809 * 01810 * @param theLHS first string to compare 01811 * @param theRHS second string to compare 01812 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01813 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01814 */ 01815 inline int 01816 compare( 01817 const XalanDOMString& theLHS, 01818 const XalanDOMChar* theRHS) 01819 { 01820 return compare( 01821 theLHS.c_str(), 01822 theLHS.length(), 01823 theRHS, 01824 length(theRHS)); 01825 } 01826 01827 01828 01829 /** 01830 * Compare the contents of two arrays in a case insensitive 01831 * manner. Only the characters a-z and A-Z are considered as 01832 * characters with "case". 01833 * 01834 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01835 * OTHER "COLLATION" ALGORITHM. 01836 * 01837 * @param theLHS first array to compare 01838 * @param theLHSLength the length of the first array 01839 * @param theRHS second array to compare 01840 * @param theRHSLength the length of the second array 01841 * @return Returns 0 for equal arrays, less than 0 if theLHS is less 01842 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01843 */ 01844 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01845 compareIgnoreCaseASCII( 01846 const XalanDOMChar* theLHS, 01847 XalanDOMString::size_type theLHSLength, 01848 const XalanDOMChar* theRHS, 01849 XalanDOMString::size_type theRHSLength); 01850 01851 01852 01853 /** 01854 * Compare the contents of two strings, in a case insensitive 01855 * manner. Only the characters a-z and A-Z are considered as 01856 * characters with "case". 01857 * 01858 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01859 * OTHER "COLLATION" ALGORITHM. 01860 * 01861 * @param theLHS first string to compare 01862 * @param theRHS second string to compare 01863 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01864 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01865 */ 01866 inline int 01867 compareIgnoreCaseASCII( 01868 const XalanDOMChar* theLHS, 01869 const XalanDOMChar* theRHS) 01870 { 01871 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01872 } 01873 01874 01875 01876 /** 01877 * Compare the contents of two strings, in a case insensitive 01878 * manner. Only the characters a-z and A-Z are considered as 01879 * characters with "case". 01880 * 01881 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01882 * OTHER "COLLATION" ALGORITHM. 01883 * 01884 * @param theLHS first string to compare 01885 * @param theRHS second string to compare 01886 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01887 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01888 * @see operator< 01889 * @see collationCompare 01890 */ 01891 inline int 01892 compareIgnoreCaseASCII( 01893 const XalanDOMString& theLHS, 01894 const XalanDOMString& theRHS) 01895 { 01896 return compareIgnoreCaseASCII( 01897 theLHS.c_str(), 01898 theLHS.length(), 01899 theRHS.c_str(), 01900 theRHS.length()); 01901 } 01902 01903 01904 01905 /** 01906 * Compare the contents of two strings, in a case insensitive 01907 * manner. Only the characters a-z and A-Z are considered as 01908 * characters with "case". 01909 * 01910 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01911 * OTHER "COLLATION" ALGORITHM. 01912 * 01913 * @param theLHS first string to compare 01914 * @param theRHS second string to compare 01915 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01916 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01917 */ 01918 inline int 01919 compareIgnoreCaseASCII( 01920 const XalanDOMString& theLHS, 01921 const XalanDOMChar* theRHS) 01922 { 01923 return compareIgnoreCaseASCII( 01924 theLHS.c_str(), 01925 theLHS.length(), 01926 theRHS, 01927 length(theRHS)); 01928 } 01929 01930 01931 01932 /** 01933 * Compare the contents of two strings, in a case insensitive 01934 * manner. Only the characters a-z and A-Z are considered for 01935 * the comparison. 01936 * 01937 * THIS FUNCTION DOES NOT COMPARE STRINGS LIKE strcmp() OR ANY 01938 * OTHER "COLLATION" ALGORITHM. 01939 * 01940 * @param theLHS first string to compare 01941 * @param theRHS second string to compare 01942 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01943 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01944 */ 01945 inline int 01946 compareIgnoreCaseASCII( 01947 const XalanDOMChar* theLHS, 01948 const XalanDOMString& theRHS) 01949 { 01950 return compareIgnoreCaseASCII( 01951 theLHS, 01952 length(theLHS), 01953 theRHS.c_str(), 01954 theRHS.length()); 01955 } 01956 01957 01958 01959 /** 01960 * Compare the contents of two character arrays. 01961 * 01962 * @param theLHS first array to compare 01963 * @param theLHSLength the length of the first array 01964 * @param theRHS second array to compare 01965 * @param theRHSLength the length of the second array 01966 * @return Returns 0 for equal arrays, less than 0 if theLHS is less 01967 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01968 */ 01969 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01970 collationCompare( 01971 const XalanDOMChar* theLHS, 01972 XalanDOMString::size_type theLHSLength, 01973 const XalanDOMChar* theRHS, 01974 XalanDOMString::size_type theRHSLength); 01975 01976 01977 01978 /** 01979 * Compare the contents of two strings. 01980 * 01981 * @param theLHS first string to compare 01982 * @param theRHS second string to compare 01983 * @return Returns 0 for equal strings, less than 0 if theLHS is less 01984 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 01985 * @see operator<() 01986 * @see compare() 01987 */ 01988 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01989 collationCompare( 01990 const XalanDOMChar* theLHS, 01991 const XalanDOMChar* theRHS); 01992 01993 01994 01995 /** 01996 * Compare the contents of two strings. 01997 * 01998 * @param theLHS first string to compare 01999 * @param theRHS second string to compare 02000 * @return Returns 0 for equal strings, less than 0 if theLHS is less 02001 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 02002 * @see operator<() 02003 * @see compare() 02004 */ 02005 inline int 02006 collationCompare( 02007 const XalanDOMString& theLHS, 02008 const XalanDOMString& theRHS) 02009 { 02010 return collationCompare(theLHS.c_str(), theRHS.c_str()); 02011 } 02012 02013 02014 02015 /** 02016 * Compare the contents of two strings. 02017 * 02018 * @param theLHS first string to compare 02019 * @param theRHS second string to compare 02020 * @return Returns 0 for equal strings, less than 0 if theLHS is less 02021 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 02022 */ 02023 inline int 02024 collationCompare( 02025 const XalanDOMChar* theLHS, 02026 const XalanDOMString& theRHS) 02027 { 02028 return collationCompare(theLHS, theRHS.c_str()); 02029 } 02030 02031 02032 02033 /** 02034 * Compare the contents of two strings. 02035 * 02036 * @param theLHS first string to compare 02037 * @param theRHS second string to compare 02038 * @return Returns 0 for equal strings, less than 0 if theLHS is less 02039 * than theRHS, or greater than 0 if theRHS is greater than theLHS. 02040 */ 02041 inline int 02042 collationCompare( 02043 const XalanDOMString& theLHS, 02044 const XalanDOMChar* theRHS) 02045 { 02046 return collationCompare( 02047 theLHS.c_str(), 02048 theLHS.length(), 02049 theRHS, 02050 length(theRHS)); 02051 } 02052 02053 02054 02055 /** 02056 * Compare the contents of two arrays for equality 02057 * 02058 * @param theLHS first array to compare 02059 * @param theRHS second array to compare 02060 * @param theLength the length of the arrays 02061 * @return true if the contents of both arrays are identical 02062 */ 02063 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02064 equals( 02065 const XalanDOMChar* theLHS, 02066 const XalanDOMChar* theRHS, 02067 XalanDOMString::size_type theLength); 02068 02069 02070 02071 /** 02072 * Compare the contents of two arrays for equality 02073 * 02074 * @param theLHS first array to compare 02075 * @param theLHSLength the length of the theLHS 02076 * @param theRHS second array to compare 02077 * @param theRHSLength the length of the theRHS 02078 * @return true if the contents of both arrays are identical 02079 */ 02080 inline bool 02081 equals( 02082 const XalanDOMChar* theLHS, 02083 XalanDOMString::size_type theLHSLength, 02084 const XalanDOMChar* theRHS, 02085 XalanDOMString::size_type theRHSLength) 02086 { 02087 return theLHSLength != theRHSLength ? false : equals(theLHS, theRHS, theLHSLength); 02088 } 02089 02090 02091 02092 /** 02093 * Compare the contents of two strings for equality 02094 * 02095 * @param theLHS first string to compare 02096 * @param theRHS second string to compare 02097 * @return true if the contents of both strings are identical 02098 */ 02099 inline bool 02100 equals( 02101 const XalanDOMChar* theLHS, 02102 const XalanDOMChar* theRHS) 02103 { 02104 const XalanDOMString::size_type theLHSLength = length(theLHS); 02105 02106 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 02107 } 02108 02109 02110 02111 /** 02112 * Compare the contents of two strings for equality 02113 * 02114 * @param theLHS first string to compare 02115 * @param theRHS second string to compare 02116 * @return true if the contents of both strings are identical 02117 */ 02118 inline bool 02119 equals( 02120 const XalanDOMString& theLHS, 02121 const XalanDOMString& theRHS) 02122 { 02123 return theLHS == theRHS; 02124 } 02125 02126 02127 02128 /** 02129 * Compare the contents of two strings for equality 02130 * 02131 * @param theLHS first string to compare 02132 * @param theRHS second string to compare 02133 * @return true if the contents of both strings are identical 02134 */ 02135 inline bool 02136 equals( 02137 const XalanDOMChar* theLHS, 02138 const XalanDOMString& theRHS) 02139 { 02140 assert(theLHS != 0); 02141 02142 // Swap them... 02143 return theRHS == theLHS; 02144 } 02145 02146 02147 02148 /** 02149 * Compare the contents of two strings for equality 02150 * 02151 * @param theLHS first string to compare 02152 * @param theRHS second string to compare 02153 * @return true if the contents of both strings are identical 02154 */ 02155 inline bool 02156 equals(const XalanDOMString& theLHS, 02157 const XalanDOMChar* theRHS) 02158 { 02159 return equals(theRHS, theLHS); 02160 } 02161 02162 02163 02164 /** 02165 * Compare the contents of two strings for equality 02166 * 02167 * @param theLHS first string to compare 02168 * @param theRHS second string to compare 02169 * @param theRHSLength the length of the theRHS 02170 * @return true if the contents of both strings are identical 02171 */ 02172 inline bool 02173 equals( 02174 const XalanDOMString& theLHS, 02175 const XalanDOMChar* theRHS, 02176 XalanDOMString::size_type theRHSLength) 02177 { 02178 return theRHSLength != theLHS.length() ? false : equals(theLHS.c_str(), theRHSLength, theRHS, theRHSLength); 02179 } 02180 02181 02182 02183 02184 /** 02185 * Compare the contents of two arrays for equality, without regard for case. 02186 * Only the characters a-z and A-Z are considered characters with "case". 02187 * 02188 * @param theLHS first string to compare 02189 * @param theRHS second string to compare 02190 * @return true if the case-insensitive contents of both strings are identical 02191 */ 02192 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02193 equalsIgnoreCaseASCII( 02194 const XalanDOMChar* theLHS, 02195 const XalanDOMChar* theRHS, 02196 XalanDOMString::size_type theLength); 02197 02198 02199 02200 /** 02201 * Compare the contents of two strings for equality, without regard for case. 02202 * Only the characters a-z and A-Z are considered characters with "case". 02203 * 02204 * @param theLHS first string to compare 02205 * @param theLHSLength the length of the theLHS 02206 * @param theRHS second string to compare 02207 * @param theRHSLength the length of the theRHS 02208 * @return true if both strings are identical 02209 */ 02210 inline bool 02211 equalsIgnoreCaseASCII( 02212 const XalanDOMChar* theLHS, 02213 XalanDOMString::size_type theLHSLength, 02214 const XalanDOMChar* theRHS, 02215 XalanDOMString::size_type theRHSLength) 02216 { 02217 return theLHSLength != theRHSLength ? false : 02218 equalsIgnoreCaseASCII(theLHS, theRHS, theLHSLength); 02219 } 02220 02221 02222 02223 /** 02224 * Compare the contents of two strings for equality, without regard for case. 02225 * Only the characters a-z and A-Z are considered characters with "case". 02226 * 02227 * @param theLHS first string to compare 02228 * @param theRHS second string to compare 02229 * @return true if both strings are identical 02230 */ 02231 inline bool 02232 equalsIgnoreCaseASCII( 02233 const XalanDOMChar* theLHS, 02234 const XalanDOMChar* theRHS) 02235 { 02236 const XalanDOMString::size_type theLength = length(theLHS); 02237 02238 return theLength != length(theRHS) ? false : 02239 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 02240 } 02241 02242 02243 02244 /** 02245 * Compare the contents of two strings for equality, without regard for case 02246 * Only the characters A-Z and a-z are considered. 02247 * 02248 * @param theLHS first string to compare 02249 * @param theRHS second string to compare 02250 * @return true if the case-insensitive contents of both strings are identical 02251 */ 02252 inline bool 02253 equalsIgnoreCaseASCII( 02254 const XalanDOMString& theLHS, 02255 const XalanDOMString& theRHS) 02256 { 02257 const XalanDOMString::size_type theLength = theLHS.length(); 02258 02259 return theLength != theRHS.length() ? false : 02260 equalsIgnoreCaseASCII( 02261 theLHS.c_str(), 02262 theRHS.c_str(), 02263 theLength); 02264 } 02265 02266 02267 02268 /** 02269 * Compare the contents of two strings for equality, without regard for case. 02270 * Only the characters a-z and A-Z are considered characters with "case". 02271 * 02272 * @param theLHS first string to compare 02273 * @param theRHS second string to compare 02274 * @return true if the case-insensitive contents of both strings are identical 02275 */ 02276 inline bool 02277 equalsIgnoreCaseASCII( 02278 const XalanDOMChar* theLHS, 02279 const XalanDOMString& theRHS) 02280 { 02281 const XalanDOMString::size_type theRHSLength = theRHS.length(); 02282 02283 return theRHSLength != length(theLHS) ? false : 02284 equalsIgnoreCaseASCII( 02285 theLHS, 02286 theRHS.c_str(), 02287 theRHSLength); 02288 } 02289 02290 02291 02292 /** 02293 * Compare the contents of two strings for equality, without regard for case. 02294 * Only the characters A-Z and a-z are considered. 02295 * 02296 * @param theLHS first string to compare 02297 * @param theRHS second string to compare 02298 * @return true if the case-insensitive contents of both strings are identical 02299 */ 02300 inline bool 02301 equalsIgnoreCaseASCII( 02302 const XalanDOMString& theLHS, 02303 const XalanDOMChar* theRHS) 02304 { 02305 return equalsIgnoreCaseASCII(theRHS, theLHS); 02306 } 02307 02308 02309 02310 /** 02311 * Implements operator< for CharVectorType. 02312 * 02313 * @param theLHS first string to compare 02314 * @param theRHS second string to compare 02315 * @return Returns true if theLHS is lexically 02316 * less than theRHS 02317 * @see compare 02318 */ 02319 inline bool 02320 operator<( 02321 const CharVectorType& theLHS, 02322 const CharVectorType& theRHS) 02323 { 02324 return compare(theLHS, theRHS) < 0 ? true : false; 02325 } 02326 02327 02328 02329 /** 02330 * Implements operator< for DOMStrings. 02331 * 02332 * @param theLHS first string to compare 02333 * @param theRHS second string to compare 02334 * @return Returns true if theLHS is lexically 02335 * less than theRHS 02336 * @see compare 02337 */ 02338 inline bool 02339 operator<( 02340 const XalanDOMString& theLHS, 02341 const XalanDOMString& theRHS) 02342 { 02343 return compare(theLHS, theRHS) < 0 ? true : false; 02344 } 02345 02346 02347 02348 /** 02349 * Assign one string to another 02350 * 02351 * @deprecated This function is deprecated. 02352 * 02353 * @param theString target string 02354 * @param theStringToAppend string to assign 02355 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated) 02356 * @return a reference to the target string 02357 */ 02358 inline XalanDOMString& 02359 assign( 02360 XalanDOMString& theString, 02361 const XalanDOMString& theStringToAssign) 02362 { 02363 theString = theStringToAssign; 02364 02365 return theString; 02366 } 02367 02368 02369 02370 /** 02371 * Assign one string to another 02372 * 02373 * @deprecated This function is deprecated. 02374 * 02375 * @param theString target string 02376 * @param theStringToAppend string to assign 02377 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated) 02378 * @return a reference to the target string 02379 */ 02380 inline XalanDOMString& 02381 assign( 02382 XalanDOMString& theString, 02383 const XalanDOMChar* theStringToAssign, 02384 XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos) 02385 { 02386 if (theStringToAssignLength == XalanDOMString::npos) 02387 { 02388 theString.assign(theStringToAssign); 02389 } 02390 else 02391 { 02392 theString.assign(theStringToAssign, theStringToAssignLength); 02393 } 02394 02395 return theString; 02396 } 02397 02398 02399 02400 /** 02401 * Concatenate two strings 02402 * 02403 * @deprecated This function is deprecated. 02404 * 02405 * @param theString target string 02406 * @param theStringToAppend string to add to target 02407 * @return a reference to the target string 02408 */ 02409 inline XalanDOMString& 02410 append( 02411 XalanDOMString& theString, 02412 const XalanDOMString& theStringToAppend) 02413 { 02414 theString.append(theStringToAppend); 02415 02416 return theString; 02417 } 02418 02419 02420 02421 /** 02422 * Concatenate two strings 02423 * 02424 * @deprecated This function is deprecated. 02425 * 02426 * @param theString target string 02427 * @param theStringToAppend string to add to target 02428 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated) 02429 * @return a reference to the target string 02430 */ 02431 inline XalanDOMString& 02432 append( 02433 XalanDOMString& theString, 02434 const XalanDOMChar* theStringToAppend, 02435 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02436 { 02437 assert(theStringToAppend != 0); 02438 02439 if (theStringToAppendLength == XalanDOMString::npos) 02440 { 02441 theString.append(theStringToAppend); 02442 } 02443 else 02444 { 02445 theString.append(theStringToAppend, theStringToAppendLength); 02446 } 02447 02448 return theString; 02449 } 02450 02451 02452 02453 /** 02454 * Concatenate two strings 02455 * 02456 * @deprecated This function is deprecated. 02457 * 02458 * @param theString target string 02459 * @param theStringToAppend string to add to target 02460 * @param theStringToAppendLength length of the string (XalanDOMString::npos implies the string is null-terminated) 02461 * @return string with contents of 'theStringToAppend' added to target string 02462 */ 02463 inline XalanDOMString& 02464 append( 02465 XalanDOMString& theString, 02466 const char* theStringToAppend, 02467 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02468 { 02469 XalanDOMString tmp(theString.getMemoryManager()); 02470 02471 TranscodeFromLocalCodePage(theStringToAppend, tmp, theStringToAppendLength); 02472 02473 theString.append(tmp); 02474 02475 return theString; 02476 } 02477 02478 02479 02480 /** 02481 * Concatenate a string and a character 02482 * 02483 * @deprecated This function is deprecated. 02484 * 02485 * @param theString target string 02486 * @param theCharToAppend the character to add to the target 02487 * @return string with the character appended 02488 */ 02489 inline XalanDOMString& 02490 append( 02491 XalanDOMString& theString, 02492 const XalanDOMChar theCharToAppend) 02493 { 02494 theString.append(1, theCharToAppend); 02495 02496 return theString; 02497 } 02498 02499 02500 02501 /** 02502 * Concatenate a string and a character 02503 * 02504 * @deprecated This function is deprecated. 02505 * 02506 * @param theString target string 02507 * @param theCharToAppend the character to add to the target 02508 * @return string with the character appended 02509 */ 02510 inline XalanDOMString& 02511 append( 02512 XalanDOMString& theString, 02513 char theCharToAppend) 02514 { 02515 // We have to transcode before appending... 02516 char theTempBuffer[] = { theCharToAppend, '\0' }; 02517 02518 return append(theString, theTempBuffer); 02519 } 02520 02521 02522 02523 /** 02524 * Insert a string into another string. 02525 * 02526 * @deprecated This function is deprecated. 02527 * 02528 * @param theString target string 02529 * @param thePosition The position in the target string to insert 02530 * @param theStringToInsert The string to insert 02531 * @return A reference to the target string 02532 */ 02533 inline XalanDOMString& 02534 insert( 02535 XalanDOMString& theString, 02536 XalanDOMString::size_type thePosition, 02537 const XalanDOMString& theStringToInsert) 02538 { 02539 theString.insert(thePosition, theStringToInsert); 02540 02541 return theString; 02542 } 02543 02544 02545 02546 /** 02547 * Insert a string into another string. 02548 * 02549 * @deprecated This function is deprecated. 02550 * 02551 * @param theString target string 02552 * @param thePosition The position in the target string to insert 02553 * @param theStringToInsert The string to insert 02554 * @return A reference to the target string 02555 */ 02556 inline XalanDOMString& 02557 insert( 02558 XalanDOMString& theString, 02559 XalanDOMString::size_type thePosition, 02560 const XalanDOMChar* theStringToInsert) 02561 { 02562 theString.insert(thePosition, theStringToInsert); 02563 02564 return theString; 02565 } 02566 02567 02568 02569 /** 02570 * Remove leading and trailing whitespace. 02571 * 02572 * @param theString The string to trim. 02573 * @param theResult The result string. 02574 * @return A reference to theResult. 02575 */ 02576 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString&) 02577 trim( 02578 const XalanDOMString& theString, 02579 XalanDOMString& theResult); 02580 02581 02582 02583 /** 02584 * Remove all elements from target string 02585 * 02586 * @deprecated This function is deprecated. 02587 * 02588 * @param theString target string 02589 */ 02590 inline void 02591 clear(XalanDOMString& theString) 02592 { 02593 theString.clear(); 02594 } 02595 02596 02597 02598 /** 02599 * Remove all elements from target string 02600 * 02601 * @deprecated This function is deprecated. 02602 * 02603 * @param theString target string 02604 */ 02605 inline void 02606 erase(XalanDOMString& theString) 02607 { 02608 theString.erase(); 02609 } 02610 02611 02612 02613 /** 02614 * Remove all elements from target string 02615 * and frees all allocated memory. 02616 * 02617 * @param theString target string 02618 */ 02619 inline void 02620 releaseMemory(XalanDOMString& theString,MemoryManager& theManager) 02621 { 02622 XalanDOMString(theManager).swap(theString); 02623 } 02624 02625 02626 02627 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02628 CopyWideStringToVector( 02629 const XalanDOMChar* theString, 02630 CharVectorType& theVector); 02631 02632 02633 02634 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02635 CopyStringToVector( 02636 const char* theString, 02637 CharVectorType& theVector); 02638 02639 02640 02641 /** 02642 * Utility function to make a null-terminated vector of XMLChs, from a 02643 * null-terminated array of chars, via transcoding, if requested. 02644 * 02645 * @param data array to be converted 02646 * @param whether or not to transcode 02647 * @return null-terminated vector of XalanDOMChar 02648 */ 02649 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType&) 02650 MakeXalanDOMCharVector( 02651 const char* data, 02652 XalanDOMCharVectorType& result, 02653 bool fTranscode = true); 02654 02655 02656 02657 /** 02658 * Utility function to make a null-terminated vector of XMLChs, from a 02659 * null-terminated array of XalanDOMChar. 02660 * 02661 * @param data array to be converted 02662 * @return null-terminated vector of XalanDOMChar 02663 */ 02664 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType&) 02665 MakeXalanDOMCharVector(const XalanDOMChar* data, 02666 XalanDOMCharVectorType& result); 02667 02668 02669 02670 /** 02671 * Utility function to make a null-terminated vector of XMLChs, from a 02672 * XalanDOMString 02673 * 02674 * @param data XalanDOMString to be converted 02675 * @return null-terminated vector of XalanDOMChar 02676 */ 02677 inline XalanDOMCharVectorType& 02678 MakeXalanDOMCharVector(const XalanDOMString& data, 02679 XalanDOMCharVectorType& result) 02680 { 02681 return MakeXalanDOMCharVector(data.c_str(),result); 02682 } 02683 02684 02685 02686 #if defined(XALAN_NO_STD_NAMESPACE) 02687 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02688 #else 02689 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02690 #endif 02691 { 02692 result_type 02693 operator() (const argument_type& theString) const 02694 { 02695 return theString.c_str(); 02696 } 02697 }; 02698 02699 02700 02701 /** 02702 * Less than functor for DOMStrings which ignores case for the characters a-z and A-Z 02703 * 02704 * @param theLHS first string to compare 02705 * @param theRHS second string to compare 02706 * @return true if the theLHS is less than theRHS, without respect to case. 02707 */ 02708 #if defined(XALAN_NO_STD_NAMESPACE) 02709 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02710 #else 02711 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02712 #endif 02713 { 02714 result_type 02715 operator() (first_argument_type theLHS, 02716 second_argument_type theRHS) const 02717 { 02718 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02719 } 02720 }; 02721 02722 02723 02724 /** 02725 * Less than or equal functor for DOMStrings 02726 * 02727 * @param theLHS first string to compare 02728 * @param theRHS second string to compare 02729 * @return true if the theLHS is less than or equal to theRHS 02730 */ 02731 #if defined(XALAN_NO_STD_NAMESPACE) 02732 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02733 #else 02734 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02735 #endif 02736 { 02737 result_type 02738 operator() (first_argument_type theLHS, 02739 second_argument_type theRHS) const 02740 { 02741 return compare(theLHS, theRHS) <= 0 ? true : false; 02742 } 02743 }; 02744 02745 02746 02747 /** 02748 * Greater than functor for DOMStrings 02749 * 02750 * @param theLHS first string to compare 02751 * @param theRHS second string to compare 02752 * @return true if the theLHS is greater than theRHS 02753 */ 02754 #if defined(XALAN_NO_STD_NAMESPACE) 02755 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02756 #else 02757 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02758 #endif 02759 { 02760 result_type 02761 operator() (first_argument_type theLHS, 02762 second_argument_type theRHS) const 02763 { 02764 return compare(theLHS, theRHS) > 0 ? true : false; 02765 } 02766 }; 02767 02768 02769 02770 /** 02771 * Greater than or equal functor for DOMStrings 02772 * 02773 * @param theLHS first string to compare 02774 * @param theRHS second string to compare 02775 * @return true if the theLHS is greater than or equal to theRHS 02776 */ 02777 #if defined(XALAN_NO_STD_NAMESPACE) 02778 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02779 #else 02780 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02781 #endif 02782 { 02783 result_type 02784 operator() (first_argument_type theLHS, 02785 second_argument_type theRHS) const 02786 { 02787 return compare(theLHS, theRHS) >= 0 ? true : false; 02788 } 02789 }; 02790 02791 02792 02793 /** 02794 * This functor is designed to compare 0-terminated wide strings in a case-insensitive 02795 * manner. It substitutes for the default less<type*> so that the contents of wide strings 02796 * can be compared, rather than just the pointers. 02797 */ 02798 #if defined(XALAN_NO_STD_NAMESPACE) 02799 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02800 #else 02801 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02802 #endif 02803 { 02804 /** 02805 * Compare the values of two objects. 02806 * 02807 * 02808 * @param theLHS first object to compare 02809 * @param theRHS second object to compare 02810 * @return true if objects are the same 02811 */ 02812 result_type 02813 operator()( 02814 first_argument_type theLHS, 02815 second_argument_type theRHS) const 02816 { 02817 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02818 } 02819 }; 02820 02821 02822 02823 /** 02824 * Determines if the string contains only whitespace 02825 * 02826 * @param theString target string 02827 * @return true if string contains only whitespace 02828 */ 02829 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02830 isXMLWhitespace(const XalanDOMString& string); 02831 02832 02833 02834 /** 02835 * Determines if a range in an array contains only whitespace 02836 * 02837 * @param ch target array 02838 * @param start starting index to examine 02839 * @param length number of characters to examine 02840 * @return true if specified range contains only whitespace 02841 */ 02842 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02843 isXMLWhitespace( 02844 const XalanDOMChar ch[], 02845 XalanDOMString::size_type start, 02846 XalanDOMString::size_type length); 02847 02848 02849 02850 /** 02851 * Determines if a null-terminated string contains only whitespace 02852 * 02853 * @param theString target string 02854 * @return true if the string contains only whitespace 02855 */ 02856 inline bool 02857 isXMLWhitespace(const XalanDOMChar* theString) 02858 { 02859 assert(theString != 0); 02860 02861 return isXMLWhitespace(theString, 0, length(theString)); 02862 } 02863 02864 02865 02866 XALAN_CPP_NAMESPACE_END 02867 02868 02869 02870 #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.11 |
|