You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2001/08/10 18:23:06 UTC

cvs commit: xml-xerces/c/src/util XMLString.hpp XMLString.cpp

peiyongz    01/08/10 09:23:06

  Modified:    c/src/util XMLString.hpp XMLString.cpp
  Log:
  isHex(), isAlphaNum(), isAllWhiteSpace() and patternMatch() Added
  
  Revision  Changes    Path
  1.26      +36 -0     xml-xerces/c/src/util/XMLString.hpp
  
  Index: XMLString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLString.hpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XMLString.hpp	2001/07/06 20:27:57	1.25
  +++ XMLString.hpp	2001/08/10 16:23:06	1.26
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XMLString.hpp,v $
  + * Revision 1.26  2001/08/10 16:23:06  peiyongz
  + * isHex(), isAlphaNum(), isAllWhiteSpace() and patternMatch() Added
  + *
    * Revision 1.25  2001/07/06 20:27:57  peiyongz
    * isValidaQName()
    *
  @@ -1017,6 +1020,18 @@
           , const XMLCh* const    searchList
       );
   
  +    /** Tells if a string has pattern within itself
  +      * @param toSearch The string to be searched
  +      * @param pattern The pattern to be searched within the string
  +      * @return Returns index to the location where the pattern was
  +      * found, else returns -1
  +      */
  +    static int patternMatch
  +    (
  +                XMLCh* const    toSearch
  +        , const XMLCh* const    pattern
  +    );
  +
       /** Get the length of the string
         * @param src The string whose length is to be determined
         * @return Returns the length of the string
  @@ -1071,6 +1086,27 @@
         * @return Returns true if within the range, otherwise false
         */
       static bool isDigit(XMLCh const theChar);
  +
  +    /**
  +      * Checks whether a character is within [0-9a-zA-Z].
  +      * @param theChar: the character to check 
  +      * @return Returns true if within the range, otherwise false
  +      */
  +    static bool isAlphaNum(XMLCh const theChar);
  +
  +    /**
  +      * Checks whether a character is within [0-9a-fA-F].
  +      * @param theChar: the character to check 
  +      * @return Returns true if within the range, otherwise false
  +      */
  +    static bool isHex(XMLCh const theChar);
  +
  +    /**
  +      * Checks whether a string contains only whitespace.
  +      * @param toCheck: the string to check 
  +      * @return Returns true if it is, otherwise false
  +      */
  +    static bool isAllWhiteSpace(const XMLCh* const toCheck);
   
       //@}
   
  
  
  
  1.26      +58 -1     xml-xerces/c/src/util/XMLString.cpp
  
  Index: XMLString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/util/XMLString.cpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- XMLString.cpp	2001/07/06 20:27:56	1.25
  +++ XMLString.cpp	2001/08/10 16:23:06	1.26
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLString.cpp,v 1.25 2001/07/06 20:27:56 peiyongz Exp $
  + * $Id: XMLString.cpp,v 1.26 2001/08/10 16:23:06 peiyongz Exp $
    */
   
   
  @@ -755,6 +755,37 @@
   
       return false;
   }
  +
  +bool XMLString::isAlphaNum(XMLCh const theChar)
  +{
  +    return (isAlpha(theChar) || isDigit(theChar));
  +}
  +
  +bool XMLString::isHex(XMLCh const theChar)
  +{
  +	return (isDigit(theChar) ||
  +			(theChar >= chLatin_a && theChar <= chLatin_f) ||
  +			(theChar >= chLatin_A && theChar <= chLatin_F));
  +}
  +
  +bool XMLString::isAllWhiteSpace(const XMLCh* const toCheck)
  +{
  +    if ( !toCheck )
  +        return true;
  +
  +    const XMLCh* startPtr = toCheck;
  +
  +    while (*startPtr)
  +    {
  +        if (!XMLPlatformUtils::fgTransService->isSpace(*startPtr))
  +            return false;
  +
  +        startPtr++;
  +    }
  +
  +    return true;
  +}
  +
   // ---------------------------------------------------------------------------
   //  Wide char versions of most of the string methods
   // ---------------------------------------------------------------------------
  @@ -1130,6 +1161,32 @@
       return 0;
   }
   
  +int XMLString::patternMatch(        XMLCh* const    toSearch
  +                            , const XMLCh* const    pattern)
  +{
  +    if (!toSearch || !pattern )
  +        return -1;
  +
  +    XMLCh* srcPtr = toSearch;
  +    const int patnLen = XMLString::stringLen(pattern);
  +    int  patnIndex = 0;
  +
  +    while (*srcPtr)
  +    {
  +        if (*srcPtr++ != pattern[patnIndex++])
  +        {
  +            patnIndex = 0;
  +        }
  +        else
  +        {
  +            if (patnIndex == patnLen)
  +                // full pattern match found
  +                return (srcPtr - patnLen - toSearch);
  +        }
  +    }
  +
  +    return -1;
  +}
   
   unsigned int XMLString::hashN(  const   XMLCh* const    tohash
                                   , const unsigned int    n
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org