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 2004/08/11 18:18:05 UTC

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

peiyongz    2004/08/11 09:18:04

  Modified:    c/src/xercesc/util XMLBigDecimal.hpp XMLBigDecimal.cpp
  Log:
  Light weight parsing method
  
  Revision  Changes    Path
  1.18      +15 -1     xml-xerces/c/src/xercesc/util/XMLBigDecimal.hpp
  
  Index: XMLBigDecimal.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigDecimal.hpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLBigDecimal.hpp	13 Jan 2004 19:50:56 -0000	1.17
  +++ XMLBigDecimal.hpp	11 Aug 2004 16:17:58 -0000	1.18
  @@ -111,6 +111,12 @@
                   ,        MemoryManager* const manager
                   );
   
  +    static void  parseDecimal
  +                ( 
  +                   const XMLCh*         const toParse
  +                ,        MemoryManager* const manager
  +                );
  +
       /**
        *
        *  Deprecated: please use getRawData
  @@ -130,6 +136,8 @@
   
       unsigned int          getTotalDigit() const;
   
  +    inline XMLCh*         getIntVal() const;
  +
       /**
        * Compares this object to the specified object.
        *
  @@ -196,6 +204,7 @@
       XMLCh*         fRawData;
       XMLCh*         fIntVal;
       MemoryManager* fMemoryManager;
  +
   };
   
   inline int XMLBigDecimal::getSign() const
  @@ -231,6 +240,11 @@
   inline MemoryManager* XMLBigDecimal::getMemoryManager() const
   {
       return fMemoryManager;
  +}
  +
  +inline XMLCh*  XMLBigDecimal::getIntVal() const
  +{
  +    return fIntVal;
   }
   
   //
  
  
  
  1.23      +71 -0     xml-xerces/c/src/xercesc/util/XMLBigDecimal.cpp
  
  Index: XMLBigDecimal.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigDecimal.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- XMLBigDecimal.cpp	19 Mar 2004 01:15:55 -0000	1.22
  +++ XMLBigDecimal.cpp	11 Aug 2004 16:17:58 -0000	1.23
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.23  2004/08/11 16:17:58  peiyongz
  + * Light weight parsing method
  + *
    * Revision 1.22  2004/03/19 01:15:55  peiyongz
    * store/load fRawData
    *
  @@ -417,6 +420,74 @@
       }
   
       *retPtr = chNull;   //terminated
  +    return;
  +}
  +
  +void  XMLBigDecimal::parseDecimal(const XMLCh*         const toParse
  +                               ,        MemoryManager* const manager)
  +{
  +
  +    // Strip leading white space, if any. 
  +    const XMLCh* startPtr = toParse;
  +    while (XMLChar1_0::isWhitespace(*startPtr))
  +        startPtr++;
  +
  +    // If we hit the end, then return failure
  +    if (!*startPtr)
  +        ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_WSString, manager);
  +
  +    // Strip tailing white space, if any.
  +    const XMLCh* endPtr = toParse + XMLString::stringLen(toParse);
  +    while (XMLChar1_0::isWhitespace(*(endPtr - 1)))
  +        endPtr--;
  +
  +    // '+' or '-' is allowed only at the first position
  +    // and is NOT included in the return parsed string
  +
  +    if (*startPtr == chDash)
  +    {
  +        startPtr++;
  +    }
  +    else if (*startPtr == chPlus)
  +    {
  +        startPtr++;
  +    }
  +
  +    // Strip leading zeros
  +    while (*startPtr == chDigit_0)
  +        startPtr++;
  +
  +    // containning zero, only zero, nothing but zero
  +    // it is a zero, indeed
  +    if (startPtr >= endPtr)
  +    {
  +        return;
  +    }
  +
  +    // Scan data
  +    bool   dotSignFound = false;
  +    while (startPtr < endPtr)
  +    {
  +        if (*startPtr == chPeriod)
  +        {
  +            if (!dotSignFound)
  +            {
  +                dotSignFound = true;
  +                startPtr++;
  +                continue;
  +            }
  +            else  // '.' is allowed only once
  +                ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_2ManyDecPoint, manager);
  +        }
  +
  +        // If not valid decimal digit, then an error
  +        if ((*startPtr < chDigit_0) || (*startPtr > chDigit_9))
  +            ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars, manager);
  +
  +        startPtr++;
  +
  +    }
  +
       return;
   }
   
  
  
  

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