00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(DOMSTRINGHELPER_HEADER_GUARD_1357924680) 00058 #define DOMSTRINGHELPER_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <PlatformSupport/PlatformSupportDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 #include <functional> 00069 #if defined(XALAN_NO_IOSFWD) 00070 #include <ostream> 00071 #else 00072 #include <iosfwd> 00073 #endif 00074 #include <vector> 00075 00076 #if defined(XALAN_LSTRSUPPORT) 00077 #include <cwchar> 00078 #endif 00079 00080 #if defined(AIX) 00081 #include <wchar.h> 00082 #elif defined(__GNUC__) 00083 #include <wctype.h> 00084 #endif 00085 00086 00087 #include <XalanDOM/XalanDOMString.hpp> 00088 00089 00090 00091 #include <PlatformSupport/XalanUnicode.hpp> 00092 00093 00094 00095 class XalanOutputStream; 00096 00097 00098 00099 // This macro has been defined to deal with certain C++ compilers which 00100 // do not create Unicode strings when the "L" string constant prefix is 00101 // used. It is meant _only_ for use with static strings. 00102 // It is _not_ designed to be thread-safe, because there will always be 00103 // at least one global static transcoded string that will trigger the 00104 // code at startup. 00105 #if defined(XALAN_LSTRSUPPORT) 00106 00107 #define XALAN_STATIC_UCODE_STRING(str) L##str 00108 00109 #else 00110 00111 // Makes sure the Xerces platform is initialized, then 00112 // transcodes the string. 00113 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(const XalanDOMString) 00114 initializeAndTranscode(const char* theString); 00115 00116 #define XALAN_STATIC_UCODE_STRING(str) initializeAndTranscode(str) 00117 00118 #endif 00119 00120 00121 00126 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00127 DOMStringHelperInitialize(); 00128 00129 00130 00135 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00136 DOMStringHelperTerminate(); 00137 00138 00139 00147 inline void 00148 reserve( 00149 XalanDOMString& theString, 00150 unsigned int theCount) 00151 { 00152 theString.reserve(theCount); 00153 } 00154 00155 00156 00164 inline const XalanDOMChar* 00165 c_wstr(const XalanDOMString& theString) 00166 { 00167 const XalanDOMChar* const ptr = theString.rawBuffer(); 00168 00169 assert(!ptr || ptr[theString.length()] == '\0'); 00170 00171 return ptr; 00172 } 00173 00174 00175 00191 inline const XalanDOMChar* 00192 c_wstr(const XalanDOMChar* theString) 00193 { 00194 return theString; 00195 } 00196 00197 00198 00206 inline const XalanDOMChar* 00207 toCharArray(const XalanDOMString& theString) 00208 { 00209 return theString.rawBuffer(); 00210 } 00211 00212 00213 00220 inline unsigned int 00221 length(const XalanDOMString& theString) 00222 { 00223 return theString.length(); 00224 } 00225 00226 00227 00235 inline unsigned int 00236 length(const XalanDOMChar* theBuffer) 00237 { 00238 assert(theBuffer != 0); 00239 00240 // For the time being, we're using our own custom routine, 00241 // since performance is better. 00242 #if defined(XALAN_USE_WCHAR_SUPPORT) 00243 return wcslen(theBuffer); 00244 #else 00245 const XalanDOMChar* theBufferPointer = theBuffer; 00246 00247 while(*theBufferPointer != 0) 00248 { 00249 theBufferPointer++; 00250 } 00251 00252 return theBufferPointer - theBuffer; 00253 #endif 00254 } 00255 00256 00257 00264 inline bool 00265 isEmpty(const XalanDOMString& str) 00266 { 00267 return length(str) == 0 ? true : false; 00268 } 00269 00270 00271 00281 inline unsigned int 00282 indexOf( 00283 const XalanDOMChar* theString, 00284 XalanDOMChar theChar) 00285 { 00286 // For the time being, we're using our own custom routine, 00287 // since performance is better. 00288 #if defined(XALAN_USE_WCHAR_SUPPORT) 00289 00290 const XalanDOMChar* const thePointer = 00291 wcschr(theString, theChar); 00292 00293 if (thePointer == 0) 00294 { 00295 return length(theString); 00296 } 00297 else 00298 { 00299 return thePointer - theString; 00300 } 00301 00302 #else 00303 00304 const XalanDOMChar* thePointer = theString; 00305 00306 while(*thePointer != theChar && *thePointer != 0) 00307 { 00308 ++thePointer; 00309 } 00310 00311 return thePointer - theString; 00312 00313 #endif 00314 } 00315 00316 00317 00327 inline unsigned int 00328 indexOf( 00329 const XalanDOMString& theString, 00330 XalanDOMChar theChar) 00331 { 00332 if (theString.length() == 0) 00333 { 00334 return 0; 00335 } 00336 else 00337 { 00338 return indexOf(c_wstr(theString), theChar); 00339 } 00340 } 00341 00342 00343 00353 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00354 indexOf( 00355 const XalanDOMChar* theString, 00356 const XalanDOMChar* theSubstring); 00357 00358 00368 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00369 indexOf( 00370 const XalanDOMString& theString, 00371 const XalanDOMString& theSubstring); 00372 00373 00374 00384 00385 // For the time being, we're using our own custom routine, 00386 // since performance is better. 00387 #if defined(XALAN_USE_WCHAR_SUPPORT) 00388 00389 inline unsigned int 00390 lastIndexOf( 00391 const XalanDOMChar* theString, 00392 XalanDOMChar theChar) 00393 { 00394 const XalanDOMChar* const thePointer = 00395 wcsrchr(theString, theChar); 00396 00397 if (thePointer == 0) 00398 { 00399 return length(theString); 00400 } 00401 else 00402 { 00403 return thePointer - theString; 00404 } 00405 } 00406 00407 #else 00408 00409 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned int) 00410 lastIndexOf( 00411 const XalanDOMChar* theString, 00412 XalanDOMChar theChar); 00413 00414 #endif 00415 00425 inline unsigned int 00426 lastIndexOf( 00427 const XalanDOMString& theString, 00428 XalanDOMChar theChar) 00429 { 00430 return lastIndexOf(c_wstr(theString), theChar); 00431 } 00432 00433 00434 00442 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00443 startsWith( 00444 const XalanDOMChar* theString, 00445 const XalanDOMChar* theSubstring); 00446 00447 00448 00456 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00457 startsWith( 00458 const XalanDOMString& theDOMString, 00459 const XalanDOMString& theSubstring); 00460 00461 00462 00470 inline bool 00471 startsWith( 00472 const XalanDOMString& theDOMString, 00473 const char* theSubstring) 00474 { 00475 return startsWith(theDOMString, 00476 XalanDOMString(theSubstring)); 00477 } 00478 00479 00487 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00488 endsWith( 00489 const XalanDOMChar* theString, 00490 const XalanDOMChar* theSubstring); 00491 00492 00493 00501 inline bool 00502 endsWith( 00503 const XalanDOMString& theDOMString, 00504 const XalanDOMString& theSubstring) 00505 { 00506 return endsWith(c_wstr(theDOMString), c_wstr(theSubstring)); 00507 } 00508 00509 00510 00517 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 00518 DoubleToDOMString(double theDouble); 00519 00520 00521 00528 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 00529 LongToHexDOMString(long theLong); 00530 00531 00532 00539 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 00540 UnsignedLongToHexDOMString(unsigned long theUnsignedLong); 00541 00542 00543 00550 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 00551 LongToDOMString(long theLong); 00552 00553 00554 00561 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 00562 UnsignedLongToDOMString(unsigned long theInt); 00563 00564 00565 00572 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00573 WideStringToInt(const XalanDOMChar* theString); 00574 00575 00576 00583 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00584 WideStringToLong(const XalanDOMChar* theString); 00585 00586 00587 00594 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00595 WideStringToUnsignedLong(const XalanDOMChar* theString); 00596 00597 00598 00605 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00606 WideStringToDouble(const XalanDOMChar* theString); 00607 00608 00609 00616 inline int 00617 DOMStringToInt(const XalanDOMString& theString) 00618 { 00619 return WideStringToInt(c_wstr(theString)); 00620 } 00621 00622 00623 00630 inline long 00631 DOMStringToLong(const XalanDOMString& theString) 00632 { 00633 return WideStringToLong(c_wstr(theString)); 00634 } 00635 00636 00637 00644 inline unsigned long 00645 DOMStringToUnsignedLong(const XalanDOMString& theString) 00646 { 00647 return WideStringToUnsignedLong(c_wstr(theString)); 00648 } 00649 00650 00651 00658 inline double 00659 DOMStringToDouble(const XalanDOMString& theString) 00660 { 00661 return WideStringToDouble(c_wstr(theString)); 00662 } 00663 00664 00665 00666 // Standard vector of XalanDOMChars and chars 00667 #if defined(XALAN_NO_NAMESPACES) 00668 typedef vector<XalanDOMChar> XalanDOMCharVectorType; 00669 00670 typedef vector<char> CharVectorType; 00671 #else 00672 typedef std::vector<XalanDOMChar> XalanDOMCharVectorType; 00673 00674 typedef std::vector<char> CharVectorType; 00675 #endif 00676 00677 00678 00686 inline const char* 00687 c_str(const CharVectorType& theString) 00688 { 00689 const char* const ptr = &theString[0]; 00690 00691 assert(!ptr || ptr[theString.size() - 1] == '\0'); 00692 00693 return ptr; 00694 } 00695 00696 00697 00705 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00706 OutputString( 00707 XalanOutputStream& theStream, 00708 const CharVectorType& theString); 00709 00710 00711 00719 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00720 OutputString( 00721 #if defined(XALAN_NO_NAMESPACES) 00722 ostream& theStream, 00723 #else 00724 std::ostream& theStream, 00725 #endif 00726 const CharVectorType& theString); 00727 00728 00729 00737 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00738 OutputString( 00739 XalanOutputStream& theStream, 00740 const XalanDOMChar* theString); 00741 00742 00743 00751 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00752 OutputString( 00753 #if defined(XALAN_NO_NAMESPACES) 00754 ostream& theStream, 00755 #else 00756 std::ostream& theStream, 00757 #endif 00758 const XalanDOMChar* theString); 00759 00760 00761 00769 inline void 00770 OutputString( 00771 XalanOutputStream& theStream, 00772 const XalanDOMString& theString) 00773 { 00774 if (isEmpty(theString) == false) 00775 { 00776 OutputString(theStream, c_wstr(theString)); 00777 } 00778 } 00779 00780 00781 00789 inline void 00790 OutputString( 00791 #if defined(XALAN_NO_NAMESPACES) 00792 ostream& theStream, 00793 #else 00794 std::ostream& theStream, 00795 #endif 00796 const XalanDOMString& theString) 00797 { 00798 OutputString(theStream, c_wstr(theString)); 00799 } 00800 00801 00802 00810 inline XalanOutputStream& 00811 operator<<( 00812 XalanOutputStream& theStream, 00813 const CharVectorType& theString) 00814 { 00815 OutputString(theStream, theString); 00816 00817 return theStream; 00818 } 00819 00820 00821 00829 #if defined(XALAN_NO_NAMESPACES) 00830 inline ostream& 00831 operator<<( 00832 ostream& theStream, 00833 #else 00834 inline std::ostream& 00835 operator<<( 00836 std::ostream& theStream, 00837 #endif 00838 const CharVectorType& theString) 00839 { 00840 OutputString(theStream, theString); 00841 00842 return theStream; 00843 } 00844 00845 00846 00854 inline XalanOutputStream& 00855 operator<<( 00856 XalanOutputStream& theStream, 00857 const XalanDOMChar* theString) 00858 { 00859 OutputString(theStream, 00860 theString); 00861 00862 return theStream; 00863 } 00864 00865 00866 00874 #if defined(XALAN_NO_NAMESPACES) 00875 inline ostream& 00876 operator<<( 00877 ostream& theStream, 00878 #else 00879 inline std::ostream& 00880 operator<<( 00881 std::ostream& theStream, 00882 #endif 00883 const XalanDOMChar* theString) 00884 { 00885 OutputString(theStream, 00886 theString); 00887 00888 return theStream; 00889 } 00890 00891 00892 00900 inline XalanOutputStream& 00901 operator<<( 00902 XalanOutputStream& theStream, 00903 const XalanDOMString& theString) 00904 { 00905 OutputString(theStream, 00906 theString); 00907 00908 return theStream; 00909 } 00910 00911 00912 00920 #if defined(XALAN_NO_NAMESPACES) 00921 inline ostream& 00922 operator<<( 00923 ostream& theStream, 00924 #else 00925 inline std::ostream& 00926 operator<<( 00927 std::ostream& theStream, 00928 #endif 00929 const XalanDOMString& theString) 00930 { 00931 OutputString(theStream, 00932 theString); 00933 00934 return theStream; 00935 } 00936 00937 00938 00945 inline XalanDOMString 00946 clone(const XalanDOMString& theString) 00947 { 00948 return theString.clone(); 00949 } 00950 00951 00952 00959 inline bool 00960 isSpace(XalanDOMChar theChar) 00961 { 00962 return theChar > XalanUnicode::charSpace ? false : 00963 (theChar == XalanUnicode::charSpace || 00964 theChar == XalanUnicode::charCR || 00965 theChar == XalanUnicode::charLF || 00966 theChar == XalanUnicode::charHTab) ? true : false; 00967 } 00968 00969 00970 00978 inline XalanDOMChar 00979 charAt( 00980 const XalanDOMString& theString, 00981 unsigned int theIndex) 00982 { 00983 return theString.charAt(theIndex); 00984 } 00985 00986 00987 00994 inline bool 00995 isDigit(XalanDOMChar theChar) 00996 { 00997 return iswdigit(theChar) ? true : false; 00998 } 00999 01000 01001 01008 inline bool 01009 isLetterOrDigit(XalanDOMChar theChar) 01010 { 01011 return iswalnum(theChar) ? true : false; 01012 } 01013 01014 01015 01027 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01028 substring( 01029 const XalanDOMChar* theString, 01030 unsigned int theStartIndex, 01031 unsigned int theEndIndex = UINT_MAX); 01032 01033 01034 01046 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01047 substring( 01048 const XalanDOMString& theString, 01049 unsigned int theStartIndex, 01050 unsigned int theEndIndex = UINT_MAX); 01051 01052 01053 01061 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01062 toLowerCase(const XalanDOMString& theString); 01063 01064 01065 01073 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01074 toUpperCase(const XalanDOMString& theString); 01075 01076 01077 01078 #if !defined(XALAN_AMBIGUOUS_EVEN_IF_NOT_CALLED) 01079 // These two function are specifically not defined, and 01080 // should produce ambiguity during compilation. This 01081 // is necessary because the Xerces XalanDOMString class 01082 // defines == as referring to the same underlying 01083 // handle, not identical strings, as C++ programmers 01084 // would expect. 01085 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01086 operator==( 01087 const XalanDOMString& theLHS, 01088 const XalanDOMString& theRHS); 01089 01090 01091 01092 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01093 operator!=( 01094 const XalanDOMString& theLHS, 01095 const XalanDOMString& theRHS); 01096 #endif 01097 01098 01099 01109 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01110 compare( 01111 const CharVectorType& theLHS, 01112 const CharVectorType& theRHS); 01113 01114 01115 01116 // For the time being, we're using our own custom routine, 01117 // since performance is better. 01118 01119 #if defined(XALAN_USE_WCHAR_SUPPORT) 01120 01131 inline int 01132 compare( 01133 const XalanDOMChar* theLHS, 01134 const XalanDOMChar* theRHS) 01135 { 01136 return wcscmp(theLHS, theRHS); 01137 } 01138 01139 #else 01140 01141 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01142 compare( 01143 const XalanDOMChar* theLHS, 01144 const XalanDOMChar* theRHS); 01145 01146 #endif 01147 01148 01149 01161 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01162 compareIgnoreCase( 01163 const XalanDOMChar* theLHS, 01164 const XalanDOMChar* theRHS); 01165 01166 01167 01168 #if defined(XALAN_USE_WCHAR_SUPPORT) 01169 01181 inline int 01182 collationCompare( 01183 const XalanDOMChar* theLHS, 01184 const XalanDOMChar* theRHS) 01185 { 01186 return wcscoll(theLHS, theRHS); 01187 } 01188 01189 #else 01190 01191 // Can't really do it, so just call compare... 01192 inline int 01193 collationCompare( 01194 const XalanDOMChar* theLHS, 01195 const XalanDOMChar* theRHS) 01196 { 01197 return compare(theLHS, theRHS); 01198 } 01199 01200 #endif 01201 01202 01203 01214 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01215 compare( 01216 const XalanDOMString& theLHS, 01217 const XalanDOMString& theRHS); 01218 01219 01231 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01232 compareIgnoreCase( 01233 const XalanDOMString& theLHS, 01234 const XalanDOMString& theRHS); 01235 01236 01237 01249 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01250 collationCompare( 01251 const XalanDOMString& theLHS, 01252 const XalanDOMString& theRHS); 01253 01254 01255 01263 inline bool 01264 equals(const XalanDOMChar* theLHS, 01265 const XalanDOMChar* theRHS) 01266 { 01267 return compare(theLHS, theRHS) == 0 ? true : false; 01268 } 01269 01270 01271 01279 inline bool 01280 equals(const XalanDOMChar* theLHS, 01281 const XalanDOMString& theRHS) 01282 { 01283 assert(theLHS != 0); 01284 01285 return theRHS.equals(theLHS); 01286 } 01287 01288 01289 01297 inline bool 01298 equals(const XalanDOMString& theLHS, 01299 const XalanDOMChar* theRHS) 01300 { 01301 assert(theRHS != 0); 01302 01303 return theLHS.equals(theRHS); 01304 } 01305 01306 01307 01315 inline bool 01316 equals(const XalanDOMString& theLHS, 01317 const char* theRHS) 01318 { 01319 assert(theRHS != 0); 01320 01321 return theLHS.equals(theRHS) ? true : false; 01322 } 01323 01324 01325 01333 inline bool 01334 equals(const XalanDOMChar* theLHS, 01335 const char* theRHS) 01336 { 01337 return equals(theLHS, XalanDOMString(theRHS)); 01338 } 01339 01340 01341 01349 inline bool 01350 equals(const char* theLHS, 01351 const XalanDOMChar* theRHS) 01352 { 01353 assert(theLHS != 0); 01354 assert(theRHS != 0); 01355 01356 return equals(XalanDOMString(theLHS), theRHS); 01357 } 01358 01359 01360 01368 inline bool 01369 equals( 01370 const XalanDOMString& theLHS, 01371 const XalanDOMString& theRHS) 01372 { 01373 return theLHS.equals(theRHS) ? true : false; 01374 } 01375 01376 01377 01385 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01386 equalsIgnoreCase( 01387 const XalanDOMChar* theLHS, 01388 const XalanDOMChar* theRHS); 01389 01390 01391 01399 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01400 equalsIgnoreCase( 01401 const XalanDOMString& theLHS, 01402 const XalanDOMString& theRHS); 01403 01404 01405 01415 inline bool 01416 operator<( 01417 const CharVectorType& theLHS, 01418 const CharVectorType& theRHS) 01419 { 01420 return compare(theLHS, theRHS) < 0 ? true : false; 01421 } 01422 01423 01424 01434 inline bool 01435 operator<( 01436 const XalanDOMString& theLHS, 01437 const XalanDOMString& theRHS) 01438 { 01439 return compare(theLHS, theRHS) < 0 ? true : false; 01440 } 01441 01442 01443 01451 inline XalanDOMString& 01452 append( 01453 XalanDOMString& theString, 01454 const XalanDOMString& theStringToAppend) 01455 { 01456 theString.appendData(theStringToAppend); 01457 01458 return theString; 01459 } 01460 01461 01462 01469 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01470 trim(const XalanDOMString& theString); 01471 01472 01473 01479 inline void 01480 clear(XalanDOMString& theString) 01481 { 01482 #if defined(XALAN_OLD_STYLE_CASTS) 01483 theString = (DOM_NullPtr*)0; 01484 #else 01485 theString = static_cast<DOM_NullPtr*>(0); 01486 #endif 01487 } 01488 01489 01490 01491 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01492 CopyWideStringToVector( 01493 const XalanDOMChar* theString, 01494 CharVectorType& theVector); 01495 01496 01497 01498 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01499 CopyStringToVector( 01500 const char* theString, 01501 CharVectorType& theVector); 01502 01503 01504 01512 inline const XalanDOMChar* 01513 c_wstr(const XalanDOMCharVectorType& theVector) 01514 { 01515 return &theVector[0]; 01516 } 01517 01518 01519 01527 inline bool 01528 equals( 01529 const XalanDOMCharVectorType& theLHS, 01530 const XalanDOMCharVectorType& theRHS) 01531 { 01532 return theLHS == theRHS; 01533 } 01534 01535 01536 01544 inline bool 01545 equals( 01546 const XalanDOMCharVectorType& theLHS, 01547 const XalanDOMChar* theRHS) 01548 { 01549 return equals(c_wstr(theLHS), theRHS); 01550 } 01551 01552 01553 01561 inline bool 01562 equals( 01563 const XalanDOMChar* theLHS, 01564 const XalanDOMCharVectorType& theRHS) 01565 { 01566 return equals(theLHS, c_wstr(theRHS)); 01567 } 01568 01569 01570 01579 inline bool 01580 equals( 01581 const XalanDOMCharVectorType& theLHS, 01582 const XalanDOMString& theRHS) 01583 { 01584 return equals(c_wstr(theLHS), c_wstr(theRHS)); 01585 } 01586 01587 01588 01597 inline bool 01598 equals( 01599 const XalanDOMString& theLHS, 01600 const XalanDOMCharVectorType& theRHS) 01601 { 01602 return equals(c_wstr(theLHS), c_wstr(theRHS)); 01603 } 01604 01605 01606 01617 inline int 01618 compare( 01619 const XalanDOMCharVectorType& theLHS, 01620 const XalanDOMCharVectorType& theRHS) 01621 { 01622 return compare(&theLHS[0], &theRHS[0]); 01623 } 01624 01625 01626 01638 inline int 01639 compareIgnoreCase( 01640 01641 const XalanDOMCharVectorType& theLHS, 01642 const XalanDOMCharVectorType& theRHS) 01643 { 01644 return compareIgnoreCase(&theLHS[0], &theRHS[0]); 01645 } 01646 01647 01648 01660 inline int 01661 collationCompare( 01662 const XalanDOMCharVectorType& theLHS, 01663 const XalanDOMCharVectorType& theRHS) 01664 { 01665 return collationCompare(&theLHS[0], &theRHS[0]); 01666 } 01667 01668 01669 01679 inline bool 01680 operator<( 01681 const XalanDOMCharVectorType& theLHS, 01682 const XalanDOMCharVectorType& theRHS) 01683 { 01684 return compare(theLHS, theRHS) < 0 ? true : false; 01685 } 01686 01687 01688 01697 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 01698 MakeXalanDOMCharVector( 01699 const char* data, 01700 bool fTranscode = true); 01701 01702 01703 01711 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 01712 MakeXalanDOMCharVector(const XalanDOMChar* data); 01713 01714 01715 01723 inline XalanDOMCharVectorType 01724 MakeXalanDOMCharVector(const XalanDOMString& data) 01725 { 01726 return MakeXalanDOMCharVector(c_wstr(data)); 01727 } 01728 01729 01730 01731 #if defined(XALAN_NO_NAMESPACES) 01732 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 01733 #else 01734 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 01735 #endif 01736 { 01737 result_type 01738 operator() (const argument_type& theString) const 01739 { 01740 return c_wstr(theString); 01741 } 01742 }; 01743 01744 01745 01752 #if defined(XALAN_NO_NAMESPACES) 01753 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 01754 #else 01755 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 01756 #endif 01757 { 01758 result_type 01759 operator() (argument_type theKey) const 01760 { 01761 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 01762 01763 unsigned long theHashValue = 0L; 01764 01765 if (theRawBuffer != 0) 01766 { 01767 while (*theRawBuffer) 01768 { 01769 theHashValue = 5 * theHashValue + *theRawBuffer; 01770 01771 theRawBuffer++; 01772 } 01773 } 01774 01775 return result_type(theHashValue++); 01776 } 01777 }; 01778 01779 01780 01788 #if defined(XALAN_NO_NAMESPACES) 01789 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01790 #else 01791 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01792 #endif 01793 { 01794 result_type 01795 operator() (first_argument_type theLHS, 01796 second_argument_type theRHS) const 01797 { 01798 return equals(theLHS, theRHS); 01799 } 01800 }; 01801 01802 01803 01811 #if defined(XALAN_NO_NAMESPACES) 01812 struct DOMStringEqualsIgnoreCaseFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01813 #else 01814 struct DOMStringEqualsIgnoreCaseFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01815 #endif 01816 { 01817 result_type 01818 operator() (first_argument_type theLHS, 01819 second_argument_type theRHS) const 01820 { 01821 return equalsIgnoreCase(theLHS, theRHS); 01822 } 01823 }; 01824 01825 01826 01834 #if defined(XALAN_NO_NAMESPACES) 01835 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01836 #else 01837 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01838 #endif 01839 { 01840 result_type 01841 operator() (first_argument_type theLHS, 01842 second_argument_type theRHS) const 01843 { 01844 return !equals(theLHS, theRHS); 01845 } 01846 }; 01847 01848 01849 01857 #if defined(XALAN_NO_NAMESPACES) 01858 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01859 #else 01860 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01861 #endif 01862 { 01863 result_type 01864 operator() (first_argument_type theLHS, 01865 second_argument_type theRHS) const 01866 { 01867 return compare(theLHS, theRHS) < 0 ? true : false; 01868 } 01869 }; 01870 01871 01872 01880 #if defined(XALAN_NO_NAMESPACES) 01881 struct DOMStringLessThanIgnoreCaseFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01882 #else 01883 struct DOMStringLessThanIgnoreCaseFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01884 #endif 01885 { 01886 result_type 01887 operator() (first_argument_type theLHS, 01888 second_argument_type theRHS) const 01889 { 01890 return compareIgnoreCase(theLHS, theRHS) < 0 ? true : false; 01891 } 01892 }; 01893 01894 01895 01903 #if defined(XALAN_NO_NAMESPACES) 01904 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01905 #else 01906 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01907 #endif 01908 { 01909 result_type 01910 operator() (first_argument_type theLHS, 01911 second_argument_type theRHS) const 01912 { 01913 return compare(theLHS, theRHS) <= 0 ? true : false; 01914 } 01915 }; 01916 01917 01918 01926 #if defined(XALAN_NO_NAMESPACES) 01927 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01928 #else 01929 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01930 #endif 01931 { 01932 result_type 01933 operator() (first_argument_type theLHS, 01934 second_argument_type theRHS) const 01935 { 01936 return compare(theLHS, theRHS) > 0 ? true : false; 01937 } 01938 }; 01939 01940 01941 01949 #if defined(XALAN_NO_NAMESPACES) 01950 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01951 #else 01952 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 01953 #endif 01954 { 01955 result_type 01956 operator() (first_argument_type theLHS, 01957 second_argument_type theRHS) const 01958 { 01959 return compare(theLHS, theRHS) >= 0 ? true : false; 01960 } 01961 }; 01962 01963 01964 01976 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01977 TranscodeToLocalCodePage( 01978 const XalanDOMChar* sourceString, 01979 unsigned int sourceStringLength, 01980 CharVectorType& targetVector, 01981 bool terminate = false); 01982 01983 01984 01995 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01996 TranscodeToLocalCodePage( 01997 const XalanDOMChar* sourceString, 01998 CharVectorType& targetVector, 01999 bool terminate = false); 02000 02001 02002 02011 inline const CharVectorType 02012 TranscodeToLocalCodePage(const XalanDOMChar* sourceString) 02013 { 02014 CharVectorType theResult; 02015 02016 TranscodeToLocalCodePage(sourceString, theResult, true); 02017 02018 return theResult; 02019 } 02020 02021 02022 02032 inline bool 02033 TranscodeToLocalCodePage( 02034 const XalanDOMString& sourceString, 02035 CharVectorType& targetVector, 02036 bool terminate = false) 02037 { 02038 return TranscodeToLocalCodePage(c_wstr(sourceString), targetVector, terminate); 02039 } 02040 02041 02042 02051 inline const CharVectorType 02052 TranscodeToLocalCodePage(const XalanDOMString& sourceString) 02053 { 02054 CharVectorType theResult; 02055 02056 TranscodeToLocalCodePage(sourceString, theResult, true); 02057 02058 return theResult; 02059 } 02060 02061 02062 02069 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02070 isWhiteSpace(const XalanDOMString& string); 02071 02072 02073 02082 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02083 isWhiteSpace( 02084 const XalanDOMChar* ch, 02085 unsigned int start, 02086 unsigned int length); 02087 02088 02089 02090 #endif // DOMSTRINGHELPER_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.0 |
|