peiyongz 2004/08/11 09:48:24 Modified: c/src/xercesc/util XMLBigInteger.hpp XMLBigInteger.cpp Log: String version compareValue Revision Changes Path 1.13 +7 -1 xml-xerces/c/src/xercesc/util/XMLBigInteger.hpp Index: XMLBigInteger.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigInteger.hpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- XMLBigInteger.hpp 29 Jan 2004 11:48:46 -0000 1.12 +++ XMLBigInteger.hpp 11 Aug 2004 16:48:24 -0000 1.13 @@ -108,6 +108,12 @@ , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + static int compareValues(const XMLCh* const lString + , const int& lSign + , const XMLCh* const rString + , const int& rSign + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + void multiply(const unsigned int byteToShift); void divide(const unsigned int byteToShift); 1.11 +55 -0 xml-xerces/c/src/xercesc/util/XMLBigInteger.cpp Index: XMLBigInteger.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLBigInteger.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLBigInteger.cpp 23 Dec 2003 21:48:14 -0000 1.10 +++ XMLBigInteger.cpp 11 Aug 2004 16:48:24 -0000 1.11 @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2004/08/11 16:48:24 peiyongz + * String version compareValue + * * Revision 1.10 2003/12/23 21:48:14 peiyongz * Absorb exception thrown in getCanonicalRepresentation and return 0 * @@ -353,6 +356,58 @@ // we need to convert it to 1, 0, and -1 // int retVal = XMLString::compareString(lValue->fMagnitude, rValue->fMagnitude); + + if ( retVal > 0 ) + { + return ( lSign > 0 ? 1 : -1 ); + } + else if ( retVal < 0 ) + { + return ( lSign > 0 ? -1 : 1 ); + } + else + return 0; + +} + +int XMLBigInteger::compareValues(const XMLCh* const lString + , const int& lSign + , const XMLCh* const rString + , const int& rSign + , MemoryManager* const manager) +{ + if ((!lString) || (!rString) ) + ThrowXMLwithMemMgr(NumberFormatException, XMLExcepts::XMLNUM_null_ptr, manager); + + // + // different sign + // + if (lSign != rSign) + return(lSign > rSign ? 1 : -1); + + // + // same sign + // + if (lSign == 0) // optimization + return 0; + + int lStrLen = XMLString::stringLen(lString); + int rStrLen = XMLString::stringLen(rString); + + // + // different length + // + if (lStrLen > rStrLen) + return ( lSign > 0 ? 1 : -1 ); + else if (lStrLen < rStrLen) + return ( lSign > 0 ? -1 : 1 ); + + // + // same length + // XMLString::compareString() return > 0, 0 and <0 + // we need to convert it to 1, 0, and -1 + // + int retVal = XMLString::compareString(lString, rString); if ( retVal > 0 ) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]