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 2003/01/25 00:16:33 UTC

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

peiyongz    2003/01/24 15:16:33

  Modified:    c/src/xercesc/util XMLString.hpp XMLString.cpp
  Log:
  removeWS() added;
  
  Revision  Changes    Path
  1.12      +9 -0      xml-xerces/c/src/xercesc/util/XMLString.hpp
  
  Index: XMLString.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLString.hpp	20 Dec 2002 22:10:21 -0000	1.11
  +++ XMLString.hpp	24 Jan 2003 23:16:33 -0000	1.12
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.12  2003/01/24 23:16:33  peiyongz
  + * removeWS() added;
  + *
    * Revision 1.11  2002/12/20 22:10:21  tng
    * XML 1.1
    *
  @@ -1357,6 +1360,12 @@
         *        On return , this buffer also holds the converted string
         */
       static void collapseWS(XMLCh* const toConvert);
  +
  +    /** Remove whitespace
  +      * @param toConvert The string which needs to be whitespace removed.
  +      *        On return , this buffer also holds the converted string
  +      */
  +    static void removeWS(XMLCh* const toConvert);
   
       /**
        * Fixes a platform dependent absolute path filename to standard URI form.
  
  
  
  1.19      +33 -1     xml-xerces/c/src/xercesc/util/XMLString.cpp
  
  Index: XMLString.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XMLString.cpp	6 Jan 2003 19:50:05 -0000	1.18
  +++ XMLString.cpp	24 Jan 2003 23:16:33 -0000	1.19
  @@ -1651,6 +1651,38 @@
       return;
   }
   
  +//
  +// remove whitespace
  +//
  +void XMLString::removeWS(XMLCh* const toConvert)
  +{
  +    // If no string, then its a failure
  +    if (( !toConvert ) || ( !*toConvert ))
  +        return;
  +
  +    XMLCh* retBuf = new XMLCh[ XMLString::stringLen(toConvert) + 1];
  +    XMLCh* retPtr = &(retBuf[0]);
  +    XMLCh* startPtr = toConvert;
  +
  +    while (*startPtr)
  +    {
  +        if ( ( *startPtr != chCR)    &&
  +             ( *startPtr != chLF)    &&
  +             ( *startPtr != chHTab)  &&
  +             ( *startPtr != chSpace)  )
  +        {           
  +            *retPtr++ = *startPtr;
  +        }
  +
  +        startPtr++;
  +
  +    }
  +
  +    *retPtr = chNull;
  +    XMLString::moveChars(toConvert, retBuf, stringLen(retBuf)+1); //copy the last chNull as well
  +    delete[] retBuf;
  +    return;
  +}
   
   /**
    * Fixes a platform dependent absolute path filename to standard URI form.
  
  
  

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