XMLString.hpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:51k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 1999, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Log: XMLString.hpp,v $
  58.  * Revision 1.26  2001/08/10 16:23:06  peiyongz
  59.  * isHex(), isAlphaNum(), isAllWhiteSpace() and patternMatch() Added
  60.  *
  61.  * Revision 1.25  2001/07/06 20:27:57  peiyongz
  62.  * isValidaQName()
  63.  *
  64.  * Revision 1.24  2001/07/04 14:38:20  peiyongz
  65.  * IDDatatypeValidator: created
  66.  * DatatypeValidatorFactory: IDDTV enabled
  67.  * XMLString:isValidName(): to validate Name (XML [4][5])
  68.  *
  69.  * Revision 1.23  2001/06/13 14:07:55  peiyongz
  70.  * isValidaEncName() to validate an encoding name (EncName)
  71.  *
  72.  * Revision 1.22  2001/05/23 15:44:51  tng
  73.  * Schema: NormalizedString fix.  By Pei Yong Zhang.
  74.  *
  75.  * Revision 1.21  2001/05/11 13:26:31  tng
  76.  * Copyright update.
  77.  *
  78.  * Revision 1.20  2001/05/09 18:43:30  tng
  79.  * Add StringDatatypeValidator and BooleanDatatypeValidator.  By Pei Yong Zhang.
  80.  *
  81.  * Revision 1.19  2001/05/03 20:34:35  tng
  82.  * Schema: SchemaValidator update
  83.  *
  84.  * Revision 1.18  2001/05/03 19:17:35  knoaman
  85.  * TraverseSchema Part II.
  86.  *
  87.  * Revision 1.17  2001/03/21 21:56:13  tng
  88.  * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
  89.  *
  90.  * Revision 1.16  2001/03/02 20:52:46  knoaman
  91.  * Schema: Regular expression - misc. updates for error messages,
  92.  * and additions of new functions to XMLString class.
  93.  *
  94.  * Revision 1.15  2001/01/15 21:26:34  tng
  95.  * Performance Patches by David Bertoni.
  96.  *
  97.  * Details: (see xerces-c-dev mailing Jan 14)
  98.  * XMLRecognizer.cpp: the internal encoding string XMLUni::fgXMLChEncodingString
  99.  * was going through this function numerous times.  As a result, the top hot-spot
  100.  * for the parse was _wcsicmp().  The real problem is that the Microsofts wide string
  101.  * functions are unbelievably slow.  For things like encodings, it might be
  102.  * better to use a special comparison function that only considers a-z and
  103.  * A-Z as characters with case.  This works since the character set for
  104.  * encodings is limit to printable ASCII characters.
  105.  *
  106.  *  XMLScanner2.cpp: This also has some case-sensitive vs. insensitive compares.
  107.  * They are also much faster.  The other tweak is to only make a copy of an attribute
  108.  * string if it needs to be split.  And then, the strategy is to try to use a
  109.  * stack-based buffer, rather than a dynamically-allocated one.
  110.  *
  111.  * SAX2XMLReaderImpl.cpp: Again, more case-sensitive vs. insensitive comparisons.
  112.  *
  113.  * KVStringPair.cpp & hpp: By storing the size of the allocation, the storage can
  114.  * likely be re-used many times, cutting down on dynamic memory allocations.
  115.  *
  116.  * XMLString.hpp: a more efficient implementation of stringLen().
  117.  *
  118.  * DTDValidator.cpp: another case of using a stack-based buffer when possible
  119.  *
  120.  * These patches made a big difference in parse time in some of our test
  121.  * files, especially the ones are very attribute-heavy.
  122.  *
  123.  * Revision 1.14  2000/10/13 22:47:57  andyh
  124.  * Fix bug (failure to null-terminate result) in XMLString::trim().
  125.  * Patch contributed by Nadav Aharoni
  126.  *
  127.  * Revision 1.13  2000/04/12 18:42:15  roddey
  128.  * Improved docs in terms of what 'max chars' means in the method
  129.  * parameters.
  130.  *
  131.  * Revision 1.12  2000/04/06 19:42:51  rahulj
  132.  * Clarified how big the target buffer should be in the API
  133.  * documentation.
  134.  *
  135.  * Revision 1.11  2000/03/23 01:02:38  roddey
  136.  * Updates to the XMLURL class to correct a lot of parsing problems
  137.  * and to add support for the port number. Updated the URL tests
  138.  * to test some of this new stuff.
  139.  *
  140.  * Revision 1.10  2000/03/20 23:00:46  rahulj
  141.  * Moved the inline definition of stringLen before the first
  142.  * use. This satisfied the HP CC compiler.
  143.  *
  144.  * Revision 1.9  2000/03/02 19:54:49  roddey
  145.  * This checkin includes many changes done while waiting for the
  146.  * 1.1.0 code to be finished. I can't list them all here, but a list is
  147.  * available elsewhere.
  148.  *
  149.  * Revision 1.8  2000/02/24 20:05:26  abagchi
  150.  * Swat for removing Log from API docs
  151.  *
  152.  * Revision 1.7  2000/02/16 18:51:52  roddey
  153.  * Fixed some facts in the docs and reformatted the docs to stay within
  154.  * a reasonable line width.
  155.  *
  156.  * Revision 1.6  2000/02/16 17:07:07  abagchi
  157.  * Added API docs
  158.  *
  159.  * Revision 1.5  2000/02/06 07:48:06  rahulj
  160.  * Year 2K copyright swat.
  161.  *
  162.  * Revision 1.4  2000/01/12 00:16:23  roddey
  163.  * Changes to deal with multiply nested, relative pathed, entities and to deal
  164.  * with the new URL class changes.
  165.  *
  166.  * Revision 1.3  1999/12/18 00:18:10  roddey
  167.  * More changes to support the new, completely orthagonal support for
  168.  * intrinsic encodings.
  169.  *
  170.  * Revision 1.2  1999/12/15 19:41:28  roddey
  171.  * Support for the new transcoder system, where even intrinsic encodings are
  172.  * done via the same transcoder abstraction as external ones.
  173.  *
  174.  * Revision 1.1.1.1  1999/11/09 01:05:52  twl
  175.  * Initial checkin
  176.  *
  177.  * Revision 1.2  1999/11/08 20:45:21  rahul
  178.  * Swat for adding in Product name and CVS comment log variable.
  179.  *
  180.  */
  181. #if !defined(XMLSTRING_HPP)
  182. #define XMLSTRING_HPP
  183. #include <util/XercesDefs.hpp>
  184. #include <util/RefVectorOf.hpp>
  185. class XMLLCPTranscoder;
  186. /**
  187.   * Class for representing native character strings and handling common string
  188.   * operations
  189.   *
  190.   * This class is Unicode compliant. This class is designed primarily
  191.   * for internal use, but due to popular demand, it is being made
  192.   * publicly available. Users of this class must understand that this
  193.   * is not an officially supported class. All public methods of this
  194.   * class are <i>static functions</i>.
  195.   *
  196.   */
  197. class XMLUTIL_EXPORT XMLString
  198. {
  199. public:
  200.     /* Static methods for native character mode string manipulation */
  201.     /** @name Conversion functions */
  202.     //@{
  203.     /** Converts binary data to a text string based a given radix
  204.       *
  205.       * @param toFormat The beginning of the input string to convert
  206.       * @param toFill The buffer that will hold the output on return. The
  207.       *        size of this buffer should at least be 'maxChars + 1'.
  208.       * @param maxChars The maximum number of output characters that can be
  209.       *         accepted. If the result will not fit, it is an error.
  210.       * @param radix The radix of the input data, based on which the conversion
  211.       * will be done
  212.       */
  213.     static void binToText
  214.     (
  215.         const   unsigned int    toFormat
  216.         ,       char* const     toFill
  217.         , const unsigned int    maxChars
  218.         , const unsigned int    radix
  219.     );
  220.     /** Converts binary data to a text string based a given radix
  221.       *
  222.       * @param toFormat The beginning of the input string to convert
  223.       * @param toFill The buffer that will hold the output on return. The
  224.       *        size of this buffer should at least be 'maxChars + 1'.
  225.       * @param maxChars The maximum number of output characters that can be
  226.       *         accepted. If the result will not fit, it is an error.
  227.       * @param radix The radix of the input data, based on which the conversion
  228.       * will be done
  229.       */
  230.     static void binToText
  231.     (
  232.         const   unsigned int    toFormat
  233.         ,       XMLCh* const    toFill
  234.         , const unsigned int    maxChars
  235.         , const unsigned int    radix
  236.     );
  237.     /** Converts binary data to a text string based a given radix
  238.       *
  239.       * @param toFormat The beginning of the input string to convert
  240.       * @param toFill The buffer that will hold the output on return. The
  241.       *        size of this buffer should at least be 'maxChars + 1'.
  242.       * @param maxChars The maximum number of output characters that can be
  243.       *         accepted. If the result will not fit, it is an error.
  244.       * @param radix The radix of the input data, based on which the conversion
  245.       * will be done
  246.       */
  247.     static void binToText
  248.     (
  249.         const   unsigned long   toFormat
  250.         ,       char* const     toFill
  251.         , const unsigned int    maxChars
  252.         , const unsigned int    radix
  253.     );
  254.     /** Converts binary data to a text string based a given radix
  255.       *
  256.       * @param toFormat The beginning of the input string to convert
  257.       * @param toFill The buffer that will hold the output on return. The
  258.       *        size of this buffer should at least be 'maxChars + 1'.
  259.       * @param maxChars The maximum number of output characters that can be
  260.       *         accepted. If the result will not fit, it is an error.
  261.       * @param radix The radix of the input data, based on which the conversion
  262.       * will be done
  263.       */
  264.     static void binToText
  265.     (
  266.         const   unsigned long   toFormat
  267.         ,       XMLCh* const    toFill
  268.         , const unsigned int    maxChars
  269.         , const unsigned int    radix
  270.     );
  271.     /** Converts binary data to a text string based a given radix
  272.       *
  273.       * @param toFormat The beginning of the input string to convert
  274.       * @param toFill The buffer that will hold the output on return. The
  275.       *        size of this buffer should at least be 'maxChars + 1'.
  276.       * @param maxChars The maximum number of output characters that can be
  277.       *         accepted. If the result will not fit, it is an error.
  278.       * @param radix The radix of the input data, based on which the conversion
  279.       * will be done
  280.       */
  281.     static void binToText
  282.     (
  283.         const   long            toFormat
  284.         ,       char* const     toFill
  285.         , const unsigned int    maxChars
  286.         , const unsigned int    radix
  287.     );
  288.     /** Converts binary data to a text string based a given radix
  289.       *
  290.       * @param toFormat The beginning of the input string to convert
  291.       * @param toFill The buffer that will hold the output on return. The
  292.       *        size of this buffer should at least be 'maxChars + 1'.
  293.       * @param maxChars The maximum number of output characters that can be
  294.       *         accepted. If the result will not fit, it is an error.
  295.       * @param radix The radix of the input data, based on which the conversion
  296.       * will be done
  297.       */
  298.     static void binToText
  299.     (
  300.         const   long            toFormat
  301.         ,       XMLCh* const    toFill
  302.         , const unsigned int    maxChars
  303.         , const unsigned int    radix
  304.     );
  305.     /** Converts binary data to a text string based a given radix
  306.       *
  307.       * @param toFormat The beginning of the input string to convert
  308.       * @param toFill The buffer that will hold the output on return. The
  309.       *        size of this buffer should at least be 'maxChars + 1'.
  310.       * @param maxChars The maximum number of output characters that can be
  311.       *         accepted. If the result will not fit, it is an error.
  312.       * @param radix The radix of the input data, based on which the conversion
  313.       * will be done
  314.       */
  315.     static void binToText
  316.     (
  317.         const   int             toFormat
  318.         ,       char* const     toFill
  319.         , const unsigned int    maxChars
  320.         , const unsigned int    radix
  321.     );
  322.     /** Converts binary data to a text string based a given radix
  323.       *
  324.       * @param toFormat The beginning of the input string to convert
  325.       * @param toFill The buffer that will hold the output on return. The
  326.       *        size of this buffer should at least be 'maxChars + 1'.
  327.       * @param maxChars The maximum number of output characters that can be
  328.       *         accepted. If the result will not fit, it is an error.
  329.       * @param radix The radix of the input data, based on which the conversion
  330.       * will be done
  331.       */
  332.     static void binToText
  333.     (
  334.         const   int             toFormat
  335.         ,       XMLCh* const    toFill
  336.         , const unsigned int    maxChars
  337.         , const unsigned int    radix
  338.     );
  339.     /**
  340.       * Converts a string of decimal chars to a binary value
  341.       *
  342.       * Note that leading and trailng whitespace is legal and will be ignored
  343.       * but the remainder must be all decimal digits.
  344.       *
  345.       * @param toConvert The string of digits to convert
  346.       * @param toFill    The unsigned int value to fill with the converted
  347.       *                  value.
  348.       */
  349.     static bool textToBin
  350.     (
  351.         const   XMLCh* const    toConvert
  352.         ,       unsigned int&   toFill
  353.     );
  354.     /**
  355.       * Converts a string of decimal chars to a binary value
  356.       *
  357.       * Note that leading and trailng whitespace is legal and will be ignored,
  358.       *
  359.       * Only one and either of (+,-) after the leading whitespace, before
  360.       * any other characters are allowed.
  361.       *
  362.       * but the remainder must be all decimal digits.
  363.       *
  364.       * @param toConvert The string of digits to convert
  365.       */
  366.     static int parseInt
  367.     (
  368.         const   XMLCh* const    toConvert
  369.     );
  370.     //@}
  371.     /** @name String concatenation functions */
  372.     //@{
  373.     /** Concatenates two strings.
  374.       *
  375.       * <code>catString</code> appends <code>src</code> to <code>target</code> and
  376.       * terminates the resulting string with a null character. The initial character
  377.       * of <code>src</code> overwrites the terminating character of <code>target
  378.       * </code>.
  379.       *
  380.       * No overflow checking is performed when strings are copied or appended.
  381.       * The behavior of <code>catString</code> is undefined if source and
  382.       * destination strings overlap.
  383.       *
  384.       * @param target Null-terminated destination string
  385.       * @param src Null-terminated source string
  386.       */
  387.     static void catString
  388.     (
  389.                 char* const     target
  390.         , const char* const     src
  391.     );
  392.     /** Concatenates two strings.
  393.       *
  394.       * <code>catString</code> appends <code>src</code> to <code>target</code> and
  395.       * terminates the resulting string with a null character. The initial character of
  396.       * <code>src</code> overwrites the terminating character of <code>target</code>.
  397.       * No overflow checking is performed when strings are copied or appended.
  398.       * The behavior of <code>catString</code> is undefined if source and destination
  399.       * strings overlap.
  400.       *
  401.       *    @param target Null-terminated destination string
  402.       * @param src Null-terminated source string
  403.       */
  404.     static void catString
  405.     (
  406.                 XMLCh* const    target
  407.         , const XMLCh* const    src
  408.     );
  409.     //@}
  410.     /** @name String comparison functions */
  411.     //@{
  412.     /** Lexicographically compares lowercase versions of <code>str1</code> and
  413.       * <code>str2</code> and returns a value indicating their relationship.
  414.       * @param str1 Null-terminated string to compare
  415.       * @param str2 Null-terminated string to compare
  416.       *
  417.       * @return The return value indicates the relation of <code>str1</code> to
  418.       * <code>str2</code> as follows
  419.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  420.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  421.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  422.       */
  423.     static int compareIString
  424.     (
  425.         const   char* const     str1
  426.         , const char* const     str2
  427.     );
  428.     /** Lexicographically compares lowercase versions of <code>str1</code> and
  429.       * <code>str2</code> and returns a value indicating their relationship.
  430.       * @param str1 Null-terminated string to compare
  431.       * @param str2 Null-terminated string to compare
  432.       * @return The return value indicates the relation of <code>str1</code> to
  433.       * <code>str2</code> as follows
  434.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  435.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  436.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  437.       */
  438.     static int compareIString
  439.     (
  440.         const   XMLCh* const    str1
  441.         , const XMLCh* const    str2
  442.     );
  443.     /** Lexicographically compares, at most, the first count characters in
  444.       * <code>str1</code> and <code>str2</code> and returns a value indicating the
  445.       * relationship between the substrings.
  446.       * @param str1 Null-terminated string to compare
  447.       * @param str2 Null-terminated string to compare
  448.       * @param count The number of characters to compare
  449.       *
  450.       * @return The return value indicates the relation of <code>str1</code> to
  451.       * <code>str2</code> as follows
  452.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  453.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  454.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  455.       */
  456.     static int compareNString
  457.     (
  458.         const   char* const     str1
  459.         , const char* const     str2
  460.         , const unsigned int    count
  461.     );
  462.     /** Lexicographically compares, at most, the first count characters in
  463.       * <code>str1</code> and <code>str2</code> and returns a value indicating
  464.       * the relationship between the substrings.
  465.       * @param str1 Null-terminated string to compare
  466.       * @param str2 Null-terminated string to compare
  467.       * @param count The number of characters to compare
  468.       *
  469.       * @return The return value indicates the relation of <code>str1</code> to
  470.       * <code>str2</code> as follows
  471.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  472.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  473.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  474.       */
  475.     static int compareNString
  476.     (
  477.         const   XMLCh* const    str1
  478.         , const XMLCh* const    str2
  479.         , const unsigned int    count
  480.     );
  481.     /** Lexicographically compares, at most, the first count characters in
  482.       * <code>str1</code> and <code>str2</code> without regard to case and
  483.       * returns a value indicating the relationship between the substrings.
  484.       *
  485.       * @param str1 Null-terminated string to compare
  486.       * @param str2 Null-terminated string to compare
  487.       * @param count The number of characters to compare
  488.       * @return The return value indicates the relation of <code>str1</code> to
  489.       * <code>str2</code> as follows
  490.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  491.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  492.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  493.       */
  494.     static int compareNIString
  495.     (
  496.         const   char* const     str1
  497.         , const char* const     str2
  498.         , const unsigned int    count
  499.     );
  500.     /** Lexicographically compares, at most, the first count characters in
  501.       * <code>str1</code> and <code>str2</code> without regard to case and
  502.       * returns a value indicating the relationship between the substrings.
  503.       *
  504.       * @param str1 Null-terminated string to compare
  505.       * @param str2 Null-terminated string to compare
  506.       * @param count The number of characters to compare
  507.       *
  508.       * @return The return value indicates the relation of <code>str1</code> to
  509.       * <code>str2</code> as follows
  510.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  511.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  512.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  513.       */
  514.     static int compareNIString
  515.     (
  516.         const   XMLCh* const    str1
  517.         , const XMLCh* const    str2
  518.         , const unsigned int    count
  519.     );
  520.     /** Lexicographically compares <code>str1</code> and <code>str2</code> and
  521.       * returns a value indicating their relationship.
  522.       *
  523.       * @param str1 Null-terminated string to compare
  524.       * @param str2 Null-terminated string to compare
  525.       *
  526.       * @return The return value indicates the relation of <code>str1</code> to
  527.       * <code>str2</code> as follows
  528.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  529.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  530.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  531.       */
  532.     static int compareString
  533.     (
  534.         const   char* const     str1
  535.         , const char* const     str2
  536.     );
  537.     /** Lexicographically compares <code>str1</code> and <code>str2</code> and
  538.       * returns a value indicating their relationship.
  539.       *
  540.       * @param str1 Null-terminated string to compare
  541.       * @param str2 Null-terminated string to compare
  542.       * @return The return value indicates the relation of <code>str1</code> to
  543.       * <code>str2</code> as follows
  544.       *  Less than 0 means <code>str1</code> is less than <code>str2</code>
  545.       *  Equal to 0 means <code>str1</code> is identical to <code>str2</code>
  546.       *  Greater than 0 means <code>str1</code> is more than <code>str2</code>
  547.       */
  548.     static int compareString
  549.     (
  550.         const   XMLCh* const    str1
  551.         , const XMLCh* const    str2
  552.     );
  553. /** Lexicographically compares <code>str1</code> and <code>str2</code>
  554.   * regions and returns true if they are equal, otherwise false.
  555.   *
  556.       * A substring of <code>str1</code> is compared to a substring of
  557.   * <code>str2</code>. The result is true if these substrings represent
  558.   * identical character sequences. The substring of <code>str1</code>
  559.       * to be compared begins at offset1 and has length charsCount. The
  560.   * substring of <code>str2</code> to be compared begins at offset2 and
  561.   * has length charsCount. The result is false if and only if at least
  562.       * one of the following is true:
  563.       *   offset1 is negative.
  564.       *   offset2 is negative.
  565.       *   offset1+charsCount is greater than the length of str1.
  566.       *   offset2+charsCount is greater than the length of str2.
  567.       *   There is some nonnegative integer k less than charsCount such that:
  568.       *   str1.charAt(offset1+k) != str2.charAt(offset2+k)
  569.       *
  570.       * @param str1 Null-terminated string to compare
  571.   * @param offset1 Starting offset of str1
  572.       * @param str2 Null-terminated string to compare
  573.   * @param offset2 Starting offset of str2
  574.   * @param charsCount The number of characters to compare
  575.       * @return true if the specified subregion of <code>str1</code> exactly
  576.   *  matches the specified subregion of <code>str2></code>; false
  577.   *  otherwise.
  578.       */
  579.     static bool regionMatches
  580.     (
  581.         const   XMLCh* const    str1
  582. , const int offset1
  583.         , const XMLCh* const    str2
  584. , const int offset2
  585. , const unsigned int charCount
  586.     );
  587. /** Lexicographically compares <code>str1</code> and <code>str2</code>
  588.   * regions without regard to case and returns true if they are equal,
  589.   * otherwise false.
  590.   *
  591.       * A substring of <code>str1</code> is compared to a substring of
  592.   * <code>str2</code>. The result is true if these substrings represent
  593.   * identical character sequences. The substring of <code>str1</code>
  594.       * to be compared begins at offset1 and has length charsCount. The
  595.   * substring of <code>str2</code> to be compared begins at offset2 and
  596.   * has length charsCount. The result is false if and only if at least
  597.       * one of the following is true:
  598.       *   offset1 is negative.
  599.       *   offset2 is negative.
  600.       *   offset1+charsCount is greater than the length of str1.
  601.       *   offset2+charsCount is greater than the length of str2.
  602.       *   There is some nonnegative integer k less than charsCount such that:
  603.       *   str1.charAt(offset1+k) != str2.charAt(offset2+k)
  604.       *
  605.       * @param str1 Null-terminated string to compare
  606.   * @param offset1 Starting offset of str1
  607.       * @param str2 Null-terminated string to compare
  608.   * @param offset2 Starting offset of str2
  609.   * @param charsCount The number of characters to compare
  610.       * @return true if the specified subregion of <code>str1</code> exactly
  611.   *  matches the specified subregion of <code>str2></code>; false
  612.   *  otherwise.
  613.       */
  614.     static bool regionIMatches
  615.     (
  616.         const   XMLCh* const    str1
  617. , const int offset1
  618.         , const XMLCh* const    str2
  619. , const int offset2
  620. , const unsigned int charCount
  621.     );
  622.     //@}
  623.     /** @name String copy functions */
  624.     //@{
  625.     /** Copies <code>src</code>, including the terminating null character, to the
  626.       * location specified by <code>target</code>.
  627.       *
  628.       * No overflow checking is performed when strings are copied or appended.
  629.       * The behavior of strcpy is undefined if the source and destination strings
  630.       * overlap.
  631.       *
  632.       * @param target Destination string
  633.       * @param src Null-terminated source string
  634.       */
  635.     static void copyString
  636.     (
  637.                 char* const     target
  638.         , const char* const     src
  639.     );
  640.     /** Copies <code>src</code>, including the terminating null character, to
  641.       *   the location specified by <code>target</code>.
  642.       *
  643.       * No overflow checking is performed when strings are copied or appended.
  644.       * The behavior of <code>copyString</code> is undefined if the source and
  645.       * destination strings overlap.
  646.       *
  647.       * @param target Destination string
  648.       * @param src Null-terminated source string
  649.       */
  650.     static void copyString
  651.     (
  652.                 XMLCh* const    target
  653.         , const XMLCh* const    src
  654.     );
  655.     /** Copies <code>src</code>, upto a fixed number of characters, to the
  656.       * location specified by <code>target</code>.
  657.       *
  658.       * No overflow checking is performed when strings are copied or appended.
  659.       * The behavior of <code>copyNString</code> is undefined if the source and
  660.       * destination strings overlap.
  661.       *
  662.       * @param target Destination string. The size of the buffer should
  663.       *        atleast be 'maxChars + 1'.
  664.       * @param src Null-terminated source string
  665.       * @param maxChars The maximum number of characters to copy
  666.       */
  667.     static bool copyNString
  668.     (
  669.                 XMLCh* const    target
  670.         , const XMLCh* const    src
  671.         , const unsigned int    maxChars
  672.     );
  673.     //@}
  674.     /** @name Hash functions */
  675.     //@{
  676.     /** Hashes a string given a modulus
  677.       *
  678.       * @param toHash The string to hash
  679.       * @param hashModulus The divisor to be used for hashing
  680.       * @return Returns the hash value
  681.       */
  682.     static unsigned int hash
  683.     (
  684.         const   char* const     tohash
  685.         , const unsigned int    hashModulus
  686.     );
  687.     /** Hashes a string given a modulus
  688.       *
  689.       * @param toHash The string to hash
  690.       * @param hashModulus The divisor to be used for hashing
  691.       * @return Returns the hash value
  692.       */
  693.     static unsigned int hash
  694.     (
  695.         const   XMLCh* const    toHash
  696.         , const unsigned int    hashModulus
  697.     );
  698.     /** Hashes a string given a modulus taking a maximum number of characters
  699.       * as the limit
  700.       *
  701.       * @param toHash The string to hash
  702.       * @param numChars The maximum number of characters to consider for hashing
  703.       * @param hashModulus The divisor to be used for hashing
  704.       *
  705.       * @return Returns the hash value
  706.       */
  707.     static unsigned int hashN
  708.     (
  709.         const   XMLCh* const    toHash
  710.         , const unsigned int    numChars
  711.         , const unsigned int    hashModulus
  712.     );
  713.     //@}
  714.     /** @name Search functions */
  715.     //@{
  716.     /**
  717.       * Provides the index of the first occurance of a character within a string
  718.       *
  719.       * @param toSearch The string to search
  720.       * @param ch The character to search within the string
  721.       * @return If found, returns the index of the character within the string,
  722.       * else returns -1.
  723.       */
  724.     static int indexOf(const char* const toSearch, const char ch);
  725.     /**
  726.       * Provides the index of the first occurance of a character within a string
  727.       *
  728.       * @param toSearch The string to search
  729.       * @param ch The character to search within the string
  730.       * @return If found, returns the index of the character within the string,
  731.       * else returns -1.
  732.       */
  733.     static int indexOf(const XMLCh* const toSearch, const XMLCh ch);
  734.     /**
  735.       * Provides the index of the first occurance of a character within a string
  736.       * starting from a given index
  737.       *
  738.       * @param toSearch The string to search
  739.       * @param chToFInd The character to search within the string
  740.       * @param fromIndex The index to start earch from
  741.       * @return If found, returns the index of the character within the string,
  742.       * else returns -1.
  743.       */
  744.     static int indexOf
  745.     (
  746.         const   char* const     toSearch
  747.         , const char            chToFind
  748.         , const unsigned int    fromIndex
  749.     );
  750.     /**
  751.       * Provides the index of the first occurance of a character within a string
  752.       * starting from a given index
  753.       *
  754.       * @param toSearch The string to search
  755.       * @param chToFInd The character to search within the string
  756.       * @param fromIndex The index to start search from
  757.       * @return If found, returns the index of the character within the string,
  758.       * else returns -1.
  759.       */
  760.     static int indexOf
  761.     (
  762.         const   XMLCh* const    toSearch
  763.         , const XMLCh           chToFind
  764.         , const unsigned int    fromIndex
  765.     );
  766.     /**
  767.       * Provides the index of the last occurance of a character within a string
  768.       *
  769.       * @param toSearch The string to search
  770.       * @param ch The character to search within the string
  771.       * @return If found, returns the index of the character within the string,
  772.       * else returns -1.
  773.       */
  774.     static int lastIndexOf(const char* const toSearch, const char ch);
  775.     /**
  776.       * Provides the index of the last occurance of a character within a string
  777.       *
  778.       * @param toSearch The string to search
  779.       * @param ch The character to search within the string
  780.       * @return If found, returns the index of the character within the string,
  781.       * else returns -1.
  782.       */
  783.     static int lastIndexOf(const XMLCh* const toSearch, const XMLCh ch);
  784.     /**
  785.       * Provides the index of the last occurance of a character within a string
  786.       * starting backward from a given index
  787.       *
  788.       * @param toSearch The string to search
  789.       * @param chToFInd The character to search within the string
  790.       * @param fromIndex The index to start backward search from
  791.       * @return If found, returns the index of the character within the string,
  792.       * else returns -1.
  793.       */
  794.     static int lastIndexOf
  795.     (
  796.         const   char* const     toSearch
  797.         , const char            chToFind
  798.         , const unsigned int    fromIndex
  799.     );
  800.     /**
  801.       * Provides the index of the last occurance of a character within a string
  802.       * starting backward from a given index
  803.       *
  804.       * @param toSearch The string to search
  805.       * @param chToFInd The character to search within the string
  806.       * @param fromIndex The index to start backward search from
  807.       * @return If found, returns the index of the character within the string,
  808.       * else returns -1.
  809.       */
  810.     static int lastIndexOf
  811.     (
  812.         const   XMLCh* const    toSearch
  813.         , const XMLCh           ch
  814.         , const unsigned int    fromIndex
  815.     );
  816.     //@}
  817.     /** @name Fixed size string movement */
  818.     //@{
  819.     /** Moves X number of chars
  820.       * @param targetStr The string to copy the chars to
  821.       * @param srcStr The string to copy the chars from
  822.       * @param count The number of chars to move
  823.       */
  824.     static void moveChars
  825.     (
  826.                 XMLCh* const    targetStr
  827.         , const XMLCh* const    srcStr
  828.         , const unsigned int    count
  829.     );
  830.     //@}
  831.     /** @name Substring function */
  832.     //@{
  833.     /** Create a substring of a givend string. The substring begins at the
  834.       * specified beginIndex and extends to the character at index
  835.       * endIndex - 1.
  836.       * @param targetStr The string to copy the chars to
  837.       * @param srcStr The string to copy the chars from
  838.       * @param startIndex beginning index, inclusive.
  839.       * @param endIndex the ending index, exclusive.
  840.       */
  841.     static void subString
  842.     (
  843.                 char* const    targetStr
  844.         , const char* const    srcStr
  845.         , const int            startIndex
  846.         , const int            endIndex
  847.     );
  848.     /** Create a substring of a givend string. The substring begins at the
  849.       * specified beginIndex and extends to the character at index
  850.       * endIndex - 1.
  851.       * @param targetStr The string to copy the chars to
  852.       * @param srcStr The string to copy the chars from
  853.       * @param startIndex beginning index, inclusive.
  854.       * @param endIndex the ending index, exclusive.
  855.       */
  856.     static void subString
  857.     (
  858.                 XMLCh* const    targetStr
  859.         , const XMLCh* const    srcStr
  860.         , const int             startIndex
  861.         , const int             endIndex
  862.     );
  863.     //@}
  864.     /** @name Replication function */
  865.     //@{
  866.     /** Replicates a string
  867.       * @param toRep The string to replicate
  868.       * @return Returns a pointer to the replicated string
  869.       */
  870.     static char* replicate(const char* const toRep);
  871.     /** Replicates a string
  872.       * @param toRep The string to replicate
  873.       * @return Returns a pointer to the replicated string
  874.       */
  875.     static XMLCh* replicate(const XMLCh* const toRep);
  876.     //@}
  877.     /** @name String query function */
  878.     //@{
  879.     /** Tells if the sub-string appears within a string at the beginning
  880.       * @param toTest The string to test
  881.       * @param prefix The sub-string that needs to be checked
  882.       * @return Returns true if the sub-string was found at the beginning of
  883.       * <code>toTest</code>, else false
  884.       */
  885.     static bool startsWith
  886.     (
  887.         const   char* const     toTest
  888.         , const char* const     prefix
  889.     );
  890.     /** Tells if the sub-string appears within a string at the beginning
  891.       * @param toTest The string to test
  892.       * @param prefix The sub-string that needs to be checked
  893.       * @return Returns true if the sub-string was found at the beginning of
  894.       * <code>toTest</code>, else false
  895.       */
  896.     static bool startsWith
  897.     (
  898.         const   XMLCh* const    toTest
  899.         , const XMLCh* const    prefix
  900.     );
  901.     /** Tells if the sub-string appears within a string at the beginning
  902.       * without regard to case
  903.       *
  904.       * @param toTest The string to test
  905.       * @param prefix The sub-string that needs to be checked
  906.       * @return Returns true if the sub-string was found at the beginning of
  907.       * <code>toTest</code>, else false
  908.       */
  909.     static bool startsWithI
  910.     (
  911.         const   char* const     toTest
  912.         , const char* const     prefix
  913.     );
  914.     /** Tells if the sub-string appears within a string at the beginning
  915.       * without regard to case
  916.       *
  917.       * @param toTest The string to test
  918.       * @param prefix The sub-string that needs to be checked
  919.       *
  920.       * @return Returns true if the sub-string was found at the beginning
  921.       * of <code>toTest</code>, else false
  922.       */
  923.     static bool startsWithI
  924.     (
  925.         const   XMLCh* const    toTest
  926.         , const XMLCh* const    prefix
  927.     );
  928.     /** Tells if the sub-string appears within a string at the end.
  929.       * @param toTest The string to test
  930.       * @param suffix The sub-string that needs to be checked
  931.       * @return Returns true if the sub-string was found at the end of
  932.       * <code>toTest</code>, else false
  933.       */
  934.     static bool endsWith
  935.     (
  936.         const   XMLCh* const    toTest
  937.         , const XMLCh* const    prefix
  938.     );
  939.     /** Tells if a string has any occurance of another string within itself
  940.       * @param toSearch The string to be searched
  941.       * @param searchList The sub-string to be searched within the string
  942.       * @return Returns the pointer to the location where the sub-string was
  943.       * found, else returns 0
  944.       */
  945.     static const XMLCh* findAny
  946.     (
  947.         const   XMLCh* const    toSearch
  948.         , const XMLCh* const    searchList
  949.     );
  950.     /** Tells if a string has any occurance of another string within itself
  951.       * @param toSearch The string to be searched
  952.       * @param searchList The sub-string to be searched within the string
  953.       * @return Returns the pointer to the location where the sub-string was
  954.       * found, else returns 0
  955.       */
  956.     static XMLCh* findAny
  957.     (
  958.                 XMLCh* const    toSearch
  959.         , const XMLCh* const    searchList
  960.     );
  961.     /** Tells if a string has pattern within itself
  962.       * @param toSearch The string to be searched
  963.       * @param pattern The pattern to be searched within the string
  964.       * @return Returns index to the location where the pattern was
  965.       * found, else returns -1
  966.       */
  967.     static int patternMatch
  968.     (
  969.                 XMLCh* const    toSearch
  970.         , const XMLCh* const    pattern
  971.     );
  972.     /** Get the length of the string
  973.       * @param src The string whose length is to be determined
  974.       * @return Returns the length of the string
  975.       */
  976.     static unsigned int stringLen(const char* const src);
  977.     /** Get the length of the string
  978.       * @param src The string whose length is to be determined
  979.       * @return Returns the length of the string
  980.       */
  981.     static unsigned int stringLen(const XMLCh* const src);
  982.     /**
  983.       * Checks whether an name is a valid NCName.
  984.       * @param name The string to check its NCName validity
  985.       * @return Returns true if name is NCName valid, otherwise false
  986.       */
  987.     static bool isValidNCName(const XMLCh* const name);
  988.     /**
  989.       * Checks whether an name is a valid Name.
  990.       * @param name The string to check its Name validity
  991.       * @return Returns true if name is Name valid, otherwise false
  992.       */
  993.     static bool isValidName(const XMLCh* const name);
  994.     /**
  995.       * Checks whether an name is a valid EncName.
  996.       * @param name The string to check its EncName validity
  997.       * @return Returns true if name is EncName valid, otherwise false
  998.       */
  999.     static bool isValidEncName(const XMLCh* const name);  
  1000.     /**
  1001.       * Checks whether an name is a valid QName.
  1002.       * @param name The string to check its QName validity
  1003.       * @return Returns true if name is QName valid, otherwise false
  1004.       */
  1005.     static bool isValidQName(const XMLCh* const name);  
  1006.     /**
  1007.       * Checks whether a character is within [a-zA-Z].
  1008.       * @param theChar: the character to check 
  1009.       * @return Returns true if within the range, otherwise false
  1010.       */
  1011.     static bool isAlpha(XMLCh const theChar);
  1012.     /**
  1013.       * Checks whether a character is within [0-9].
  1014.       * @param theChar: the character to check 
  1015.       * @return Returns true if within the range, otherwise false
  1016.       */
  1017.     static bool isDigit(XMLCh const theChar);
  1018.     /**
  1019.       * Checks whether a character is within [0-9a-zA-Z].
  1020.       * @param theChar: the character to check 
  1021.       * @return Returns true if within the range, otherwise false
  1022.       */
  1023.     static bool isAlphaNum(XMLCh const theChar);
  1024.     /**
  1025.       * Checks whether a character is within [0-9a-fA-F].
  1026.       * @param theChar: the character to check 
  1027.       * @return Returns true if within the range, otherwise false
  1028.       */
  1029.     static bool isHex(XMLCh const theChar);
  1030.     /**
  1031.       * Checks whether a string contains only whitespace.
  1032.       * @param toCheck: the string to check 
  1033.       * @return Returns true if it is, otherwise false
  1034.       */
  1035.     static bool isAllWhiteSpace(const XMLCh* const toCheck);
  1036.     //@}
  1037.     /** @name Conversion functions */
  1038.     //@{
  1039.     /** Cut leading chars from a string
  1040.       *
  1041.       * @param toCut The string to cut chars from
  1042.       * @param count The count of leading chars to cut
  1043.       */
  1044.     static void cut
  1045.     (
  1046.                 XMLCh* const    toCutFrom
  1047.         , const unsigned int    count
  1048.     );
  1049.     /** Transcodes a string to native code-page
  1050.       *
  1051.       * NOTE: The returned buffer is dynamically allocated and is the
  1052.       * responsibility of the caller to delete it when not longer needed.
  1053.       *
  1054.       * @param toTranscode The string to be transcoded
  1055.       * @return Returns the transcoded string
  1056.       */
  1057.     static char* transcode
  1058.     (
  1059.         const   XMLCh* const    toTranscode
  1060.     );
  1061.     /** Transcodes a string to native code-page
  1062.       *
  1063.       * Be aware that when transcoding to an external encoding, that each
  1064.       * Unicode char can create multiple output bytes. So you cannot assume
  1065.       * a one to one correspondence of input chars to output bytes.
  1066.       *
  1067.       * @param toTranscode The string tobe transcoded
  1068.       * @param toFill The buffer that is filled with the transcoded value.
  1069.       *        The size of this buffer should atleast be 'maxChars + 1'.
  1070.       * @param maxChars The maximum number of bytes that the output
  1071.       *         buffer can hold (not including the null, which is why
  1072.       *         toFill should be at least maxChars+1.) If the resulting
  1073.       *         output cannot fit into this many bytes, it is an error and
  1074.       *         false is returned.
  1075.       * @return Returns true if successful, false if there was an error
  1076.       */
  1077.     static bool transcode
  1078.     (
  1079.         const   XMLCh* const    toTranscode
  1080.         ,       char* const     toFill
  1081.         , const unsigned int    maxChars
  1082.     );
  1083.     /** Transcodes a string to native code-page
  1084.       *
  1085.       * NOTE: The returned buffer is dynamically allocated and is the
  1086.       * responsibility of the caller to delete it when not longer needed.
  1087.       *
  1088.       * @param toTranscode The string to be transcoded
  1089.       * @return Returns the transcoded string
  1090.       */
  1091.     static XMLCh* transcode
  1092.     (
  1093.         const   char* const     toTranscode
  1094.     );
  1095.     /** Transcodes a string to native code-page
  1096.       * @param toTranscode The string tobe transcoded
  1097.       * @param toFill The buffer that is filled with the transcoded value.
  1098.       *        The size of this buffer should atleast be 'maxChars + 1'.
  1099.       * @param maxChars The maximum number of characters that the output
  1100.       *         buffer can hold (not including the null, which is why
  1101.       *         toFill should be at least maxChars+1.) If the resulting
  1102.       *         output cannot fit into this many characters, it is an error
  1103.       *         and false is returned.
  1104.       * @return Returns true if successful, false if there was an error
  1105.       */
  1106.     static bool transcode
  1107.     (
  1108.         const   char* const     toTranscode
  1109.         ,       XMLCh* const    toFill
  1110.         , const unsigned int    maxChars
  1111.     );
  1112.     /** Trims off extra space characters from the start and end of the string,
  1113.       * moving the non-space string content back to the start.
  1114.       * @param toTrim The string to be trimmed. On return this contains the
  1115.       * trimmed string
  1116.       */
  1117.     static void trim(char* const toTrim);
  1118.     /** Trims off extra space characters from the start and end of the string,
  1119.       * moving the non-space string content back to the start.
  1120.       * @param toTrim The string to be trimmed. On return this contains
  1121.       * the trimmed string
  1122.       */
  1123.     static void trim(XMLCh* const toTrim);
  1124.     /** Break a string into tokens with space as delimiter, and
  1125.       * stored in a string vector.  The caller owns the string vector
  1126.       * that is returned, and is responsible for deleting it.
  1127.       * @param tokenizeStr String to be tokenized
  1128.       * @return a vector of all the tokenized string
  1129.       */
  1130.     static RefVectorOf<XMLCh>* tokenizeString(const XMLCh* const tokenizeSrc);
  1131.     /** Find is the string appears in the enum list
  1132.       * @param toFind the string to be found
  1133.       * @param enumList the list
  1134.       * return true if found
  1135.       */
  1136.     static bool isInList(const XMLCh* const toFind, const XMLCh* const enumList);
  1137.     //@}
  1138.     /** @name Formatting functions */
  1139.     //@{
  1140.     /** Creates a UName from a URI and base name. It is in the form
  1141.       * {url}name, and is commonly used internally to represent fully
  1142.       * qualified names when namespaces are enabled.
  1143.       *
  1144.       * @param pszURI The URI part of the name
  1145.       * @param pszName The base part of the name
  1146.       * @return Returns the complete formatted UName
  1147.       */
  1148.     static XMLCh* makeUName
  1149.     (
  1150.         const   XMLCh* const    pszURI
  1151.         , const XMLCh* const    pszName
  1152.     );
  1153.     /**
  1154.       * Internal function to perform token replacement for strings.
  1155.       *
  1156.       * @param errText The text (NULL terminated) where the replacement
  1157.       *        is to be done. The size of this buffer should be
  1158.       *        'maxChars + 1' to account for the final NULL.
  1159.       * @param maxChars The size of the output buffer, i.e. the maximum
  1160.       *         number of characters that it will hold. If the result is
  1161.       *         larger, it will be truncated.
  1162.       * @param text1 Replacement text-one
  1163.       * @param text2 Replacement text-two
  1164.       * @param text3 Replacement text-three
  1165.       * @param text4 Replacement text-four
  1166.       * @return Returns the count of characters that are outputted
  1167.       */
  1168.     static unsigned int replaceTokens
  1169.     (
  1170.                 XMLCh* const    errText
  1171.         , const unsigned int    maxChars
  1172.         , const XMLCh* const    text1
  1173.         , const XMLCh* const    text2
  1174.         , const XMLCh* const    text3
  1175.         , const XMLCh* const    text4
  1176.     );
  1177.     /** Converts a string to uppercase
  1178.       * @param toUpperCase The string which needs to be converted to uppercase.
  1179.       *        On return, this buffer also holds the converted uppercase string
  1180.       */
  1181.     static void upperCase(XMLCh* const toUpperCase);
  1182. /** Converts a string to lowercase
  1183.       * @param toLowerCase The string which needs to be converted to lowercase.
  1184.       *        On return, this buffer also holds the converted lowercase string
  1185.       */
  1186.     static void lowerCase(XMLCh* const toLowerCase);
  1187. /** Check if string is WhiteSpace:replace
  1188.       * @param toCheck The string which needs to be checked.
  1189.       */
  1190.     static bool isWSReplaced(const XMLCh* const toCheck);
  1191. /** Check if string is WhiteSpace:collapse
  1192.       * @param toCheck The string which needs to be checked.
  1193.       */
  1194.     static bool isWSCollapsed(const XMLCh* const toCheck);
  1195. /** Replace whitespace
  1196.       * @param toCheck The string which needs to be whitespace replaced.
  1197.       *        On return , this buffer also holds the converted string
  1198.       */
  1199.     static void replaceWS(XMLCh* const toConvert);
  1200. /** Collapse whitespace
  1201.       * @param toConvert The string which needs to be whitespace collapsed.
  1202.       *        On return , this buffer also holds the converted string
  1203.       */       
  1204.     static void collapseWS(XMLCh* const toConvert);
  1205.     //@}
  1206. private :
  1207.     /** @name Constructors and Destructor */
  1208.     //@{
  1209.     /** Unimplemented default constructor */
  1210.     XMLString();
  1211.     /** Unimplemented destructor */
  1212.     ~XMLString();
  1213.     //@}
  1214.     /** @name Initialization */
  1215.     //@{
  1216.     /** Init/Term methods called from XMLPlatformUtils class */
  1217.     static void initString(XMLLCPTranscoder* const defToUse);
  1218.     static void termString();
  1219.     //@}
  1220. /**
  1221.   * Called by regionMatches/regionIMatches to validate that we
  1222.   * have a valid input
  1223.   */
  1224. static bool validateRegion(const XMLCh* const str1, const int offset1,
  1225. const XMLCh* const str2, const int offset2,
  1226. const unsigned int charsCount);
  1227.     friend class XMLPlatformUtils;
  1228. };
  1229. // ---------------------------------------------------------------------------
  1230. //  Inline some methods that are either just passthroughs to other string
  1231. //  methods, or which are key for performance.
  1232. // ---------------------------------------------------------------------------
  1233. inline void XMLString::moveChars(       XMLCh* const    targetStr
  1234.                                 , const XMLCh* const    srcStr
  1235.                                 , const unsigned int    count)
  1236. {
  1237.     XMLCh* outPtr = targetStr;
  1238.     const XMLCh* inPtr = srcStr;
  1239.     for (unsigned int index = 0; index < count; index++)
  1240.         *outPtr++ = *inPtr++;
  1241. }
  1242. inline unsigned int XMLString::stringLen(const XMLCh* const src)
  1243. {
  1244.     if (src == 0 || *src == 0)
  1245.     {
  1246.         return 0;
  1247.    }
  1248.     else
  1249.    {
  1250.         const XMLCh* pszTmp = src + 1;
  1251.         while (*pszTmp)
  1252.             ++pszTmp;
  1253.         return (unsigned int)(pszTmp - src);
  1254.     }
  1255. }
  1256. inline bool XMLString::startsWith(  const   XMLCh* const    toTest
  1257.                                     , const XMLCh* const    prefix)
  1258. {
  1259.     return (compareNString(toTest, prefix, stringLen(prefix)) == 0);
  1260. }
  1261. inline bool XMLString::startsWithI( const   XMLCh* const    toTest
  1262.                                     , const XMLCh* const    prefix)
  1263. {
  1264.     return (compareNIString(toTest, prefix, stringLen(prefix)) == 0);
  1265. }
  1266. inline bool XMLString::endsWith(const XMLCh* const toTest,
  1267.                                 const XMLCh* const suffix)
  1268. {
  1269.     unsigned int suffixLen = XMLString::stringLen(suffix);
  1270.     return regionMatches(toTest, XMLString::stringLen(toTest) - suffixLen,
  1271.                          suffix, 0, suffixLen);
  1272. }
  1273. inline XMLCh* XMLString::replicate(const XMLCh* const toRep)
  1274. {
  1275.     // If a null string, return a null string!
  1276.     XMLCh* ret = 0;
  1277.     if (toRep)
  1278.     {
  1279.         const unsigned int len = stringLen(toRep);
  1280.         ret = new XMLCh[len + 1];
  1281.         XMLCh* outPtr = ret;
  1282.         const XMLCh* inPtr = toRep;
  1283.         for (unsigned int index = 0; index <= len; index++)
  1284.             *outPtr++ = *inPtr++;
  1285.     }
  1286.     return ret;
  1287. }
  1288. inline bool XMLString::validateRegion(const XMLCh* const str1,
  1289.   const int offset1,
  1290.   const XMLCh* const str2,
  1291.   const int offset2,
  1292.   const unsigned int charsCount)
  1293. {
  1294. if (offset1 < 0 || offset2 < 0 ||
  1295. (offset1 + charsCount) > XMLString::stringLen(str1) ||
  1296. (offset2 + charsCount) > XMLString::stringLen(str2) )
  1297. return false;
  1298. return true;
  1299. }
  1300. #endif