00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(XERCESC_INCLUDE_GUARD_XML_BIGINTEGER_HPP)
00023 #define XERCESC_INCLUDE_GUARD_XML_BIGINTEGER_HPP
00024
00025 #include <xercesc/util/XMemory.hpp>
00026 #include <xercesc/util/XMLString.hpp>
00027
00028 XERCES_CPP_NAMESPACE_BEGIN
00029
00030 class XMLUTIL_EXPORT XMLBigInteger : public XMemory
00031 {
00032 public:
00033
00047 XMLBigInteger
00048 (
00049 const XMLCh* const strValue
00050 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00051 );
00052 ~XMLBigInteger();
00053
00054 XMLBigInteger(const XMLBigInteger& toCopy);
00055
00056 static XMLCh* getCanonicalRepresentation
00057 (
00058 const XMLCh* const rawData
00059 , MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
00060 , bool isNonPositiveInteger = false
00061 );
00062
00063 static void parseBigInteger(const XMLCh* const toConvert
00064 , XMLCh* const retBuffer
00065 , int& signValue
00066 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00067
00068 static int compareValues(const XMLBigInteger* const lValue
00069 ,const XMLBigInteger* const rValue
00070 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00071
00072
00073 static int compareValues(const XMLCh* const lString
00074 , const int& lSign
00075 , const XMLCh* const rString
00076 , const int& rSign
00077 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00078
00079 void multiply(const unsigned int byteToShift);
00080
00081 void divide(const unsigned int byteToShift);
00082
00083 unsigned int getTotalDigit() const;
00084
00090 inline XMLCh* getRawData() const;
00091
00102 bool operator==(const XMLBigInteger& toCompare) const;
00103
00108 int getSign() const;
00109
00110 int intValue() const;
00111
00112 private:
00113
00114
00115
00116 XMLBigInteger& operator=(const XMLBigInteger&);
00117
00118
00119 void setSign(int);
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 int fSign;
00143 XMLCh* fMagnitude;
00144 XMLCh* fRawData;
00145 MemoryManager* fMemoryManager;
00146 };
00147
00148 inline int XMLBigInteger::getSign() const
00149 {
00150 return fSign;
00151 }
00152
00153 inline unsigned int XMLBigInteger::getTotalDigit() const
00154 {
00155 return ((getSign() ==0) ? 0 : (unsigned int)XMLString::stringLen(fMagnitude));
00156 }
00157
00158 inline bool XMLBigInteger::operator==(const XMLBigInteger& toCompare) const
00159 {
00160 return ( compareValues(this, &toCompare, fMemoryManager) ==0 ? true : false);
00161 }
00162
00163 inline void XMLBigInteger::setSign(int newSign)
00164 {
00165 fSign = newSign;
00166 }
00167
00168 inline XMLCh* XMLBigInteger::getRawData() const
00169 {
00170 return fRawData;
00171 }
00172
00173 XERCES_CPP_NAMESPACE_END
00174
00175 #endif