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_OLD_STREAMS) 00070 class ostream; 00071 #else 00072 #include <iosfwd> 00073 #endif 00074 #include <vector> 00075 00076 00077 00078 #include <XalanDOM/XalanDOMString.hpp> 00079 00080 00081 00082 #include <PlatformSupport/XalanUnicode.hpp> 00083 #include <PlatformSupport/XalanXMLChar.hpp> 00084 00085 00086 00087 class XalanOutputStream; 00088 00089 00090 00091 // This macro has been defined to deal with certain C++ compilers which 00092 // do not create Unicode strings when the "L" string constant prefix is 00093 // used. It is meant _only_ for use with static strings. 00094 #if defined(XALAN_LSTRSUPPORT) && !defined(XALAN_XALANDOMCHAR_USHORT_MISMATCH) 00095 00096 #define XALAN_STATIC_UCODE_STRING(str) L##str 00097 00108 inline const XalanDOMString 00109 StaticStringToDOMString(const XalanDOMChar* theString) 00110 { 00111 return XalanDOMString(theString); 00112 } 00113 00114 #else 00115 00116 #define XALAN_STATIC_UCODE_STRING(str) TranscodeFromLocalCodePage(str) 00117 00126 inline const XalanDOMString& 00127 StaticStringToDOMString(const XalanDOMString& theString) 00128 { 00129 return theString; 00130 } 00131 00132 #endif 00133 00134 00135 00140 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00141 DOMStringHelperInitialize(); 00142 00143 00144 00149 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00150 DOMStringHelperTerminate(); 00151 00152 00153 00161 inline const XalanDOMChar* 00162 c_wstr(const XalanDOMString& theString) 00163 { 00164 return theString.c_str(); 00165 } 00166 00167 00168 00176 inline const char* 00177 c_str(const CharVectorType& theString) 00178 { 00179 if (theString.size() == 0) 00180 { 00181 return 0; 00182 } 00183 else 00184 { 00185 const char* const ptr = &theString[0]; 00186 00187 assert(ptr[theString.size() - 1] == '\0'); 00188 00189 return ptr; 00190 } 00191 } 00192 00193 00194 00210 inline const XalanDOMChar* 00211 c_wstr(const XalanDOMChar* theString) 00212 { 00213 return theString; 00214 } 00215 00216 00217 00225 inline const XalanDOMChar* 00226 toCharArray(const XalanDOMString& theString) 00227 { 00228 return theString.c_str(); 00229 } 00230 00231 00232 00239 inline const XalanDOMChar* 00240 toCharArray(const XalanDOMChar* theString) 00241 { 00242 return theString; 00243 } 00244 00245 00246 00254 inline const char* 00255 toCharArray(const CharVectorType& theString) 00256 { 00257 return theString.size() == 0 ? 0 : &theString[0]; 00258 } 00259 00260 00261 00269 inline void 00270 reserve( 00271 XalanDOMString& theString, 00272 XalanDOMString::size_type theCount) 00273 { 00274 theString.reserve(theCount); 00275 } 00276 00277 00278 00285 inline XalanDOMString::size_type 00286 length(const XalanDOMString& theString) 00287 { 00288 return theString.length(); 00289 } 00290 00291 00292 00300 inline XalanDOMString::size_type 00301 length(const XalanDOMChar* theString) 00302 { 00303 assert(theString != 0); 00304 00305 const XalanDOMChar* theBufferPointer = theString; 00306 00307 while(*theBufferPointer != 0) 00308 { 00309 theBufferPointer++; 00310 } 00311 00312 return XalanDOMString::size_type(theBufferPointer - theString); 00313 } 00314 00315 00316 00323 inline XalanDOMString::size_type 00324 length(const char* theString) 00325 { 00326 assert(theString != 0); 00327 00328 return XalanDOMString::size_type(strlen(theString)); 00329 } 00330 00331 00332 00339 inline bool 00340 isEmpty(const XalanDOMString& str) 00341 { 00342 return str.empty(); 00343 } 00344 00345 00346 00356 inline XalanDOMString::size_type 00357 indexOf( 00358 const XalanDOMChar* theString, 00359 XalanDOMChar theChar) 00360 { 00361 assert(theString != 0); 00362 00363 const XalanDOMChar* thePointer = theString; 00364 00365 while(*thePointer != theChar && *thePointer != 0) 00366 { 00367 ++thePointer; 00368 } 00369 00370 return XalanDOMString::size_type(thePointer - theString); 00371 } 00372 00373 00374 00385 inline XalanDOMString::size_type 00386 indexOf( 00387 const XalanDOMChar* theString, 00388 XalanDOMString::size_type theStringLength, 00389 XalanDOMChar theChar) 00390 { 00391 assert(theString != 0); 00392 00393 const XalanDOMChar* thePointer = theString; 00394 const XalanDOMChar* const theEndPointer = theString + theStringLength; 00395 00396 while(*thePointer != theChar && thePointer != theEndPointer) 00397 { 00398 ++thePointer; 00399 } 00400 00401 return XalanDOMString::size_type(thePointer - theString); 00402 } 00403 00404 00405 00415 inline XalanDOMString::size_type 00416 indexOf( 00417 const XalanDOMString& theString, 00418 XalanDOMChar theChar) 00419 { 00420 return length(theString) == 0 ? 0 : indexOf(c_wstr(theString), theChar); 00421 } 00422 00423 00424 00434 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00435 indexOf( 00436 const XalanDOMChar* theString, 00437 const XalanDOMChar* theSubstring); 00438 00439 00449 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00450 indexOf( 00451 const XalanDOMString& theString, 00452 const XalanDOMString& theSubstring); 00453 00454 00455 00465 00466 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type) 00467 lastIndexOf( 00468 const XalanDOMChar* theString, 00469 XalanDOMChar theChar); 00470 00471 00472 00482 inline XalanDOMString::size_type 00483 lastIndexOf( 00484 const XalanDOMString& theString, 00485 XalanDOMChar theChar) 00486 { 00487 return lastIndexOf(c_wstr(theString), theChar); 00488 } 00489 00490 00491 00499 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00500 startsWith( 00501 const XalanDOMChar* theString, 00502 const XalanDOMChar* theSubstring); 00503 00504 00505 00513 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00514 startsWith( 00515 const XalanDOMChar* theString, 00516 const XalanDOMString& theSubstring); 00517 00518 00519 00527 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00528 startsWith( 00529 const XalanDOMString& theString, 00530 const XalanDOMChar* theSubstring); 00531 00532 00533 00541 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00542 startsWith( 00543 const XalanDOMString& theString, 00544 const XalanDOMString& theSubstring); 00545 00546 00547 00555 inline bool 00556 startsWith( 00557 const XalanDOMString& theString, 00558 const char* theSubstring) 00559 { 00560 return startsWith( 00561 theString, 00562 XalanDOMString(theSubstring)); 00563 } 00564 00565 00566 00574 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 00575 endsWith( 00576 const XalanDOMChar* theString, 00577 const XalanDOMChar* theSubstring); 00578 00579 00580 00588 inline bool 00589 endsWith( 00590 const XalanDOMString& theDOMString, 00591 const XalanDOMString& theSubstring) 00592 { 00593 return endsWith(c_wstr(theDOMString), c_wstr(theSubstring)); 00594 } 00595 00596 00597 00605 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00606 PointerToDOMString( 00607 const void* theValue, 00608 XalanDOMString& theResult); 00609 00610 00611 00618 inline const XalanDOMString 00619 PointerToDOMString(const void* theValue) 00620 { 00621 XalanDOMString theResult; 00622 00623 PointerToDOMString(theValue, theResult); 00624 00625 return theResult; 00626 } 00627 00628 00629 00637 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00638 DoubleToDOMString( 00639 double theValue, 00640 XalanDOMString& theResult); 00641 00642 00643 00650 inline const XalanDOMString 00651 DoubleToDOMString(double theValue) 00652 { 00653 XalanDOMString theResult; 00654 00655 DoubleToDOMString(theValue, theResult); 00656 00657 return theResult; 00658 } 00659 00660 00661 00670 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00671 LongToHexDOMString( 00672 long theValue, 00673 XalanDOMString& theResult); 00674 00675 00676 00684 inline const XalanDOMString 00685 LongToHexDOMString(long theValue) 00686 { 00687 XalanDOMString theResult; 00688 00689 LongToHexDOMString(theValue, theResult); 00690 00691 return theResult; 00692 } 00693 00694 00695 00704 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00705 UnsignedLongToHexDOMString( 00706 unsigned long theValue, 00707 XalanDOMString& theResult); 00708 00709 00710 00718 inline const XalanDOMString 00719 UnsignedLongToHexDOMString(unsigned long theValue) 00720 { 00721 XalanDOMString theResult; 00722 00723 UnsignedLongToHexDOMString(theValue, theResult); 00724 00725 return theResult; 00726 } 00727 00728 00729 00737 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00738 LongToDOMString( 00739 long theValue, 00740 XalanDOMString& theResult); 00741 00742 00743 00750 inline const XalanDOMString 00751 LongToDOMString(long theValue) 00752 { 00753 XalanDOMString theResult; 00754 00755 LongToDOMString(theValue, theResult); 00756 00757 return theResult; 00758 } 00759 00760 00761 00770 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 00771 UnsignedLongToDOMString( 00772 unsigned long theValue, 00773 XalanDOMString& theResult); 00774 00775 00776 00783 inline const XalanDOMString 00784 UnsignedLongToDOMString(unsigned long theValue) 00785 { 00786 XalanDOMString theResult; 00787 00788 UnsignedLongToDOMString(theValue, theResult); 00789 00790 return theResult; 00791 } 00792 00793 00794 00801 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 00802 WideStringToInt(const XalanDOMChar* theString); 00803 00804 00805 00812 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(long) 00813 WideStringToLong(const XalanDOMChar* theString); 00814 00815 00816 00823 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(unsigned long) 00824 WideStringToUnsignedLong(const XalanDOMChar* theString); 00825 00826 00827 00834 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(double) 00835 WideStringToDouble(const XalanDOMChar* theString); 00836 00837 00838 00845 inline int 00846 DOMStringToInt(const XalanDOMString& theString) 00847 { 00848 return WideStringToInt(c_wstr(theString)); 00849 } 00850 00851 00852 00859 inline long 00860 DOMStringToLong(const XalanDOMString& theString) 00861 { 00862 return WideStringToLong(c_wstr(theString)); 00863 } 00864 00865 00866 00873 inline unsigned long 00874 DOMStringToUnsignedLong(const XalanDOMString& theString) 00875 { 00876 return WideStringToUnsignedLong(c_wstr(theString)); 00877 } 00878 00879 00880 00887 inline double 00888 DOMStringToDouble(const XalanDOMString& theString) 00889 { 00890 return WideStringToDouble(c_wstr(theString)); 00891 } 00892 00893 00894 00902 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00903 OutputString( 00904 XalanOutputStream& theStream, 00905 const CharVectorType& theString); 00906 00907 00908 00916 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00917 OutputString( 00918 #if defined(XALAN_NO_NAMESPACES) 00919 ostream& theStream, 00920 #else 00921 std::ostream& theStream, 00922 #endif 00923 const CharVectorType& theString); 00924 00925 00926 00934 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00935 OutputString( 00936 XalanOutputStream& theStream, 00937 const XalanDOMChar* theString); 00938 00939 00940 00948 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 00949 OutputString( 00950 #if defined(XALAN_NO_NAMESPACES) 00951 ostream& theStream, 00952 #else 00953 std::ostream& theStream, 00954 #endif 00955 const XalanDOMChar* theString); 00956 00957 00958 00966 inline void 00967 OutputString( 00968 XalanOutputStream& theStream, 00969 const XalanDOMString& theString) 00970 { 00971 if (isEmpty(theString) == false) 00972 { 00973 OutputString(theStream, c_wstr(theString)); 00974 } 00975 } 00976 00977 00978 00986 inline void 00987 OutputString( 00988 #if defined(XALAN_NO_NAMESPACES) 00989 ostream& theStream, 00990 #else 00991 std::ostream& theStream, 00992 #endif 00993 const XalanDOMString& theString) 00994 { 00995 OutputString(theStream, c_wstr(theString)); 00996 } 00997 00998 00999 01007 inline XalanOutputStream& 01008 operator<<( 01009 XalanOutputStream& theStream, 01010 const CharVectorType& theString) 01011 { 01012 OutputString(theStream, theString); 01013 01014 return theStream; 01015 } 01016 01017 01018 01026 #if defined(XALAN_NO_NAMESPACES) 01027 inline ostream& 01028 operator<<( 01029 ostream& theStream, 01030 #else 01031 inline std::ostream& 01032 operator<<( 01033 std::ostream& theStream, 01034 #endif 01035 const CharVectorType& theString) 01036 { 01037 OutputString(theStream, theString); 01038 01039 return theStream; 01040 } 01041 01042 01043 01051 inline XalanOutputStream& 01052 operator<<( 01053 XalanOutputStream& theStream, 01054 const XalanDOMChar* theString) 01055 { 01056 OutputString(theStream, 01057 theString); 01058 01059 return theStream; 01060 } 01061 01062 01063 01071 #if defined(XALAN_NO_NAMESPACES) 01072 inline ostream& 01073 operator<<( 01074 ostream& theStream, 01075 #else 01076 inline std::ostream& 01077 operator<<( 01078 std::ostream& theStream, 01079 #endif 01080 const XalanDOMChar* theString) 01081 { 01082 OutputString(theStream, 01083 theString); 01084 01085 return theStream; 01086 } 01087 01088 01089 01097 inline XalanOutputStream& 01098 operator<<( 01099 XalanOutputStream& theStream, 01100 const XalanDOMString& theString) 01101 { 01102 OutputString(theStream, 01103 theString); 01104 01105 return theStream; 01106 } 01107 01108 01109 01117 #if defined(XALAN_NO_NAMESPACES) 01118 inline ostream& 01119 operator<<( 01120 ostream& theStream, 01121 #else 01122 inline std::ostream& 01123 operator<<( 01124 std::ostream& theStream, 01125 #endif 01126 const XalanDOMString& theString) 01127 { 01128 OutputString(theStream, 01129 theString); 01130 01131 return theStream; 01132 } 01133 01134 01135 01143 inline XalanDOMChar 01144 charAt( 01145 const XalanDOMString& theString, 01146 XalanDOMString::size_type theIndex) 01147 { 01148 return theString[theIndex]; 01149 } 01150 01151 01152 01159 inline bool 01160 isXMLWhitespace(XalanDOMChar theChar) 01161 { 01162 return XalanXMLChar::isWhitespace(theChar); 01163 } 01164 01165 01166 01173 inline bool 01174 isXMLDigit(XalanDOMChar theChar) 01175 { 01176 return XalanXMLChar::isDigit(theChar); 01177 } 01178 01179 01180 01187 inline bool 01188 isXMLLetterOrDigit(XalanDOMChar theChar) 01189 { 01190 return XalanXMLChar::isDigit(theChar) || 01191 XalanXMLChar::isLetter(theChar); 01192 } 01193 01194 01195 01207 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01208 substring( 01209 const XalanDOMChar* theString, 01210 XalanDOMString::size_type theStartIndex, 01211 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01212 01213 01214 01227 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)& 01228 substring( 01229 const XalanDOMChar* theString, 01230 XalanDOMString& theSubstring, 01231 XalanDOMString::size_type theStartIndex, 01232 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01233 01234 01235 01247 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 01248 substring( 01249 const XalanDOMString& theString, 01250 XalanDOMString& theSubstring, 01251 XalanDOMString::size_type theStartIndex, 01252 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01253 01254 01255 01267 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01268 substring( 01269 const XalanDOMString& theString, 01270 XalanDOMString::size_type theStartIndex, 01271 XalanDOMString::size_type theEndIndex = XalanDOMString::npos); 01272 01273 01274 01283 inline XalanDOMChar 01284 toLowerASCII(XalanDOMChar theChar) 01285 { 01286 if (theChar >= XalanUnicode::charLetter_A && theChar <= XalanUnicode::charLetter_Z) 01287 { 01288 return XalanDOMChar(theChar - (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01289 } 01290 else 01291 { 01292 return theChar; 01293 } 01294 } 01295 01296 01297 01306 inline XalanDOMChar 01307 toUpperASCII(XalanDOMChar theChar) 01308 { 01309 if (theChar >= XalanUnicode::charLetter_a && theChar <= XalanUnicode::charLetter_z) 01310 { 01311 return XalanDOMChar(theChar + (XalanUnicode::charLetter_A - XalanUnicode::charLetter_a)); 01312 } 01313 else 01314 { 01315 return theChar; 01316 } 01317 } 01318 01319 01320 01329 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01330 toLowerCaseASCII(const XalanDOMChar* theString); 01331 01332 01333 01342 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01343 toLowerCaseASCII(const XalanDOMString& theString); 01344 01345 01346 01355 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01356 toUpperCaseASCII(const XalanDOMChar* theString); 01357 01358 01359 01368 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 01369 toUpperCaseASCII(const XalanDOMString& theString); 01370 01371 01372 01385 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01386 compare( 01387 const CharVectorType& theLHS, 01388 const CharVectorType& theRHS); 01389 01390 01391 01405 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01406 compare( 01407 const XalanDOMChar* theLHS, 01408 XalanDOMString::size_type theLHSLength, 01409 const XalanDOMChar* theRHS, 01410 XalanDOMString::size_type theRHSLength); 01411 01412 01413 01425 inline int 01426 compare( 01427 const XalanDOMChar* theLHS, 01428 const XalanDOMChar* theRHS) 01429 { 01430 return compare(theLHS, length(theLHS), theRHS, length(theRHS)); 01431 } 01432 01433 01434 01445 inline int 01446 compare( 01447 const XalanDOMString& theLHS, 01448 const XalanDOMString& theRHS) 01449 { 01450 return compare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01451 } 01452 01453 01454 01466 inline int 01467 compare( 01468 const XalanDOMChar* theLHS, 01469 const XalanDOMString& theRHS) 01470 { 01471 return compare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01472 } 01473 01474 01475 01487 inline int 01488 compare( 01489 const XalanDOMString& theLHS, 01490 const XalanDOMChar* theRHS) 01491 { 01492 return compare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01493 } 01494 01495 01496 01509 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01510 compareIgnoreCaseASCII( 01511 const XalanDOMChar* theLHS, 01512 XalanDOMString::size_type theLHSLength, 01513 const XalanDOMChar* theRHS, 01514 XalanDOMString::size_type theRHSLength); 01515 01516 01517 01528 inline int 01529 compareIgnoreCaseASCII( 01530 const XalanDOMChar* theLHS, 01531 const XalanDOMChar* theRHS) 01532 { 01533 return compareIgnoreCaseASCII(theLHS, length(theLHS), theRHS, length(theRHS)); 01534 } 01535 01536 01537 01550 inline int 01551 compareIgnoreCaseASCII( 01552 const XalanDOMString& theLHS, 01553 const XalanDOMString& theRHS) 01554 { 01555 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01556 } 01557 01558 01559 01573 inline int 01574 compareIgnoreCaseASCII( 01575 const XalanDOMString& theLHS, 01576 const XalanDOMChar* theRHS) 01577 { 01578 return compareIgnoreCaseASCII(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01579 } 01580 01581 01582 01596 inline int 01597 compareIgnoreCaseASCII( 01598 const XalanDOMChar* theLHS, 01599 const XalanDOMString& theRHS) 01600 { 01601 return compareIgnoreCaseASCII(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01602 } 01603 01604 01605 01616 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int) 01617 collationCompare( 01618 const XalanDOMChar* theLHS, 01619 XalanDOMString::size_type theLHSLength, 01620 const XalanDOMChar* theRHS, 01621 XalanDOMString::size_type theRHSLength); 01622 01623 01624 01635 inline int 01636 collationCompare( 01637 const XalanDOMChar* theLHS, 01638 const XalanDOMChar* theRHS) 01639 { 01640 return collationCompare(theLHS, length(theLHS), theRHS, length(theRHS)); 01641 } 01642 01643 01644 01655 inline int 01656 collationCompare( 01657 const XalanDOMString& theLHS, 01658 const XalanDOMString& theRHS) 01659 { 01660 return collationCompare(toCharArray(theLHS), length(theLHS), toCharArray(theRHS), length(theRHS)); 01661 } 01662 01663 01664 01673 inline int 01674 collationCompare( 01675 const XalanDOMChar* theLHS, 01676 const XalanDOMString& theRHS) 01677 { 01678 return collationCompare(theLHS, length(theLHS), toCharArray(theRHS), length(theRHS)); 01679 } 01680 01681 01682 01691 inline int 01692 collationCompare( 01693 const XalanDOMString& theLHS, 01694 const XalanDOMChar* theRHS) 01695 { 01696 return collationCompare(toCharArray(theLHS), length(theLHS), theRHS, length(theRHS)); 01697 } 01698 01699 01700 01709 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01710 equals( 01711 const XalanDOMChar* theLHS, 01712 const XalanDOMChar* theRHS, 01713 XalanDOMString::size_type theLength); 01714 01715 01716 01724 inline bool 01725 equals( 01726 const XalanDOMChar* theLHS, 01727 const XalanDOMChar* theRHS) 01728 { 01729 const XalanDOMString::size_type theLHSLength = length(theLHS); 01730 01731 return theLHSLength != length(theRHS) ? false : equals(theLHS, theRHS, theLHSLength); 01732 } 01733 01734 01735 01743 inline bool 01744 equals( 01745 const XalanDOMString& theLHS, 01746 const XalanDOMString& theRHS) 01747 { 01748 return theLHS == theRHS; 01749 } 01750 01751 01752 01760 inline bool 01761 equals( 01762 const XalanDOMChar* theLHS, 01763 const XalanDOMString& theRHS) 01764 { 01765 assert(theLHS != 0); 01766 01767 // Swap them... 01768 return theRHS == theLHS; 01769 } 01770 01771 01772 01780 inline bool 01781 equals(const XalanDOMString& theLHS, 01782 const XalanDOMChar* theRHS) 01783 { 01784 return equals(theRHS, theLHS); 01785 } 01786 01787 01788 01796 inline bool 01797 equals(const XalanDOMString& theLHS, 01798 const char* theRHS) 01799 { 01800 assert(theRHS != 0); 01801 01802 const XalanDOMString::size_type theRHSLength = length(theRHS); 01803 01804 if (theRHSLength != length(theLHS)) 01805 { 01806 return false; 01807 } 01808 else 01809 { 01810 return theLHS == XalanDOMString(theRHS, theRHSLength); 01811 } 01812 } 01813 01814 01815 01823 inline bool 01824 equals(const char* theLHS, 01825 const XalanDOMString& theRHS) 01826 { 01827 return equals(theRHS, theLHS); 01828 } 01829 01830 01831 01839 inline bool 01840 equals(const XalanDOMChar* theLHS, 01841 const char* theRHS) 01842 { 01843 assert(theLHS != 0); 01844 assert(theRHS != 0); 01845 01846 const XalanDOMString::size_type theRHSLength = length(theRHS); 01847 01848 if (theRHSLength != length(theLHS)) 01849 { 01850 return false; 01851 } 01852 else 01853 { 01854 return equals(XalanDOMString(theRHS, theRHSLength), theLHS); 01855 } 01856 } 01857 01858 01859 01867 inline bool 01868 equals(const char* theLHS, 01869 const XalanDOMChar* theRHS) 01870 { 01871 return equals(theRHS, theLHS); 01872 } 01873 01874 01875 01884 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 01885 equalsIgnoreCaseASCII( 01886 const XalanDOMChar* theLHS, 01887 const XalanDOMChar* theRHS, 01888 XalanDOMString::size_type theLength); 01889 01890 01891 01900 inline bool 01901 equalsIgnoreCaseASCII( 01902 const XalanDOMChar* theLHS, 01903 const XalanDOMChar* theRHS) 01904 { 01905 const XalanDOMString::size_type theLength = length(theLHS); 01906 01907 return theLength != length(theRHS) ? false : 01908 equalsIgnoreCaseASCII(theLHS, theRHS, theLength); 01909 } 01910 01911 01912 01921 inline bool 01922 equalsIgnoreCaseASCII( 01923 const XalanDOMString& theLHS, 01924 const XalanDOMString& theRHS) 01925 { 01926 const XalanDOMString::size_type theLength = length(theLHS); 01927 01928 return theLength != length(theRHS) ? false : 01929 equalsIgnoreCaseASCII(toCharArray(theLHS), toCharArray(theRHS), theLength); 01930 } 01931 01932 01933 01942 inline bool 01943 equalsIgnoreCaseASCII( 01944 const XalanDOMChar* theLHS, 01945 const XalanDOMString& theRHS) 01946 { 01947 const XalanDOMString::size_type theRHSLength = length(theRHS); 01948 01949 return theRHSLength != length(theLHS) ? false : 01950 equalsIgnoreCaseASCII(theLHS, toCharArray(theRHS), theRHSLength); 01951 } 01952 01953 01954 01963 inline bool 01964 equalsIgnoreCaseASCII( 01965 const XalanDOMString& theLHS, 01966 const XalanDOMChar* theRHS) 01967 { 01968 return equalsIgnoreCaseASCII(theRHS, theLHS); 01969 } 01970 01971 01972 01982 inline bool 01983 operator<( 01984 const CharVectorType& theLHS, 01985 const CharVectorType& theRHS) 01986 { 01987 return compare(theLHS, theRHS) < 0 ? true : false; 01988 } 01989 01990 01991 02001 inline bool 02002 operator<( 02003 const XalanDOMString& theLHS, 02004 const XalanDOMString& theRHS) 02005 { 02006 return compare(theLHS, theRHS) < 0 ? true : false; 02007 } 02008 02009 02010 02019 inline XalanDOMString& 02020 assign( 02021 XalanDOMString& theString, 02022 const XalanDOMString& theStringToAssign) 02023 { 02024 theString = theStringToAssign; 02025 02026 return theString; 02027 } 02028 02029 02030 02039 inline XalanDOMString& 02040 assign( 02041 XalanDOMString& theString, 02042 const XalanDOMChar* theStringToAssign, 02043 XalanDOMString::size_type theStringToAssignLength = XalanDOMString::npos) 02044 { 02045 if (theStringToAssignLength == XalanDOMString::npos) 02046 { 02047 theString.assign(theStringToAssign); 02048 } 02049 else 02050 { 02051 theString.assign(theStringToAssign, theStringToAssignLength); 02052 } 02053 02054 return theString; 02055 } 02056 02057 02058 02066 inline XalanDOMString& 02067 append( 02068 XalanDOMString& theString, 02069 const XalanDOMString& theStringToAppend) 02070 { 02071 theString.append(theStringToAppend); 02072 02073 return theString; 02074 } 02075 02076 02077 02086 inline XalanDOMString& 02087 append( 02088 XalanDOMString& theString, 02089 const XalanDOMChar* theStringToAppend, 02090 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02091 { 02092 assert(theStringToAppend != 0); 02093 02094 if (theStringToAppendLength == XalanDOMString::npos) 02095 { 02096 theString.append(theStringToAppend); 02097 } 02098 else 02099 { 02100 theString.append(theStringToAppend, theStringToAppendLength); 02101 } 02102 02103 return theString; 02104 } 02105 02106 02107 02116 inline XalanDOMString& 02117 append( 02118 XalanDOMString& theString, 02119 const char* theStringToAppend, 02120 XalanDOMString::size_type theStringToAppendLength = XalanDOMString::npos) 02121 { 02122 theString.append(TranscodeFromLocalCodePage(theStringToAppend, theStringToAppendLength)); 02123 02124 return theString; 02125 } 02126 02127 02128 02136 inline XalanDOMString& 02137 append( 02138 XalanDOMString& theString, 02139 const XalanDOMChar theCharToAppend) 02140 { 02141 theString.append(1, theCharToAppend); 02142 02143 return theString; 02144 } 02145 02146 02147 02155 inline XalanDOMString& 02156 append( 02157 XalanDOMString& theString, 02158 char theCharToAppend) 02159 { 02160 // We have to transcode before appending... 02161 char theTempBuffer[] = { theCharToAppend, '\0' }; 02162 02163 return append(theString, theTempBuffer); 02164 } 02165 02166 02167 02176 inline XalanDOMString& 02177 insert( 02178 XalanDOMString& theString, 02179 XalanDOMString::size_type thePosition, 02180 const XalanDOMString& theStringToInsert) 02181 { 02182 theString.insert(thePosition, theStringToInsert); 02183 02184 return theString; 02185 } 02186 02187 02188 02197 inline XalanDOMString& 02198 insert( 02199 XalanDOMString& theString, 02200 XalanDOMString::size_type thePosition, 02201 const XalanDOMChar* theStringToInsert) 02202 { 02203 theString.insert(thePosition, theStringToInsert); 02204 02205 return theString; 02206 } 02207 02208 02209 02216 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString) 02217 trim(const XalanDOMString& theString); 02218 02219 02220 02226 inline void 02227 clear(XalanDOMString& theString) 02228 { 02229 theString.clear(); 02230 } 02231 02232 02233 02239 inline void 02240 erase(XalanDOMString& theString) 02241 { 02242 theString.erase(); 02243 } 02244 02245 02246 02253 inline void 02254 releaseMemory(XalanDOMString& theString) 02255 { 02256 XalanDOMString().swap(theString); 02257 } 02258 02259 02260 02261 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02262 CopyWideStringToVector( 02263 const XalanDOMChar* theString, 02264 CharVectorType& theVector); 02265 02266 02267 02268 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(void) 02269 CopyStringToVector( 02270 const char* theString, 02271 CharVectorType& theVector); 02272 02273 02274 02283 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02284 MakeXalanDOMCharVector( 02285 const char* data, 02286 bool fTranscode = true); 02287 02288 02289 02297 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMCharVectorType) 02298 MakeXalanDOMCharVector(const XalanDOMChar* data); 02299 02300 02301 02309 inline XalanDOMCharVectorType 02310 MakeXalanDOMCharVector(const XalanDOMString& data) 02311 { 02312 return MakeXalanDOMCharVector(c_wstr(data)); 02313 } 02314 02315 02316 02317 #if defined(XALAN_NO_NAMESPACES) 02318 struct c_wstr_functor : public unary_function<XalanDOMString, const XalanDOMChar*> 02319 #else 02320 struct c_wstr_functor : public std::unary_function<XalanDOMString, const XalanDOMChar*> 02321 #endif 02322 { 02323 result_type 02324 operator() (const argument_type& theString) const 02325 { 02326 return c_wstr(theString); 02327 } 02328 }; 02329 02330 02331 02338 #if defined(XALAN_NO_NAMESPACES) 02339 struct DOMStringHashFunction : public unary_function<const XalanDOMString&, size_t> 02340 #else 02341 struct DOMStringHashFunction : public std::unary_function<const XalanDOMString&, size_t> 02342 #endif 02343 { 02344 result_type 02345 operator() (argument_type theKey) const 02346 { 02347 const XalanDOMChar* theRawBuffer = c_wstr(theKey); 02348 02349 result_type theHashValue = 0; 02350 02351 if (theRawBuffer != 0) 02352 { 02353 while (*theRawBuffer) 02354 { 02355 theHashValue = 5 * theHashValue + *theRawBuffer; 02356 02357 theRawBuffer++; 02358 } 02359 } 02360 02361 return theHashValue++; 02362 } 02363 }; 02364 02365 02366 02374 #if defined(XALAN_NO_NAMESPACES) 02375 struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02376 #else 02377 struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02378 #endif 02379 { 02380 result_type 02381 operator() (first_argument_type theLHS, 02382 second_argument_type theRHS) const 02383 { 02384 return equals(theLHS, theRHS); 02385 } 02386 }; 02387 02388 02389 02397 #if defined(XALAN_NO_NAMESPACES) 02398 struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02399 #else 02400 struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02401 #endif 02402 { 02403 result_type 02404 operator() (first_argument_type theLHS, 02405 second_argument_type theRHS) const 02406 { 02407 return !equals(theLHS, theRHS); 02408 } 02409 }; 02410 02411 02412 02420 #if defined(XALAN_NO_NAMESPACES) 02421 struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02422 #else 02423 struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02424 #endif 02425 { 02426 result_type 02427 operator() (first_argument_type theLHS, 02428 second_argument_type theRHS) const 02429 { 02430 return compare(theLHS, theRHS) < 0 ? true : false; 02431 } 02432 }; 02433 02434 02435 02443 #if defined(XALAN_NO_NAMESPACES) 02444 struct DOMStringLessThanIgnoreCaseASCIIFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02445 #else 02446 struct DOMStringLessThanIgnoreCaseASCIIFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02447 #endif 02448 { 02449 result_type 02450 operator() (first_argument_type theLHS, 02451 second_argument_type theRHS) const 02452 { 02453 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02454 } 02455 }; 02456 02457 02458 02466 #if defined(XALAN_NO_NAMESPACES) 02467 struct DOMStringLessThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02468 #else 02469 struct DOMStringLessThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02470 #endif 02471 { 02472 result_type 02473 operator() (first_argument_type theLHS, 02474 second_argument_type theRHS) const 02475 { 02476 return compare(theLHS, theRHS) <= 0 ? true : false; 02477 } 02478 }; 02479 02480 02481 02489 #if defined(XALAN_NO_NAMESPACES) 02490 struct DOMStringGreaterThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02491 #else 02492 struct DOMStringGreaterThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02493 #endif 02494 { 02495 result_type 02496 operator() (first_argument_type theLHS, 02497 second_argument_type theRHS) const 02498 { 02499 return compare(theLHS, theRHS) > 0 ? true : false; 02500 } 02501 }; 02502 02503 02504 02512 #if defined(XALAN_NO_NAMESPACES) 02513 struct DOMStringGreaterThanOrEqualFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02514 #else 02515 struct DOMStringGreaterThanOrEqualFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool> 02516 #endif 02517 { 02518 result_type 02519 operator() (first_argument_type theLHS, 02520 second_argument_type theRHS) const 02521 { 02522 return compare(theLHS, theRHS) >= 0 ? true : false; 02523 } 02524 }; 02525 02526 02527 02533 #if defined(XALAN_NO_NAMESPACES) 02534 struct less_no_case_ascii_wide_string : public binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02535 #else 02536 struct less_no_case_ascii_wide_string : public std::binary_function<const XalanDOMChar*, const XalanDOMChar*, bool> 02537 #endif 02538 { 02547 result_type 02548 operator()( 02549 first_argument_type theLHS, 02550 second_argument_type theRHS) const 02551 { 02552 return compareIgnoreCaseASCII(theLHS, theRHS) < 0 ? true : false; 02553 } 02554 }; 02555 02556 02557 02564 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02565 isXMLWhitespace(const XalanDOMString& string); 02566 02567 02568 02577 XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(bool) 02578 isXMLWhitespace( 02579 const XalanDOMChar ch[], 02580 XalanDOMString::size_type start, 02581 XalanDOMString::size_type length); 02582 02583 02584 02591 inline bool 02592 isXMLWhitespace(const XalanDOMChar* theString) 02593 { 02594 assert(theString != 0); 02595 02596 return isXMLWhitespace(theString, 0, length(theString)); 02597 } 02598 02599 02600 02601 #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.3 |
|