00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef XML_BIGINTEGER_HPP
00023 #define 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 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 int getTotalDigit() const;
00084
00093 inline XMLCh* toString() const;
00094
00100 inline XMLCh* getRawData() const;
00101
00112 bool operator==(const XMLBigInteger& toCompare) const;
00113
00118 int getSign() const;
00119
00120 int intValue() const;
00121
00122 private:
00123
00124
00125
00126 XMLBigInteger& operator=(const XMLBigInteger&);
00127
00128
00129 void setSign(int);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 int fSign;
00153 XMLCh* fMagnitude;
00154 XMLCh* fRawData;
00155 MemoryManager* fMemoryManager;
00156 };
00157
00158 inline int XMLBigInteger::getSign() const
00159 {
00160 return fSign;
00161 }
00162
00163 inline int XMLBigInteger::getTotalDigit() const
00164 {
00165 return ((getSign() ==0) ? 0 : XMLString::stringLen(fMagnitude));
00166 }
00167
00168 inline bool XMLBigInteger::operator==(const XMLBigInteger& toCompare) const
00169 {
00170 return ( compareValues(this, &toCompare, fMemoryManager) ==0 ? true : false);
00171 }
00172
00173 inline void XMLBigInteger::setSign(int newSign)
00174 {
00175 fSign = newSign;
00176 }
00177
00178 inline XMLCh* XMLBigInteger::getRawData() const
00179 {
00180 return fRawData;
00181 }
00182
00183
00184
00185
00186 inline XMLCh* XMLBigInteger::toString() const
00187 {
00188
00189 return XMLString::replicate(fRawData, fMemoryManager);
00190 }
00191
00192 XERCES_CPP_NAMESPACE_END
00193
00194 #endif