- Main Page
- Related Pages
- Classes
- Files

# XMLString.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: XMLString.hpp 932887 2010-04-11 13:04:59Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_XMLSTRING_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_XMLSTRING_HPP
    00024
    00025 #include <xercesc/util/BaseRefVectorOf.hpp>
    00026 #include <xercesc/framework/XMLBuffer.hpp>
    00027 #include <xercesc/framework/MemoryManager.hpp>
    00028 #include <string.h>
    00029 #include <assert.h>
    00030
    00031 XERCES_CPP_NAMESPACE_BEGIN
    00032
    00033 class XMLLCPTranscoder;
    00045 class XMLUTIL_EXPORT XMLString
    00046 {
    00047 public:
    00048     /* Static methods for native character mode string manipulation */
    00049
    00050
    00067     static void catString
    00068     (
    00069                 char* const     target
    00070         , const char* const     src
    00071     );
    00072
    00085     static void catString
    00086     (
    00087                 XMLCh* const    target
    00088         , const XMLCh* const    src
    00089     );
    00091
    00105     static int compareIString
    00106     (
    00107         const   char* const     str1
    00108         , const char* const     str2
    00109     );
    00110
    00121     static int compareIString
    00122     (
    00123         const   XMLCh* const    str1
    00124         , const XMLCh* const    str2
    00125     );
    00126
    00138     static int compareIStringASCII
    00139     (
    00140         const   XMLCh* const    str1
    00141         , const XMLCh* const    str2
    00142     );
    00143
    00144
    00145
    00159     static int compareNString
    00160     (
    00161         const   char* const     str1
    00162         , const char* const     str2
    00163         , const XMLSize_t       count
    00164     );
    00165
    00179     static int compareNString
    00180     (
    00181         const   XMLCh* const    str1
    00182         , const XMLCh* const    str2
    00183         , const XMLSize_t       count
    00184     );
    00185
    00186
    00200     static int compareNIString
    00201     (
    00202         const   char* const     str1
    00203         , const char* const     str2
    00204         , const XMLSize_t       count
    00205     );
    00206
    00221     static int compareNIString
    00222     (
    00223         const   XMLCh* const    str1
    00224         , const XMLCh* const    str2
    00225         , const XMLSize_t       count
    00226     );
    00227
    00240     static int compareString
    00241     (
    00242         const   char* const     str1
    00243         , const char* const     str2
    00244     );
    00245
    00257     static int compareString
    00258     (
    00259         const   XMLCh* const    str1
    00260         , const XMLCh* const    str2
    00261     );
    00262
    00271     static bool equals
    00272     (
    00273           const XMLCh* str1
    00274         , const XMLCh* str2
    00275     );
    00276
    00286     static bool equalsN
    00287     (
    00288           const XMLCh* str1
    00289         , const XMLCh* str2
    00290         , XMLSize_t n
    00291     );
    00292
    00293     static bool equals
    00294     (
    00295           const char* str1
    00296         , const char* str2
    00297     );
    00298
    00308     static bool equalsN
    00309     (
    00310           const char* str1
    00311         , const char* str2
    00312         , XMLSize_t n
    00313     );
    00314
    00341     static bool regionMatches
    00342     (
    00343         const   XMLCh* const    str1
    00344         , const int             offset1
    00345         , const XMLCh* const    str2
    00346         , const int             offset2
    00347         , const XMLSize_t       charCount
    00348     );
    00349
    00377     static bool regionIMatches
    00378     (
    00379         const   XMLCh* const    str1
    00380         , const int             offset1
    00381         , const XMLCh* const    str2
    00382         , const int             offset2
    00383         , const XMLSize_t       charCount
    00384     );
    00386
    00399     static void copyString
    00400     (
    00401                 char* const     target
    00402         , const char* const     src
    00403     );
    00404
    00415     static void copyString
    00416     (
    00417                 XMLCh* const    target
    00418         , const XMLCh* const    src
    00419     );
    00420
    00433     static bool copyNString
    00434     (
    00435                 XMLCh* const   target
    00436         , const XMLCh* const   src
    00437         , const XMLSize_t      maxChars
    00438     );
    00440
    00449     static XMLSize_t hash
    00450     (
    00451         const   char* const     toHash
    00452         , const XMLSize_t       hashModulus
    00453     );
    00454
    00461     static XMLSize_t hash
    00462     (
    00463         const   XMLCh* const    toHash
    00464         , const XMLSize_t       hashModulus
    00465     );
    00466
    00475     static XMLSize_t hashN
    00476     (
    00477         const   XMLCh* const    toHash
    00478         , const XMLSize_t       numChars
    00479         , const XMLSize_t       hashModulus
    00480     );
    00481
    00483
    00494     static int indexOf(const char* const toSearch, const char ch);
    00495
    00504     static int indexOf(const XMLCh* const toSearch, const XMLCh ch);
    00505
    00517     static int indexOf
    00518     (
    00519         const   char* const     toSearch
    00520         , const char            chToFind
    00521         , const XMLSize_t       fromIndex
    00522         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00523     );
    00524
    00536     static int indexOf
    00537     (
    00538         const   XMLCh* const    toSearch
    00539         , const XMLCh           chToFind
    00540         , const XMLSize_t       fromIndex
    00541         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00542     );
    00543
    00552     static int lastIndexOf(const char* const toSearch, const char ch);
    00553
    00562     static int lastIndexOf(const XMLCh* const toSearch, const XMLCh ch);
    00563
    00573     static int lastIndexOf
    00574     (
    00575         const XMLCh ch
    00576         , const XMLCh* const toSearch
    00577         , const XMLSize_t    toSearchLen
    00578     );
    00579
    00591     static int lastIndexOf
    00592     (
    00593         const   char* const     toSearch
    00594         , const char            chToFind
    00595         , const XMLSize_t       fromIndex
    00596         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00597     );
    00598
    00610     static int lastIndexOf
    00611     (
    00612         const   XMLCh* const    toSearch
    00613         , const XMLCh           ch
    00614         , const XMLSize_t       fromIndex
    00615         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00616     );
    00618
    00626     static void moveChars
    00627     (
    00628                 XMLCh* const    targetStr
    00629         , const XMLCh* const    srcStr
    00630         , const XMLSize_t       count
    00631     );
    00632
    00634
    00646     static void subString
    00647     (
    00648                 char* const    targetStr
    00649         , const char* const    srcStr
    00650         , const XMLSize_t      startIndex
    00651         , const XMLSize_t      endIndex
    00652         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00653     );
    00654
    00664     static void subString
    00665     (
    00666                 XMLCh* const    targetStr
    00667         , const XMLCh* const    srcStr
    00668         , const XMLSize_t       startIndex
    00669         , const XMLSize_t       endIndex
    00670         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00671     );
    00672
    00683     static void subString
    00684     (
    00685                 XMLCh* const    targetStr
    00686         , const XMLCh* const    srcStr
    00687         , const XMLSize_t       startIndex
    00688         , const XMLSize_t       endIndex
    00689         , const XMLSize_t       srcStrLength
    00690         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00691     );
    00692
    00694
    00707     static char* replicate(const char* const toRep,
    00708                            MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00709
    00720     static XMLCh* replicate(const XMLCh* const toRep,
    00721                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00722
    00724
    00733     static bool startsWith
    00734     (
    00735         const   char* const     toTest
    00736         , const char* const     prefix
    00737     );
    00738
    00745     static bool startsWith
    00746     (
    00747         const   XMLCh* const    toTest
    00748         , const XMLCh* const    prefix
    00749     );
    00750
    00759     static bool startsWithI
    00760     (
    00761         const   char* const     toTest
    00762         , const char* const     prefix
    00763     );
    00764
    00774     static bool startsWithI
    00775     (
    00776         const   XMLCh* const    toTest
    00777         , const XMLCh* const    prefix
    00778     );
    00779
    00786     static bool endsWith
    00787     (
    00788         const   XMLCh* const    toTest
    00789         , const XMLCh* const    suffix
    00790     );
    00791
    00792
    00801     static const XMLCh* findAny
    00802     (
    00803         const   XMLCh* const    toSearch
    00804         , const XMLCh* const    searchList
    00805     );
    00806
    00815     static XMLCh* findAny
    00816     (
    00817                 XMLCh* const    toSearch
    00818         , const XMLCh* const    searchList
    00819     );
    00820
    00827     static int patternMatch
    00828     (
    00829           const XMLCh* const    toSearch
    00830         , const XMLCh* const    pattern
    00831     );
    00832
    00837     static XMLSize_t stringLen(const char* const src);
    00838
    00843     static XMLSize_t stringLen(const XMLCh* const src);
    00844
    00852     static bool isValidNOTATION(const XMLCh*         const name
    00853                               ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00854
    00860     static bool isValidEncName(const XMLCh* const name);
    00861
    00868     static bool isAlpha(XMLCh const theChar);
    00869
    00875     static bool isDigit(XMLCh const theChar);
    00876
    00882     static bool isAlphaNum(XMLCh const theChar);
    00883
    00889     static bool isHex(XMLCh const theChar);
    00890
    00896     static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
    00897
    00899
    00902
    00914     static void sizeToText
    00915     (
    00916         const   XMLSize_t           toFormat
    00917         ,       char* const         toFill
    00918         , const XMLSize_t           maxChars
    00919         , const unsigned int        radix
    00920         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
    00921     );
    00922
    00934     static void sizeToText
    00935     (
    00936         const   XMLSize_t           toFormat
    00937         ,       XMLCh* const        toFill
    00938         , const XMLSize_t           maxChars
    00939         , const unsigned int        radix
    00940         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
    00941     );
    00942
    00954     static void binToText
    00955     (
    00956         const   unsigned int    toFormat
    00957         ,       char* const     toFill
    00958         , const XMLSize_t       maxChars
    00959         , const unsigned int    radix
    00960         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00961     );
    00962
    00974     static void binToText
    00975     (
    00976         const   unsigned int    toFormat
    00977         ,       XMLCh* const    toFill
    00978         , const XMLSize_t       maxChars
    00979         , const unsigned int    radix
    00980         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00981     );
    00982
    00994     static void binToText
    00995     (
    00996         const   unsigned long   toFormat
    00997         ,       char* const     toFill
    00998         , const XMLSize_t       maxChars
    00999         , const unsigned int    radix
    01000         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01001     );
    01002
    01014     static void binToText
    01015     (
    01016         const   unsigned long   toFormat
    01017         ,       XMLCh* const    toFill
    01018         , const XMLSize_t       maxChars
    01019         , const unsigned int    radix
    01020         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01021     );
    01022
    01034     static void binToText
    01035     (
    01036         const   int             toFormat
    01037         ,       char* const     toFill
    01038         , const XMLSize_t       maxChars
    01039         , const unsigned int    radix
    01040         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01041     );
    01042
    01054     static void binToText
    01055     (
    01056         const   int             toFormat
    01057         ,       XMLCh* const    toFill
    01058         , const XMLSize_t       maxChars
    01059         , const unsigned int    radix
    01060         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01061     );
    01062
    01074     static void binToText
    01075     (
    01076         const   long            toFormat
    01077         ,       char* const     toFill
    01078         , const XMLSize_t       maxChars
    01079         , const unsigned int    radix
    01080         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01081     );
    01082
    01094     static void binToText
    01095     (
    01096         const   long            toFormat
    01097         ,       XMLCh* const    toFill
    01098         , const XMLSize_t       maxChars
    01099         , const unsigned int    radix
    01100         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01101     );
    01102
    01114     static bool textToBin
    01115     (
    01116         const   XMLCh* const    toConvert
    01117         ,       unsigned int&   toFill
    01118         ,       MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
    01119     );
    01120
    01134     static int parseInt
    01135     (
    01136         const   XMLCh* const    toConvert
    01137       , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
    01138     );
    01139
    01145     static void cut
    01146     (
    01147                 XMLCh* const    toCutFrom
    01148         , const XMLSize_t       count
    01149     );
    01150
    01162     static char* transcode
    01163     (
    01164         const   XMLCh* const         toTranscode
    01165         ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    01166     );
    01167
    01183     static bool transcode
    01184     (
    01185         const   XMLCh* const    toTranscode
    01186         ,       char* const     toFill
    01187         , const XMLSize_t       maxChars
    01188         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01189     );
    01190
    01202     static XMLCh* transcode
    01203     (
    01204         const   char* const          toTranscode
    01205         ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    01206     );
    01207
    01218     static bool transcode
    01219     (
    01220         const   char* const     toTranscode
    01221         ,       XMLCh* const    toFill
    01222         , const XMLSize_t       maxChars
    01223         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01224     );
    01225
    01231     static void trim(char* const toTrim);
    01232
    01238     static void trim(XMLCh* const toTrim);
    01239
    01247     static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc
    01248                                         , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01249
    01251
    01262     static XMLCh* makeUName
    01263     (
    01264         const   XMLCh* const    pszURI
    01265         , const XMLCh* const    pszName
    01266     );
    01267
    01284     static XMLSize_t replaceTokens
    01285     (
    01286                 XMLCh* const    errText
    01287         , const XMLSize_t       maxChars
    01288         , const XMLCh* const    text1
    01289         , const XMLCh* const    text2
    01290         , const XMLCh* const    text3
    01291         , const XMLCh* const    text4
    01292         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01293     );
    01294
    01299     static void upperCase(XMLCh* const toUpperCase);
    01300
    01306     static void upperCaseASCII(XMLCh* const toUpperCase);
    01307
    01312     static void lowerCase(XMLCh* const toLowerCase);
    01313
    01319     static void lowerCaseASCII(XMLCh* const toLowerCase);
    01320
    01324     static bool isWSReplaced(const XMLCh* const toCheck);
    01325
    01329     static bool isWSCollapsed(const XMLCh* const toCheck);
    01330
    01336     static void replaceWS(XMLCh* toConvert
    01337         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01338
    01344     static void collapseWS(XMLCh* toConvert
    01345         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01346
    01352     static void removeWS(XMLCh* toConvert
    01353     , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01354
    01355
    01361     static void removeChar(const XMLCh*     const srcString
    01362                          , const XMLCh&           toRemove
    01363                          ,       XMLBuffer&       dstBuffer);
    01364
    01372     static void fixURI(const XMLCh* const str, XMLCh* const target);
    01373
    01375
    01384     static void release
    01385     (
    01386         char**  buf
    01387         ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    01388     );
    01389
    01397     static void release
    01398     (
    01399         XMLCh**  buf
    01400         ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    01401     );
    01403
    01404
    01405 private :
    01406
    01410     XMLString();
    01412     ~XMLString();
    01414
    01415
    01419     static void initString(XMLLCPTranscoder* const defToUse,
    01420                            MemoryManager* const manager);
    01421     static void termString();
    01423
    01428     static bool validateRegion(const XMLCh* const str1, const int offset1,
    01429                         const XMLCh* const str2, const int offset2,
    01430                         const XMLSize_t charCount);
    01431
    01432     static MemoryManager* fgMemoryManager;
    01433
    01434     friend class XMLPlatformUtils;
    01435 };
    01436
    01437
    01438 // ---------------------------------------------------------------------------
    01439 //  Inline some methods that are either just passthroughs to other string
    01440 //  methods, or which are key for performance.
    01441 // ---------------------------------------------------------------------------
    01442 inline void XMLString::moveChars(       XMLCh* const targetStr
    01443                                 , const XMLCh* const srcStr
    01444                                 , const XMLSize_t    count)
    01445 {
    01446     memcpy(targetStr, srcStr, count * sizeof(XMLCh));
    01447 }
    01448
    01449 inline XMLSize_t XMLString::stringLen(const XMLCh* const src)
    01450 {
    01451     if (src == 0)
    01452         return 0;
    01453
    01454     const XMLCh* pszTmp = src;
    01455
    01456     while (*pszTmp++) ;
    01457
    01458     return (pszTmp - src - 1);
    01459 }
    01460
    01461 inline XMLCh* XMLString::replicate(const XMLCh* const toRep,
    01462                                    MemoryManager* const manager)
    01463 {
    01464     // If a null string, return a null string!
    01465     XMLCh* ret = 0;
    01466     if (toRep)
    01467     {
    01468         const XMLSize_t len = stringLen(toRep);
    01469         ret = (XMLCh*) manager->allocate((len+1) * sizeof(XMLCh)); //new XMLCh[len + 1];
    01470         memcpy(ret, toRep, (len + 1) * sizeof(XMLCh));
    01471     }
    01472     return ret;
    01473 }
    01474
    01475 inline bool XMLString::startsWith(  const   XMLCh* const    toTest
    01476                                     , const XMLCh* const    prefix)
    01477 {
    01478     return (compareNString(toTest, prefix, stringLen(prefix)) == 0);
    01479 }
    01480
    01481 inline bool XMLString::startsWithI( const   XMLCh* const    toTest
    01482                                     , const XMLCh* const    prefix)
    01483 {
    01484     return (compareNIString(toTest, prefix, stringLen(prefix)) == 0);
    01485 }
    01486
    01487 inline bool XMLString::endsWith(const XMLCh* const toTest,
    01488                                 const XMLCh* const suffix)
    01489 {
    01490
    01491     XMLSize_t suffixLen = XMLString::stringLen(suffix);
    01492
    01493     return regionMatches(toTest, (int)(XMLString::stringLen(toTest) - suffixLen),
    01494                          suffix, 0, suffixLen);
    01495 }
    01496
    01497 inline bool XMLString::validateRegion(const XMLCh* const str1,
    01498                                       const int offset1,
    01499                                       const XMLCh* const str2,
    01500                                       const int offset2,
    01501                                       const XMLSize_t charCount)
    01502 {
    01503
    01504     if (offset1 < 0 || offset2 < 0 ||
    01505         (offset1 + charCount) > XMLString::stringLen(str1) ||
    01506         (offset2 + charCount) > XMLString::stringLen(str2) )
    01507         return false;
    01508
    01509     return true;
    01510 }
    01511
    01512 inline bool XMLString::equals(   const XMLCh* str1
    01513                                , const XMLCh* str2)
    01514 {
    01515     if (str1 == str2)
    01516         return true;
    01517
    01518     if (str1 == 0 || str2 == 0)
    01519         return ((!str1 || !*str1) && (!str2 || !*str2));
    01520
    01521     while (*str1)
    01522         if(*str1++ != *str2++)  // they are different (or str2 is shorter and we hit the NULL)
    01523             return false;
    01524
    01525     // either both ended (and *str2 is 0 too), or str2 is longer
    01526     return (*str2==0);
    01527 }
    01528
    01529 inline bool XMLString::equalsN(const XMLCh* str1,
    01530                                const XMLCh* str2,
    01531                                XMLSize_t n)
    01532 {
    01533     if (str1 == str2 || n == 0)
    01534       return true;
    01535
    01536     if (str1 == 0 || str2 == 0)
    01537         return ((!str1 || !*str1) && (!str2 || !*str2));
    01538
    01539     for (; n != 0 && *str1 && *str2; --n, ++str1, ++str2)
    01540       if(*str1 != *str2)
    01541         break;
    01542
    01543     return n == 0 || *str1 == *str2; // either equal or both ended premat.
    01544 }
    01545
    01546 inline bool XMLString::equals(   const char* str1
    01547                                , const char* str2)
    01548 {
    01549     if (str1 == str2)
    01550         return true;
    01551
    01552     if (str1 == 0 || str2 == 0)
    01553         return ((!str1 || !*str1) && (!str2 || !*str2));
    01554
    01555     while (*str1)
    01556         if(*str1++ != *str2++)  // they are different (or str2 is shorter and we hit the NULL)
    01557             return false;
    01558
    01559     // either both ended (and *str2 is 0 too), or str2 is longer
    01560     return (*str2==0);
    01561 }
    01562
    01563 inline bool XMLString::equalsN(const char* str1,
    01564                                const char* str2,
    01565                                XMLSize_t n)
    01566 {
    01567     if (str1 == str2 || n == 0)
    01568       return true;
    01569
    01570     if (str1 == 0 || str2 == 0)
    01571         return ((!str1 || !*str1) && (!str2 || !*str2));
    01572
    01573     for (; n != 0 && *str1 && *str2; --n, ++str1, ++str2)
    01574       if(*str1 != *str2)
    01575         break;
    01576
    01577     return n == 0 || *str1 == *str2; // either equal or both ended premat.
    01578 }
    01579
    01580 inline int XMLString::lastIndexOf(const XMLCh* const toSearch, const XMLCh ch)
    01581 {
    01582     return XMLString::lastIndexOf(ch, toSearch, stringLen(toSearch));
    01583 }
    01584
    01585 inline XMLSize_t XMLString::hash(const   XMLCh* const   tohash
    01586                                 , const XMLSize_t          hashModulus)
    01587 {
    01588     if (tohash == 0 || *tohash == 0)
    01589         return 0;
    01590
    01591     const XMLCh* curCh = tohash;
    01592     XMLSize_t hashVal = (XMLSize_t)(*curCh++);
    01593
    01594     while (*curCh)
    01595         hashVal = (hashVal * 38) + (hashVal >> 24) + (XMLSize_t)(*curCh++);
    01596
    01597     // Divide by modulus
    01598     return hashVal % hashModulus;
    01599 }
    01600
    01601 inline XMLSize_t XMLString::hashN(const   XMLCh* const   tohash
    01602                                   , const XMLSize_t       n
    01603                                   , const XMLSize_t       hashModulus)
    01604 {
    01605   if (tohash == 0 || n == 0)
    01606     return 0;
    01607
    01608   const XMLCh* curCh = tohash;
    01609   XMLSize_t hashVal = (XMLSize_t)(*curCh++);
    01610
    01611   for(XMLSize_t i=0;i<n;i++)
    01612     hashVal = (hashVal * 38) + (hashVal >> 24) + (XMLSize_t)(*curCh++);
    01613
    01614   // Divide by modulus
    01615   return hashVal % hashModulus;
    01616 }
    01617
    01618 XERCES_CPP_NAMESPACE_END
    01619
    01620 #endif