| 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  * The Apache Software License, Version 1.1
    00003  *
    00004  * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
    00005  * reserved.
    00006  *
    00007  * Redistribution and use in source and binary forms, with or without
    00008  * modification, are permitted provided that the following conditions
    00009  * are met:
    00010  *
    00011  * 1. Redistributions of source code must retain the above copyright
    00012  *    notice, this list of conditions and the following disclaimer.
    00013  *
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in
    00016  *    the documentation and/or other materials provided with the
    00017  *    distribution.
    00018  *
    00019  * 3. The end-user documentation included with the redistribution,
    00020  *    if any, must include the following acknowledgment:
    00021  *       "This product includes software developed by the
    00022  *        Apache Software Foundation (http://www.apache.org/)."
    00023  *    Alternately, this acknowledgment may appear in the software itself,
    00024  *    if and wherever such third-party acknowledgments normally appear.
    00025  *
    00026  * 4. The names "Xerces" and "Apache Software Foundation" must
    00027  *    not be used to endorse or promote products derived from this
    00028  *    software without prior written permission. For written
    00029  *    permission, please contact apache\@apache.org.
    00030  *
    00031  * 5. Products derived from this software may not be called "Apache",
    00032  *    nor may "Apache" appear in their name, without prior written
    00033  *    permission of the Apache Software Foundation.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00046  * SUCH DAMAGE.
    00047  * ====================================================================
    00048  *
    00049  * This software consists of voluntary contributions made by many
    00050  * individuals on behalf of the Apache Software Foundation, and was
    00051  * originally based on software copyright (c) 1999, International
    00052  * Business Machines, Inc., http://www.ibm.com .  For more information
    00053  * on the Apache Software Foundation, please see
    00054  * <http://www.apache.org/>.
    00055  */
    00056
    00057 /*
    00058  * $Log: XMLString.hpp,v $
    00059  * Revision 1.23  2003/12/24 15:24:13  cargilld
    00060  * More updates to memory management so that the static memory manager.
    00061  *
    00062  * Revision 1.22  2003/12/17 20:00:49  cargilld
    00063  * Update for memory management so that the static memory manager (one
    00064  * used to call Initialize) is only for static data.
    00065  *
    00066  * Revision 1.21  2003/12/17 00:18:35  cargilld
    00067  * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    00068  *
    00069  * Revision 1.20  2003/10/02 11:07:26  gareth
    00070  * 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.
    00071  *
    00072  * Revision 1.19  2003/10/01 00:22:20  knoaman
    00073  * Add a lastIndexOf method that takes the string length as one of the params.
    00074  *
    00075  * Revision 1.18  2003/08/25 20:39:47  neilg
    00076  * fix XMLString::findAny(...) docs so that they match what the method actually does (and has done since time immemorial)
    00077  *
    00078  * Revision 1.17  2003/05/18 14:02:05  knoaman
    00079  * Memory manager implementation: pass per instance manager.
    00080  *
    00081  * Revision 1.16  2003/05/15 19:07:46  knoaman
    00082  * Partial implementation of the configurable memory manager.
    00083  *
    00084  * Revision 1.15  2003/04/21 20:07:05  knoaman
    00085  * Performance: use memcpy in moveChars and replicate.
    00086  *
    00087  * Revision 1.14  2003/02/25 16:42:31  tng
    00088  * [Bug 7072] Documentation for XMLString::transcode states invalid return value.
    00089  *
    00090  * Revision 1.13  2003/02/05 18:50:56  tng
    00091  * [Bug 11915] Utility for freeing memory.
    00092  *
    00093  * Revision 1.12  2003/01/24 23:16:33  peiyongz
    00094  * removeWS() added;
    00095  *
    00096  * Revision 1.11  2002/12/20 22:10:21  tng
    00097  * XML 1.1
    00098  *
    00099  * Revision 1.10  2002/12/18 14:17:54  gareth
    00100  * Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
    00101  *
    00102  * Revision 1.9  2002/12/04 02:32:43  knoaman
    00103  * #include cleanup.
    00104  *
    00105  * Revision 1.8  2002/11/05 17:42:39  peiyongz
    00106  * equals( const char* const, const char* const)
    00107  *
    00108  * Revision 1.7  2002/11/04 15:22:05  tng
    00109  * C++ Namespace Support.
    00110  *
    00111  * Revision 1.6  2002/10/01 19:45:22  tng
    00112  * Performance in XMLString::equals, only need to check one string for null as they are equal already.
    00113  *
    00114  * Revision 1.5  2002/09/24 19:41:21  tng
    00115  * New inline function equals that is modified from compareString but simply return true or false.
    00116  *
    00117  * Revision 1.4  2002/09/23 18:42:18  tng
    00118  * DOM L3: Support baseURI.   Add utility fixURI to transform an absolute path filename to standard URI form.
    00119  *
    00120  * Revision 1.3  2002/08/27 19:24:43  peiyongz
    00121  * Bug#12087: patch from Thomas Ford (tom@decisionsoft.com)
    00122  *
    00123  * Revision 1.2  2002/02/20 18:17:02  tng
    00124  * [Bug 5977] Warnings on generating apiDocs.
    00125  *
    00126  * Revision 1.1.1.1  2002/02/01 22:22:16  peiyongz
    00127  * sane_include
    00128  *
    00129  * Revision 1.26  2001/08/10 16:23:06  peiyongz
    00130  * isHex(), isAlphaNum(), isAllWhiteSpace() and patternMatch() Added
    00131  *
    00132  * Revision 1.25  2001/07/06 20:27:57  peiyongz
    00133  * isValidaQName()
    00134  *
    00135  * Revision 1.24  2001/07/04 14:38:20  peiyongz
    00136  * IDDatatypeValidator: created
    00137  * DatatypeValidatorFactory: IDDTV enabled
    00138  * XMLString:isValidName(): to validate Name (XML [4][5])
    00139  *
    00140  * Revision 1.23  2001/06/13 14:07:55  peiyongz
    00141  * isValidaEncName() to validate an encoding name (EncName)
    00142  *
    00143  * Revision 1.22  2001/05/23 15:44:51  tng
    00144  * Schema: NormalizedString fix.  By Pei Yong Zhang.
    00145  *
    00146  * Revision 1.21  2001/05/11 13:26:31  tng
    00147  * Copyright update.
    00148  *
    00149  * Revision 1.20  2001/05/09 18:43:30  tng
    00150  * Add StringDatatypeValidator and BooleanDatatypeValidator.  By Pei Yong Zhang.
    00151  *
    00152  * Revision 1.19  2001/05/03 20:34:35  tng
    00153  * Schema: SchemaValidator update
    00154  *
    00155  * Revision 1.18  2001/05/03 19:17:35  knoaman
    00156  * TraverseSchema Part II.
    00157  *
    00158  * Revision 1.17  2001/03/21 21:56:13  tng
    00159  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
    00160  *
    00161  * Revision 1.16  2001/03/02 20:52:46  knoaman
    00162  * Schema: Regular expression - misc. updates for error messages,
    00163  * and additions of new functions to XMLString class.
    00164  *
    00165  * Revision 1.15  2001/01/15 21:26:34  tng
    00166  * Performance Patches by David Bertoni.
    00167  *
    00168  * Details: (see xerces-c-dev mailing Jan 14)
    00169  * XMLRecognizer.cpp: the internal encoding string XMLUni::fgXMLChEncodingString
    00170  * was going through this function numerous times.  As a result, the top hot-spot
    00171  * for the parse was _wcsicmp().  The real problem is that the Microsofts wide string
    00172  * functions are unbelievably slow.  For things like encodings, it might be
    00173  * better to use a special comparison function that only considers a-z and
    00174  * A-Z as characters with case.  This works since the character set for
    00175  * encodings is limit to printable ASCII characters.
    00176  *
    00177  *  XMLScanner2.cpp: This also has some case-sensitive vs. insensitive compares.
    00178  * They are also much faster.  The other tweak is to only make a copy of an attribute
    00179  * string if it needs to be split.  And then, the strategy is to try to use a
    00180  * stack-based buffer, rather than a dynamically-allocated one.
    00181  *
    00182  * SAX2XMLReaderImpl.cpp: Again, more case-sensitive vs. insensitive comparisons.
    00183  *
    00184  * KVStringPair.cpp & hpp: By storing the size of the allocation, the storage can
    00185  * likely be re-used many times, cutting down on dynamic memory allocations.
    00186  *
    00187  * XMLString.hpp: a more efficient implementation of stringLen().
    00188  *
    00189  * DTDValidator.cpp: another case of using a stack-based buffer when possible
    00190  *
    00191  * These patches made a big difference in parse time in some of our test
    00192  * files, especially the ones are very attribute-heavy.
    00193  *
    00194  * Revision 1.14  2000/10/13 22:47:57  andyh
    00195  * Fix bug (failure to null-terminate result) in XMLString::trim().
    00196  * Patch contributed by Nadav Aharoni
    00197  *
    00198  * Revision 1.13  2000/04/12 18:42:15  roddey
    00199  * Improved docs in terms of what 'max chars' means in the method
    00200  * parameters.
    00201  *
    00202  * Revision 1.12  2000/04/06 19:42:51  rahulj
    00203  * Clarified how big the target buffer should be in the API
    00204  * documentation.
    00205  *
    00206  * Revision 1.11  2000/03/23 01:02:38  roddey
    00207  * Updates to the XMLURL class to correct a lot of parsing problems
    00208  * and to add support for the port number. Updated the URL tests
    00209  * to test some of this new stuff.
    00210  *
    00211  * Revision 1.10  2000/03/20 23:00:46  rahulj
    00212  * Moved the inline definition of stringLen before the first
    00213  * use. This satisfied the HP CC compiler.
    00214  *
    00215  * Revision 1.9  2000/03/02 19:54:49  roddey
    00216  * This checkin includes many changes done while waiting for the
    00217  * 1.1.0 code to be finished. I can't list them all here, but a list is
    00218  * available elsewhere.
    00219  *
    00220  * Revision 1.8  2000/02/24 20:05:26  abagchi
    00221  * Swat for removing Log from API docs
    00222  *
    00223  * Revision 1.7  2000/02/16 18:51:52  roddey
    00224  * Fixed some facts in the docs and reformatted the docs to stay within
    00225  * a reasonable line width.
    00226  *
    00227  * Revision 1.6  2000/02/16 17:07:07  abagchi
    00228  * Added API docs
    00229  *
    00230  * Revision 1.5  2000/02/06 07:48:06  rahulj
    00231  * Year 2K copyright swat.
    00232  *
    00233  * Revision 1.4  2000/01/12 00:16:23  roddey
    00234  * Changes to deal with multiply nested, relative pathed, entities and to deal
    00235  * with the new URL class changes.
    00236  *
    00237  * Revision 1.3  1999/12/18 00:18:10  roddey
    00238  * More changes to support the new, completely orthagonal support for
    00239  * intrinsic encodings.
    00240  *
    00241  * Revision 1.2  1999/12/15 19:41:28  roddey
    00242  * Support for the new transcoder system, where even intrinsic encodings are
    00243  * done via the same transcoder abstraction as external ones.
    00244  *
    00245  * Revision 1.1.1.1  1999/11/09 01:05:52  twl
    00246  * Initial checkin
    00247  *
    00248  * Revision 1.2  1999/11/08 20:45:21  rahul
    00249  * Swat for adding in Product name and CVS comment log variable.
    00250  *
    00251  */
    00252
    00253 #if !defined(XMLSTRING_HPP)
    00254 #define XMLSTRING_HPP
    00255
    00256 #include <xercesc/util/BaseRefVectorOf.hpp>
    00257 #include <xercesc/framework/MemoryManager.hpp>
    00258 #include <string.h>
    00259
    00260 XERCES_CPP_NAMESPACE_BEGIN
    00261
    00262 class XMLLCPTranscoder;
    00274 class  XMLString
    00275 {
    00276 public:
    00277     /* Static methods for native character mode string manipulation */
    00278
    00279
    00296     static void catString
    00297     (
    00298                 char* const     target
    00299         , const char* const     src
    00300     );
    00301
    00314     static void catString
    00315     (
    00316                 XMLCh* const    target
    00317         , const XMLCh* const    src
    00318     );
    00320
    00334     static int compareIString
    00335     (
    00336         const   char* const     str1
    00337         , const char* const     str2
    00338     );
    00339
    00350     static int compareIString
    00351     (
    00352         const   XMLCh* const    str1
    00353         , const XMLCh* const    str2
    00354     );
    00355
    00356
    00370     static int compareNString
    00371     (
    00372         const   char* const     str1
    00373         , const char* const     str2
    00374         , const unsigned int    count
    00375     );
    00376
    00390     static int compareNString
    00391     (
    00392         const   XMLCh* const    str1
    00393         , const XMLCh* const    str2
    00394         , const unsigned int    count
    00395     );
    00396
    00397
    00411     static int compareNIString
    00412     (
    00413         const   char* const     str1
    00414         , const char* const     str2
    00415         , const unsigned int    count
    00416     );
    00417
    00432     static int compareNIString
    00433     (
    00434         const   XMLCh* const    str1
    00435         , const XMLCh* const    str2
    00436         , const unsigned int    count
    00437     );
    00438
    00451     static int compareString
    00452     (
    00453         const   char* const     str1
    00454         , const char* const     str2
    00455     );
    00456
    00468     static int compareString
    00469     (
    00470         const   XMLCh* const    str1
    00471         , const XMLCh* const    str2
    00472     );
    00473
    00482     static bool equals
    00483     (
    00484           const XMLCh* const    str1
    00485         , const XMLCh* const    str2
    00486     );
    00487
    00488     static bool equals
    00489     (
    00490           const char* const    str1
    00491         , const char* const    str2
    00492     );
    00493
    00520     static bool regionMatches
    00521     (
    00522         const   XMLCh* const    str1
    00523         , const int             offset1
    00524         , const XMLCh* const    str2
    00525         , const int             offset2
    00526         , const unsigned int    charCount
    00527     );
    00528
    00556     static bool regionIMatches
    00557     (
    00558         const   XMLCh* const    str1
    00559         , const int             offset1
    00560         , const XMLCh* const    str2
    00561         , const int             offset2
    00562         , const unsigned int    charCount
    00563     );
    00565
    00578     static void copyString
    00579     (
    00580                 char* const     target
    00581         , const char* const     src
    00582     );
    00583
    00594     static void copyString
    00595     (
    00596                 XMLCh* const    target
    00597         , const XMLCh* const    src
    00598     );
    00599
    00612     static bool copyNString
    00613     (
    00614                 XMLCh* const    target
    00615         , const XMLCh* const    src
    00616         , const unsigned int    maxChars
    00617     );
    00619
    00628     static unsigned int hash
    00629     (
    00630         const   char* const     toHash
    00631         , const unsigned int    hashModulus
    00632         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00633     );
    00634
    00641     static unsigned int hash
    00642     (
    00643         const   XMLCh* const    toHash
    00644         , const unsigned int    hashModulus
    00645         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00646     );
    00647
    00657     static unsigned int hashN
    00658     (
    00659         const   XMLCh* const    toHash
    00660         , const unsigned int    numChars
    00661         , const unsigned int    hashModulus
    00662         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00663     );
    00664
    00666
    00677     static int indexOf(const char* const toSearch, const char ch);
    00678
    00687     static int indexOf(const XMLCh* const toSearch, const XMLCh ch);
    00688
    00699     static int indexOf
    00700     (
    00701         const   char* const     toSearch
    00702         , const char            chToFind
    00703         , const unsigned int    fromIndex
    00704         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00705     );
    00706
    00717     static int indexOf
    00718     (
    00719         const   XMLCh* const    toSearch
    00720         , const XMLCh           chToFind
    00721         , const unsigned int    fromIndex
    00722         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00723     );
    00724
    00733     static int lastIndexOf(const char* const toSearch, const char ch);
    00734
    00743     static int lastIndexOf(const XMLCh* const toSearch, const XMLCh ch);
    00744
    00754     static int lastIndexOf
    00755     (
    00756         const XMLCh ch
    00757         , const XMLCh* const toSearch
    00758         , const unsigned int toSearchLen
    00759     );
    00760
    00771     static int lastIndexOf
    00772     (
    00773         const   char* const     toSearch
    00774         , const char            chToFind
    00775         , const unsigned int    fromIndex
    00776         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00777     );
    00778
    00789     static int lastIndexOf
    00790     (
    00791         const   XMLCh* const    toSearch
    00792         , const XMLCh           ch
    00793         , const unsigned int    fromIndex
    00794         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00795     );
    00797
    00805     static void moveChars
    00806     (
    00807                 XMLCh* const    targetStr
    00808         , const XMLCh* const    srcStr
    00809         , const unsigned int    count
    00810     );
    00811
    00813
    00824     static void subString
    00825     (
    00826                 char* const    targetStr
    00827         , const char* const    srcStr
    00828         , const int            startIndex
    00829         , const int            endIndex
    00830         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00831     );
    00832
    00841     static void subString
    00842     (
    00843                 XMLCh* const    targetStr
    00844         , const XMLCh* const    srcStr
    00845         , const int             startIndex
    00846         , const int             endIndex
    00847         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    00848     );
    00849
    00851
    00863     static char* replicate(const char* const toRep);
    00864
    00873     static char* replicate(const char* const toRep,
    00874                            MemoryManager* const manager);
    00875
    00885     static XMLCh* replicate(const XMLCh* const toRep);
    00886
    00895     static XMLCh* replicate(const XMLCh* const toRep,
    00896                             MemoryManager* const manager);
    00897
    00899
    00908     static bool startsWith
    00909     (
    00910         const   char* const     toTest
    00911         , const char* const     prefix
    00912     );
    00913
    00920     static bool startsWith
    00921     (
    00922         const   XMLCh* const    toTest
    00923         , const XMLCh* const    prefix
    00924     );
    00925
    00934     static bool startsWithI
    00935     (
    00936         const   char* const     toTest
    00937         , const char* const     prefix
    00938     );
    00939
    00949     static bool startsWithI
    00950     (
    00951         const   XMLCh* const    toTest
    00952         , const XMLCh* const    prefix
    00953     );
    00954
    00961     static bool endsWith
    00962     (
    00963         const   XMLCh* const    toTest
    00964         , const XMLCh* const    suffix
    00965     );
    00966
    00967
    00976     static const XMLCh* findAny
    00977     (
    00978         const   XMLCh* const    toSearch
    00979         , const XMLCh* const    searchList
    00980     );
    00981
    00990     static XMLCh* findAny
    00991     (
    00992                 XMLCh* const    toSearch
    00993         , const XMLCh* const    searchList
    00994     );
    00995
    01002     static int patternMatch
    01003     (
    01004           const XMLCh* const    toSearch
    01005         , const XMLCh* const    pattern
    01006     );
    01007
    01012     static unsigned int stringLen(const char* const src);
    01013
    01018     static unsigned int stringLen(const XMLCh* const src);
    01019
    01027     static bool isValidNCName(const XMLCh* const name);
    01028
    01036     static bool isValidName(const XMLCh* const name);
    01037
    01043     static bool isValidEncName(const XMLCh* const name);
    01044
    01052     static bool isValidQName(const XMLCh* const name);
    01053
    01060     static bool isAlpha(XMLCh const theChar);
    01061
    01067     static bool isDigit(XMLCh const theChar);
    01068
    01074     static bool isAlphaNum(XMLCh const theChar);
    01075
    01081     static bool isHex(XMLCh const theChar);
    01082
    01090     static bool isAllWhiteSpace(const XMLCh* const toCheck);
    01091
    01097     static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
    01098
    01100
    01103
    01114     static void binToText
    01115     (
    01116         const   unsigned int    toFormat
    01117         ,       char* const     toFill
    01118         , const unsigned int    maxChars
    01119         , const unsigned int    radix
    01120         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01121     );
    01122
    01133     static void binToText
    01134     (
    01135         const   unsigned int    toFormat
    01136         ,       XMLCh* const    toFill
    01137         , const unsigned int    maxChars
    01138         , const unsigned int    radix
    01139         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01140     );
    01141
    01152     static void binToText
    01153     (
    01154         const   unsigned long   toFormat
    01155         ,       char* const     toFill
    01156         , const unsigned int    maxChars
    01157         , const unsigned int    radix
    01158         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01159     );
    01160
    01171     static void binToText
    01172     (
    01173         const   unsigned long   toFormat
    01174         ,       XMLCh* const    toFill
    01175         , const unsigned int    maxChars
    01176         , const unsigned int    radix
    01177         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01178     );
    01179
    01190     static void binToText
    01191     (
    01192         const   long            toFormat
    01193         ,       char* const     toFill
    01194         , const unsigned int    maxChars
    01195         , const unsigned int    radix
    01196         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01197     );
    01198
    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
    01228     static void binToText
    01229     (
    01230         const   int             toFormat
    01231         ,       char* const     toFill
    01232         , const unsigned int    maxChars
    01233         , const unsigned int    radix
    01234         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01235     );
    01236
    01247     static void binToText
    01248     (
    01249         const   int             toFormat
    01250         ,       XMLCh* const    toFill
    01251         , const unsigned int    maxChars
    01252         , const unsigned int    radix
    01253         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01254     );
    01255
    01266     static bool textToBin
    01267     (
    01268         const   XMLCh* const    toConvert
    01269         ,       unsigned int&   toFill
    01270         ,       MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
    01271     );
    01272
    01285     static int parseInt
    01286     (
    01287         const   XMLCh* const    toConvert
    01288       , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
    01289     );
    01290
    01296     static void cut
    01297     (
    01298                 XMLCh* const    toCutFrom
    01299         , const unsigned int    count
    01300     );
    01301
    01312     static char* transcode
    01313     (
    01314         const   XMLCh* const    toTranscode
    01315     );
    01316     static char* transcode
    01317     (
    01318         const   XMLCh* const         toTranscode
    01319         ,       MemoryManager* const manager
    01320     );
    01321
    01336     static bool transcode
    01337     (
    01338         const   XMLCh* const    toTranscode
    01339         ,       char* const     toFill
    01340         , const unsigned int    maxChars
    01341         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01342     );
    01343
    01354     static XMLCh* transcode
    01355     (
    01356         const   char* const     toTranscode
    01357     );
    01358     static XMLCh* transcode
    01359     (
    01360         const   char* const          toTranscode
    01361         ,       MemoryManager* const manager
    01362     );
    01363
    01373     static bool transcode
    01374     (
    01375         const   char* const     toTranscode
    01376         ,       XMLCh* const    toFill
    01377         , const unsigned int    maxChars
    01378         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01379     );
    01380
    01386     static void trim(char* const toTrim);
    01387
    01393     static void trim(XMLCh* const toTrim);
    01394
    01401     static BaseRefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc
    01402                                         , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01403
    01405
    01416     static XMLCh* makeUName
    01417     (
    01418         const   XMLCh* const    pszURI
    01419         , const XMLCh* const    pszName
    01420     );
    01421
    01437     static unsigned int replaceTokens
    01438     (
    01439                 XMLCh* const    errText
    01440         , const unsigned int    maxChars
    01441         , const XMLCh* const    text1
    01442         , const XMLCh* const    text2
    01443         , const XMLCh* const    text3
    01444         , const XMLCh* const    text4
    01445         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
    01446     );
    01447
    01452     static void upperCase(XMLCh* const toUpperCase);
    01453
    01458     static void lowerCase(XMLCh* const toLowerCase);
    01459
    01463     static bool isWSReplaced(const XMLCh* const toCheck);
    01464
    01468     static bool isWSCollapsed(const XMLCh* const toCheck);
    01469
    01474     static void replaceWS(XMLCh* const toConvert
    01475         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01476
    01481     static void collapseWS(XMLCh* const toConvert
    01482         , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
    01483
    01488     static void removeWS(XMLCh* const toConvert
    01489     , MemoryManager*       const manager = XMLPlatformUtils::fgMemoryManager);
    01490
    01498     static void fixURI(const XMLCh* const str, XMLCh* const target);
    01499
    01501
    01509     static void release(char** buf);
    01510
    01517     static void release(XMLCh** buf);
    01518
    01525     static void release(XMLByte** buf);
    01526
    01528
    01529
    01530 private :
    01531
    01535     XMLString();
    01537     ~XMLString();
    01539
    01540
    01544     static void initString(XMLLCPTranscoder* const defToUse,
    01545                            MemoryManager* const manager);
    01546     static void termString();
    01548
    01553     static bool validateRegion(const XMLCh* const str1, const int offset1,
    01554                         const XMLCh* const str2, const int offset2,
    01555                         const unsigned int charCount);
    01556
    01557     static MemoryManager* fgMemoryManager;
    01558
    01559     friend class XMLPlatformUtils;
    01560 };
    01561
    01562
    01563 // ---------------------------------------------------------------------------
    01564 //  Inline some methods that are either just passthroughs to other string
    01565 //  methods, or which are key for performance.
    01566 // ---------------------------------------------------------------------------
    01567 inline void XMLString::moveChars(       XMLCh* const targetStr
    01568                                 , const XMLCh* const srcStr
    01569                                 , const unsigned int count)
    01570 {
    01571     memcpy(targetStr, srcStr, count * sizeof(XMLCh));
    01572 }
    01573
    01574 inline unsigned int XMLString::stringLen(const XMLCh* const src)
    01575 {
    01576     if (src == 0 || *src == 0)
    01577     {
    01578         return 0;
    01579    }
    01580     else
    01581    {
    01582         const XMLCh* pszTmp = src + 1;
    01583
    01584         while (*pszTmp)
    01585             ++pszTmp;
    01586
    01587         return (unsigned int)(pszTmp - src);
    01588     }
    01589 }
    01590
    01591 inline XMLCh* XMLString::replicate(const XMLCh* const toRep,
    01592                                    MemoryManager* const manager)
    01593 {
    01594     // If a null string, return a null string!
    01595     XMLCh* ret = 0;
    01596     if (toRep)
    01597     {
    01598         const unsigned int len = stringLen(toRep);
    01599         ret = (XMLCh*) manager->allocate((len+1) * sizeof(XMLCh)); //new XMLCh[len + 1];
    01600         memcpy(ret, toRep, (len + 1) * sizeof(XMLCh));
    01601     }
    01602     return ret;
    01603 }
    01604
    01605 inline bool XMLString::startsWith(  const   XMLCh* const    toTest
    01606                                     , const XMLCh* const    prefix)
    01607 {
    01608     return (compareNString(toTest, prefix, stringLen(prefix)) == 0);
    01609 }
    01610
    01611 inline bool XMLString::startsWithI( const   XMLCh* const    toTest
    01612                                     , const XMLCh* const    prefix)
    01613 {
    01614     return (compareNIString(toTest, prefix, stringLen(prefix)) == 0);
    01615 }
    01616
    01617 inline bool XMLString::endsWith(const XMLCh* const toTest,
    01618                                 const XMLCh* const suffix)
    01619 {
    01620
    01621     unsigned int suffixLen = XMLString::stringLen(suffix);
    01622
    01623     return regionMatches(toTest, XMLString::stringLen(toTest) - suffixLen,
    01624                          suffix, 0, suffixLen);
    01625 }
    01626
    01627 inline bool XMLString::validateRegion(const XMLCh* const str1,
    01628                                       const int offset1,
    01629                                       const XMLCh* const str2,
    01630                                       const int offset2,
    01631                                       const unsigned int charCount)
    01632 {
    01633
    01634     if (offset1 < 0 || offset2 < 0 ||
    01635         (offset1 + charCount) > XMLString::stringLen(str1) ||
    01636         (offset2 + charCount) > XMLString::stringLen(str2) )
    01637         return false;
    01638
    01639     return true;
    01640 }
    01641
    01642 inline bool XMLString::equals(   const XMLCh* const    str1
    01643                                , const XMLCh* const    str2)
    01644 {
    01645     const XMLCh* psz1 = str1;
    01646     const XMLCh* psz2 = str2;
    01647
    01648     if (psz1 == 0 || psz2 == 0) {
    01649         if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
    01650             return false;
    01651         else
    01652             return true;
    01653     }
    01654
    01655     while (*psz1 == *psz2)
    01656     {
    01657         // If either has ended, then they both ended, so equal
    01658         if (!*psz1)
    01659             return true;
    01660
    01661         // Move upwards for the next round
    01662         psz1++;
    01663         psz2++;
    01664     }
    01665     return false;
    01666 }
    01667
    01668 inline bool XMLString::equals(   const char* const    str1
    01669                                , const char* const    str2)
    01670 {
    01671     const char* psz1 = str1;
    01672     const char* psz2 = str2;
    01673
    01674     if (psz1 == 0 || psz2 == 0) {
    01675         if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
    01676             return false;
    01677         else
    01678             return true;
    01679     }
    01680
    01681     while (*psz1 == *psz2)
    01682     {
    01683         // If either has ended, then they both ended, so equal
    01684         if (!*psz1)
    01685             return true;
    01686
    01687         // Move upwards for the next round
    01688         psz1++;
    01689         psz2++;
    01690     }
    01691     return false;
    01692 }
    01693
    01694 inline int XMLString::lastIndexOf(const XMLCh* const toSearch, const XMLCh ch)
    01695 {
    01696     return XMLString::lastIndexOf(ch, toSearch, stringLen(toSearch));
    01697 }
    01698
    01699 XERCES_CPP_NAMESPACE_END
    01700
    01701 #endif

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