| API Docs for SAX and DOM |

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XMLString.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 /*
    00018  * $Log: XMLString.hpp,v $
    00019  * Revision 1.28  2004/09/08 13:56:24  peiyongz
    00020  * Apache License Version 2.0
    00021  *
    00022  * Revision 1.27  2004/09/02 19:08:09  cargilld
    00023  * Fix API Doc warning message
    00024  *
    00025  * Revision 1.26  2004/08/11 16:07:27  peiyongz
    00026  * isValidNOTATION
    00027  *
    00028  * Revision 1.25  2004/05/25 18:11:32  peiyongz
    00029  * removeChar() added
    00030  *
    00031  * Revision 1.24  2004/03/10 17:35:17  amassari
    00032  * Fix documentation for binToText (bug# 9207)
    00033  *
    00034  * Revision 1.23  2003/12/24 15:24:13  cargilld
    00035  * More updates to memory management so that the static memory manager.
    00036  *
    00037  * Revision 1.22  2003/12/17 20:00:49  cargilld
    00038  * Update for memory management so that the static memory manager (one
    00039  * used to call Initialize) is only for static data.
    00040  *
    00041  * Revision 1.21  2003/12/17 00:18:35  cargilld
    00042  * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    00043  *
    00044  * Revision 1.20  2003/10/02 11:07:26  gareth
    00045  * Made the non-memory manager version of replicate not inlined. Updated the documentation for the memory manager versions so they don't tell you you should call release.
    00046  *
    00047  * Revision 1.19  2003/10/01 00:22:20  knoaman
    00048  * Add a lastIndexOf method that takes the string length as one of the params.
    00049  *
    00050  * Revision 1.18  2003/08/25 20:39:47  neilg
    00051  * fix XMLString::findAny(...) docs so that they match what the method actually does (and has done since time immemorial)
    00052  *
    00053  * Revision 1.17  2003/05/18 14:02:05  knoaman
    00054  * Memory manager implementation: pass per instance manager.
    00055  *
    00056  * Revision 1.16  2003/05/15 19:07:46  knoaman
    00057  * Partial implementation of the configurable memory manager.
    00058  *
    00059  * Revision 1.15  2003/04/21 20:07:05  knoaman
    00060  * Performance: use memcpy in moveChars and replicate.
    00061  *
    00062  * Revision 1.14  2003/02/25 16:42:31  tng
    00063  * [Bug 7072] Documentation for XMLString::transcode states invalid return value.
    00064  *
    00065  * Revision 1.13  2003/02/05 18:50:56  tng
    00066  * [Bug 11915] Utility for freeing memory.
    00067  *
    00068  * Revision 1.12  2003/01/24 23:16:33  peiyongz
    00069  * removeWS() added;
    00070  *
    00071  * Revision 1.11  2002/12/20 22:10:21  tng
    00072  * XML 1.1
    00073  *
    00074  * Revision 1.10  2002/12/18 14:17:54  gareth
    00075  * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
    00076  *
    00077  * Revision 1.9  2002/12/04 02:32:43  knoaman
    00078  * #include cleanup.
    00079  *
    00080  * Revision 1.8  2002/11/05 17:42:39  peiyongz
    00081  * equals( const char* const, const char* const)
    00082  *
    00083  * Revision 1.7  2002/11/04 15:22:05  tng
    00084  * C++ Namespace Support.
    00085  *
    00086  * Revision 1.6  2002/10/01 19:45:22  tng
    00087  * Performance in XMLString::equals, only need to check one string for null as they are equal already.
    00088  *
    00089  * Revision 1.5  2002/09/24 19:41:21  tng
    00090  * New inline function equals that is modified from compareString but simply return true or false.
    00091  *
    00092  * Revision 1.4  2002/09/23 18:42:18  tng
    00093  * DOM L3: Support baseURI.   Add utility fixURI to transform an absolute path filename to standard URI form.
    00094  *
    00095  * Revision 1.3  2002/08/27 19:24:43  peiyongz
    00096  * Bug#12087: patch from Thomas Ford (tom@decisionsoft.com)
    00097  *
    00098  * Revision 1.2  2002/02/20 18:17:02  tng
    00099  * [Bug 5977] Warnings on generating apiDocs.
    00100  *
    00101  * Revision 1.1.1.1  2002/02/01 22:22:16  peiyongz
    00102  * sane_include
    00103  *
    00104  * Revision 1.26  2001/08/10 16:23:06  peiyongz
    00105  * isHex(), isAlphaNum(), isAllWhiteSpace() and patternMatch() Added
    00106  *
    00107  * Revision 1.25  2001/07/06 20:27:57  peiyongz
    00108  * isValidaQName()
    00109  *
    00110  * Revision 1.24  2001/07/04 14:38:20  peiyongz
    00111  * IDDatatypeValidator: created
    00112  * DatatypeValidatorFactory: IDDTV enabled
    00113  * XMLString:isValidName(): to validate Name (XML [4][5])
    00114  *
    00115  * Revision 1.23  2001/06/13 14:07:55  peiyongz
    00116  * isValidaEncName() to validate an encoding name (EncName)
    00117  *
    00118  * Revision 1.22  2001/05/23 15:44:51  tng
    00119  * Schema: NormalizedString fix.  By Pei Yong Zhang.
    00120  *
    00121  * Revision 1.21  2001/05/11 13:26:31  tng
    00122  * Copyright update.
    00123  *
    00124  * Revision 1.20  2001/05/09 18:43:30  tng
    00125  * Add StringDatatypeValidator and BooleanDatatypeValidator.  By Pei Yong Zhang.
    00126  *
    00127  * Revision 1.19  2001/05/03 20:34:35  tng
    00128  * Schema: SchemaValidator update
    00129  *
    00130  * Revision 1.18  2001/05/03 19:17:35  knoaman
    00131  * TraverseSchema Part II.
    00132  *
    00133  * Revision 1.17  2001/03/21 21:56:13  tng
    00134  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00135  *
    00136  * Revision 1.16  2001/03/02 20:52:46  knoaman
    00137  * Schema: Regular expression - misc. updates for error messages,
    00138  * and additions of new functions to XMLString class.
    00139  *
    00140  * Revision 1.15  2001/01/15 21:26:34  tng
    00141  * Performance Patches by David Bertoni.
    00142  *
    00143  * Details: (see xerces-c-dev mailing Jan 14)
    00144  * XMLRecognizer.cpp: the internal encoding string XMLUni::fgXMLChEncodingString
    00145  * was going through this function numerous times.  As a result, the top hot-spot
    00146  * for the parse was _wcsicmp().  The real problem is that the Microsofts wide string
    00147  * functions are unbelievably slow.  For things like encodings, it might be
    00148  * better to use a special comparison function that only considers a-z and
    00149  * A-Z as characters with case.  This works since the character set for
    00150  * encodings is limit to printable ASCII characters.
    00151  *
    00152  *  XMLScanner2.cpp: This also has some case-sensitive vs. insensitive compares.
    00153  * They are also much faster.  The other tweak is to only make a copy of an attribute
    00154  * string if it needs to be split.  And then, the strategy is to try to use a
    00155  * stack-based buffer, rather than a dynamically-allocated one.
    00156  *
    00157  * SAX2XMLReaderImpl.cpp: Again, more case-sensitive vs. insensitive comparisons.
    00158  *
    00159  * KVStringPair.cpp & hpp: By storing the size of the allocation, the storage can
    00160  * likely be re-used many times, cutting down on dynamic memory allocations.
    00161  *
    00162  * XMLString.hpp: a more efficient implementation of stringLen().
    00163  *
    00164  * DTDValidator.cpp: another case of using a stack-based buffer when possible
    00165  *
    00166  * These patches made a big difference in parse time in some of our test
    00167  * files, especially the ones are very attribute-heavy.
    00168  *
    00169  * Revision 1.14  2000/10/13 22:47:57  andyh
    00170  * Fix bug (failure to null-terminate result) in XMLString::trim().
    00171  * Patch contributed by Nadav Aharoni
    00172  *
    00173  * Revision 1.13  2000/04/12 18:42:15  roddey
    00174  * Improved docs in terms of what 'max chars' means in the method
    00175  * parameters.
    00176  *
    00177  * Revision 1.12  2000/04/06 19:42:51  rahulj
    00178  * Clarified how big the target buffer should be in the API
    00179  * documentation.
    00180  *
    00181  * Revision 1.11  2000/03/23 01:02:38  roddey
    00182  * Updates to the XMLURL class to correct a lot of parsing problems
    00183  * and to add support for the port number. Updated the URL tests
    00184  * to test some of this new stuff.
    00185  *
    00186  * Revision 1.10  2000/03/20 23:00:46  rahulj
    00187  * Moved the inline definition of stringLen before the first
    00188  * use. This satisfied the HP CC compiler.
    00189  *
    00190  * Revision 1.9  2000/03/02 19:54:49  roddey
    00191  * This checkin includes many changes done while waiting for the
    00192  * 1.1.0 code to be finished. I can't list them all here, but a list is
    00193  * available elsewhere.
    00194  *
    00195  * Revision 1.8  2000/02/24 20:05:26  abagchi
    00196  * Swat for removing Log from API docs
    00197  *
    00198  * Revision 1.7  2000/02/16 18:51:52  roddey
    00199  * Fixed some facts in the docs and reformatted the docs to stay within
    00200  * a reasonable line width.
    00201  *
    00202  * Revision 1.6  2000/02/16 17:07:07  abagchi
    00203  * Added API docs
    00204  *
    00205  * Revision 1.5  2000/02/06 07:48:06  rahulj
    00206  * Year 2K copyright swat.
    00207  *
    00208  * Revision 1.4  2000/01/12 00:16:23  roddey
    00209  * Changes to deal with multiply nested, relative pathed, entities and to deal
    00210  * with the new URL class changes.
    00211  *
    00212  * Revision 1.3  1999/12/18 00:18:10  roddey
    00213  * More changes to support the new, completely orthagonal support for
    00214  * intrinsic encodings.
    00215  *
    00216  * Revision 1.2  1999/12/15 19:41:28  roddey
    00217  * Support for the new transcoder system, where even intrinsic encodings are
    00218  * done via the same transcoder abstraction as external ones.
    00219  *
    00220  * Revision 1.1.1.1  1999/11/09 01:05:52  twl
    00221  * Initial checkin
    00222  *
    00223  * Revision 1.2  1999/11/08 20:45:21  rahul
    00224  * Swat for adding in Product name and CVS comment log variable.
    00225  *
    00226  */
    00227
    00228 #if !defined(XMLSTRING_HPP)
    00229 #define XMLSTRING_HPP
    00230
    00231 #include <xercesc/util/BaseRefVectorOf.hpp>
    00232 #include <xercesc/framework/XMLBuffer.hpp>
    00233 #include <xercesc/framework/MemoryManager.hpp>
    00234 #include <string.h>
    00235
    00236 XERCES_CPP_NAMESPACE_BEGIN
    00237
    00238 class XMLLCPTranscoder;
    00250 class  XMLString
    00251 {
    00252 public:
    00253     /* Static methods for native character mode string manipulation */
    00254
    00255
    00272     static void catString
    00273     (
    00274                 char* const     target
    00275         , const char* const     src
    00276     );
    00277
    00290     static void catString
    00291     (
    00292                 XMLCh* const    target
    00293         , const XMLCh* const    src
    00294     );
    00296
    00310     static int compareIString
    00311     (
    00312         const   char* const     str1
    00313         , const char* const     str2
    00314     );
    00315
    00326     static int compareIString
    00327     (
    00328         const   XMLCh* const    str1
    00329         , const XMLCh* const    str2
    00330     );
    00331
    00332
    00346     static int compareNString
    00347     (
    00348         const   char* const     str1
    00349         , const char* const     str2
    00350         , const unsigned int    count
    00351     );
    00352
    00366     static int compareNString
    00367     (
    00368         const   XMLCh* const    str1
    00369         , const XMLCh* const    str2
    00370         , const unsigned int    count
    00371     );
    00372
    00373
    00387     static int compareNIString
    00388     (
    00389         const   char* const     str1
    00390         , const char* const     str2
    00391         , const unsigned int    count
    00392     );
    00393
    00408     static int compareNIString
    00409     (
    00410         const   XMLCh* const    str1
    00411         , const XMLCh* const    str2
    00412         , const unsigned int    count
    00413     );
    00414
    00427     static int compareString
    00428     (
    00429         const   char* const     str1
    00430         , const char* const     str2
    00431     );
    00432
    00444     static int compareString
    00445     (
    00446         const   XMLCh* const    str1
    00447         , const XMLCh* const    str2
    00448     );
    00449
    00458     static bool equals
    00459     (
    00460           const XMLCh* const    str1
    00461         , const XMLCh* const    str2
    00462     );
    00463
    00464     static bool equals
    00465     (
    00466           const char* const    str1
    00467         , const char* const    str2
    00468     );
    00469
    00496     static bool regionMatches
    00497     (
    00498         const   XMLCh* const    str1
    00499         , const int             offset1
    00500         , const XMLCh* const    str2
    00501         , const int             offset2
    00502         , const unsigned int    charCount
    00503     );
    00504
    00532     static bool regionIMatches
    00533     (
    00534         const   XMLCh* const    str1
    00535         , const int             offset1
    00536         , const XMLCh* const    str2
    00537         , const int             offset2
    00538         , const unsigned int    charCount
    00539     );
    00541
    00554     static void copyString
    00555     (
    00556                 char* const     target
    00557         , const char* const     src
    00558     );
    00559
    00570     static void copyString
    00571     (
    00572                 XMLCh* const    target
    00573         , const XMLCh* const    src
    00574     );
    00575
    00588     static bool copyNString
    00589     (
    00590                 XMLCh* const    target
    00591         , const XMLCh* const    src
    00592         , const unsigned int    maxChars
    00593     );
    00595
    00605     static unsigned int hash
    00606     (
    00607         const   char* const     toHash
    00608         , const unsigned int    hashModulus
    00609         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00610     );
    00611
    00619     static unsigned int hash
    00620     (
    00621         const   XMLCh* const    toHash
    00622         , const unsigned int    hashModulus
    00623         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00624     );
    00625
    00635     static unsigned int hashN
    00636     (
    00637         const   XMLCh* const    toHash
    00638         , const unsigned int    numChars
    00639         , const unsigned int    hashModulus
    00640         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00641     );
    00642
    00644
    00655     static int indexOf(const char* const toSearch, const char ch);
    00656
    00665     static int indexOf(const XMLCh* const toSearch, const XMLCh ch);
    00666
    00678     static int indexOf
    00679     (
    00680         const   char* const     toSearch
    00681         , const char            chToFind
    00682         , const unsigned int    fromIndex
    00683         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00684     );
    00685
    00697     static int indexOf
    00698     (
    00699         const   XMLCh* const    toSearch
    00700         , const XMLCh           chToFind
    00701         , const unsigned int    fromIndex
    00702         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00703     );
    00704
    00713     static int lastIndexOf(const char* const toSearch, const char ch);
    00714
    00723     static int lastIndexOf(const XMLCh* const toSearch, const XMLCh ch);
    00724
    00734     static int lastIndexOf
    00735     (
    00736         const XMLCh ch
    00737         , const XMLCh* const toSearch
    00738         , const unsigned int toSearchLen
    00739     );
    00740
    00752     static int lastIndexOf
    00753     (
    00754         const   char* const     toSearch
    00755         , const char            chToFind
    00756         , const unsigned int    fromIndex
    00757         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00758     );
    00759
    00771     static int lastIndexOf
    00772     (
    00773         const   XMLCh* const    toSearch
    00774         , const XMLCh           ch
    00775         , const unsigned int    fromIndex
    00776         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00777     );
    00779
    00787     static void moveChars
    00788     (
    00789                 XMLCh* const    targetStr
    00790         , const XMLCh* const    srcStr
    00791         , const unsigned int    count
    00792     );
    00793
    00795
    00807     static void subString
    00808     (
    00809                 char* const    targetStr
    00810         , const char* const    srcStr
    00811         , const int            startIndex
    00812         , const int            endIndex
    00813         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00814     );
    00815
    00825     static void subString
    00826     (
    00827                 XMLCh* const    targetStr
    00828         , const XMLCh* const    srcStr
    00829         , const int             startIndex
    00830         , const int             endIndex
    00831         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00832     );
    00833
    00835
    00847     static char* replicate(const char* const toRep);
    00848
    00857     static char* replicate(const char* const toRep,
    00858                            MemoryManager* const manager);
    00859
    00869     static XMLCh* replicate(const XMLCh* const toRep);
    00870
    00879     static XMLCh* replicate(const XMLCh* const toRep,
    00880                             MemoryManager* const manager);
    00881
    00883
    00892     static bool startsWith
    00893     (
    00894         const   char* const     toTest
    00895         , const char* const     prefix
    00896     );
    00897
    00904     static bool startsWith
    00905     (
    00906         const   XMLCh* const    toTest
    00907         , const XMLCh* const    prefix
    00908     );
    00909
    00918     static bool startsWithI
    00919     (
    00920         const   char* const     toTest
    00921         , const char* const     prefix
    00922     );
    00923
    00933     static bool startsWithI
    00934     (
    00935         const   XMLCh* const    toTest
    00936         , const XMLCh* const    prefix
    00937     );
    00938
    00945     static bool endsWith
    00946     (
    00947         const   XMLCh* const    toTest
    00948         , const XMLCh* const    suffix
    00949     );
    00950
    00951
    00960     static const XMLCh* findAny
    00961     (
    00962         const   XMLCh* const    toSearch
    00963         , const XMLCh* const    searchList
    00964     );
    00965
    00974     static XMLCh* findAny
    00975     (
    00976                 XMLCh* const    toSearch
    00977         , const XMLCh* const    searchList
    00978     );
    00979
    00986     static int patternMatch
    00987     (
    00988           const XMLCh* const    toSearch
    00989         , const XMLCh* const    pattern
    00990     );
    00991
    00996     static unsigned int stringLen(const char* const src);
    00997
    01002     static unsigned int stringLen(const XMLCh* const src);
    01003
    01011     static bool isValidNOTATION(const XMLCh*         const name
    01012                               ,       MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    01013
    01021     static bool isValidNCName(const XMLCh* const name);
    01022
    01030     static bool isValidName(const XMLCh* const name);
    01031
    01037     static bool isValidEncName(const XMLCh* const name);
    01038
    01046     static bool isValidQName(const XMLCh* const name);
    01047
    01054     static bool isAlpha(XMLCh const theChar);
    01055
    01061     static bool isDigit(XMLCh const theChar);
    01062
    01068     static bool isAlphaNum(XMLCh const theChar);
    01069
    01075     static bool isHex(XMLCh const theChar);
    01076
    01084     static bool isAllWhiteSpace(const XMLCh* const toCheck);
    01085
    01091     static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
    01092
    01094
    01097
    01109     static void binToText
    01110     (
    01111         const   unsigned int    toFormat
    01112         ,       char* const     toFill
    01113         , const unsigned int    maxChars
    01114         , const unsigned int    radix
    01115         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01116     );
    01117
    01129     static void binToText
    01130     (
    01131         const   unsigned int    toFormat
    01132         ,       XMLCh* const    toFill
    01133         , const unsigned int    maxChars
    01134         , const unsigned int    radix
    01135         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01136     );
    01137
    01149     static void binToText
    01150     (
    01151         const   unsigned long   toFormat
    01152         ,       char* const     toFill
    01153         , const unsigned int    maxChars
    01154         , const unsigned int    radix
    01155         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01156     );
    01157
    01169     static void binToText
    01170     (
    01171         const   unsigned long   toFormat
    01172         ,       XMLCh* const    toFill
    01173         , const unsigned int    maxChars
    01174         , const unsigned int    radix
    01175         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01176     );
    01177
    01189     static void binToText
    01190     (
    01191         const   long            toFormat
    01192         ,       char* const     toFill
    01193         , const unsigned int    maxChars
    01194         , const unsigned int    radix
    01195         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01196     );
    01197
    01209     static void binToText
    01210     (
    01211         const   long            toFormat
    01212         ,       XMLCh* const    toFill
    01213         , const unsigned int    maxChars
    01214         , const unsigned int    radix
    01215         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01216     );
    01217
    01229     static void binToText
    01230     (
    01231         const   int             toFormat
    01232         ,       char* const     toFill
    01233         , const unsigned int    maxChars
    01234         , const unsigned int    radix
    01235         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01236     );
    01237
    01249     static void binToText
    01250     (
    01251         const   int             toFormat
    01252         ,       XMLCh* const    toFill
    01253         , const unsigned int    maxChars
    01254         , const unsigned int    radix
    01255         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01256     );
    01257
    01269     static bool textToBin
    01270     (
    01271         const   XMLCh* const    toConvert
    01272         ,       unsigned int&   toFill
    01273         ,       MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
    01274     );
    01275
    01289     static int parseInt
    01290     (
    01291         const   XMLCh* const    toConvert
    01292       , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
    01293     );
    01294
    01300     static void cut
    01301     (
    01302                 XMLCh* const    toCutFrom
    01303         , const unsigned int    count
    01304     );
    01305
    01316     static char* transcode
    01317     (
    01318         const   XMLCh* const    toTranscode
    01319     );
    01320     static char* transcode
    01321     (
    01322         const   XMLCh* const         toTranscode
    01323         ,       MemoryManager* const manager
    01324     );
    01325
    01341     static bool transcode
    01342     (
    01343         const   XMLCh* const    toTranscode
    01344         ,       char* const     toFill
    01345         , const unsigned int    maxChars
    01346         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01347     );
    01348
    01359     static XMLCh* transcode
    01360     (
    01361         const   char* const     toTranscode
    01362     );
    01363     static XMLCh* transcode
    01364     (
    01365         const   char* const          toTranscode
    01366         ,       MemoryManager* const manager
    01367     );
    01368
    01379     static bool transcode
    01380     (
    01381         const   char* const     toTranscode
    01382         ,       XMLCh* const    toFill
    01383         , const unsigned int    maxChars
    01384         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01385     );
    01386
    01392     static void trim(char* const toTrim);
    01393
    01399     static void trim(XMLCh* const toTrim);
    01400
    01408     static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc
    01409                                         , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01410
    01412
    01423     static XMLCh* makeUName
    01424     (
    01425         const   XMLCh* const    pszURI
    01426         , const XMLCh* const    pszName
    01427     );
    01428
    01445     static unsigned int replaceTokens
    01446     (
    01447                 XMLCh* const    errText
    01448         , const unsigned int    maxChars
    01449         , const XMLCh* const    text1
    01450         , const XMLCh* const    text2
    01451         , const XMLCh* const    text3
    01452         , const XMLCh* const    text4
    01453         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01454     );
    01455
    01460     static void upperCase(XMLCh* const toUpperCase);
    01461
    01466     static void lowerCase(XMLCh* const toLowerCase);
    01467
    01471     static bool isWSReplaced(const XMLCh* const toCheck);
    01472
    01476     static bool isWSCollapsed(const XMLCh* const toCheck);
    01477
    01483     static void replaceWS(XMLCh* const toConvert
    01484         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01485
    01491     static void collapseWS(XMLCh* const toConvert
    01492         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01493
    01499     static void removeWS(XMLCh* const toConvert
    01500     , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01501
    01502
    01508     static void removeChar(const XMLCh*     const srcString
    01509                          , const XMLCh&           toRemove
    01510                          ,       XMLBuffer&       dstBuffer);
    01511
    01519     static void fixURI(const XMLCh* const str, XMLCh* const target);
    01520
    01522
    01530     static void release(char** buf);
    01531
    01538     static void release(XMLCh** buf);
    01539
    01546     static void release(XMLByte** buf);
    01547
    01549
    01550
    01551 private :
    01552
    01556     XMLString();
    01558     ~XMLString();
    01560
    01561
    01565     static void initString(XMLLCPTranscoder* const defToUse,
    01566                            MemoryManager* const manager);
    01567     static void termString();
    01569
    01574     static bool validateRegion(const XMLCh* const str1, const int offset1,
    01575                         const XMLCh* const str2, const int offset2,
    01576                         const unsigned int charCount);
    01577
    01578     static MemoryManager* fgMemoryManager;
    01579
    01580     friend class XMLPlatformUtils;
    01581 };
    01582
    01583
    01584 // ---------------------------------------------------------------------------
    01585 //  Inline some methods that are either just passthroughs to other string
    01586 //  methods, or which are key for performance.
    01587 // ---------------------------------------------------------------------------
    01588 inline void XMLString::moveChars(       XMLCh* const targetStr
    01589                                 , const XMLCh* const srcStr
    01590                                 , const unsigned int count)
    01591 {
    01592     memcpy(targetStr, srcStr, count * sizeof(XMLCh));
    01593 }
    01594
    01595 inline unsigned int XMLString::stringLen(const XMLCh* const src)
    01596 {
    01597     if (src == 0 || *src == 0)
    01598     {
    01599         return 0;
    01600    }
    01601     else
    01602    {
    01603         const XMLCh* pszTmp = src + 1;
    01604
    01605         while (*pszTmp)
    01606             ++pszTmp;
    01607
    01608         return (unsigned int)(pszTmp - src);
    01609     }
    01610 }
    01611
    01612 inline XMLCh* XMLString::replicate(const XMLCh* const toRep,
    01613                                    MemoryManager* const manager)
    01614 {
    01615     // If a null string, return a null string!
    01616     XMLCh* ret = 0;
    01617     if (toRep)
    01618     {
    01619         const unsigned int len = stringLen(toRep);
    01620         ret = (XMLCh*) manager->allocate((len+1) * sizeof(XMLCh)); //new XMLCh[len + 1];
    01621         memcpy(ret, toRep, (len + 1) * sizeof(XMLCh));
    01622     }
    01623     return ret;
    01624 }
    01625
    01626 inline bool XMLString::startsWith(  const   XMLCh* const    toTest
    01627                                     , const XMLCh* const    prefix)
    01628 {
    01629     return (compareNString(toTest, prefix, stringLen(prefix)) == 0);
    01630 }
    01631
    01632 inline bool XMLString::startsWithI( const   XMLCh* const    toTest
    01633                                     , const XMLCh* const    prefix)
    01634 {
    01635     return (compareNIString(toTest, prefix, stringLen(prefix)) == 0);
    01636 }
    01637
    01638 inline bool XMLString::endsWith(const XMLCh* const toTest,
    01639                                 const XMLCh* const suffix)
    01640 {
    01641
    01642     unsigned int suffixLen = XMLString::stringLen(suffix);
    01643
    01644     return regionMatches(toTest, XMLString::stringLen(toTest) - suffixLen,
    01645                          suffix, 0, suffixLen);
    01646 }
    01647
    01648 inline bool XMLString::validateRegion(const XMLCh* const str1,
    01649                                       const int offset1,
    01650                                       const XMLCh* const str2,
    01651                                       const int offset2,
    01652                                       const unsigned int charCount)
    01653 {
    01654
    01655     if (offset1 < 0 || offset2 < 0 ||
    01656         (offset1 + charCount) > XMLString::stringLen(str1) ||
    01657         (offset2 + charCount) > XMLString::stringLen(str2) )
    01658         return false;
    01659
    01660     return true;
    01661 }
    01662
    01663 inline bool XMLString::equals(   const XMLCh* const    str1
    01664                                , const XMLCh* const    str2)
    01665 {
    01666     const XMLCh* psz1 = str1;
    01667     const XMLCh* psz2 = str2;
    01668
    01669     if (psz1 == 0 || psz2 == 0) {
    01670         if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
    01671             return false;
    01672         else
    01673             return true;
    01674     }
    01675
    01676     while (*psz1 == *psz2)
    01677     {
    01678         // If either has ended, then they both ended, so equal
    01679         if (!*psz1)
    01680             return true;
    01681
    01682         // Move upwards for the next round
    01683         psz1++;
    01684         psz2++;
    01685     }
    01686     return false;
    01687 }
    01688
    01689 inline bool XMLString::equals(   const char* const    str1
    01690                                , const char* const    str2)
    01691 {
    01692     const char* psz1 = str1;
    01693     const char* psz2 = str2;
    01694
    01695     if (psz1 == 0 || psz2 == 0) {
    01696         if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
    01697             return false;
    01698         else
    01699             return true;
    01700     }
    01701
    01702     while (*psz1 == *psz2)
    01703     {
    01704         // If either has ended, then they both ended, so equal
    01705         if (!*psz1)
    01706             return true;
    01707
    01708         // Move upwards for the next round
    01709         psz1++;
    01710         psz2++;
    01711     }
    01712     return false;
    01713 }
    01714
    01715 inline int XMLString::lastIndexOf(const XMLCh* const toSearch, const XMLCh ch)
    01716 {
    01717     return XMLString::lastIndexOf(ch, toSearch, stringLen(toSearch));
    01718 }
    01719
    01720 XERCES_CPP_NAMESPACE_END
    01721
    01722 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.