00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #ifndef XML_BIGINTEGER_HPP
00062 #define XML_BIGINTEGER_HPP
00063
00064 #include <xercesc/util/XMemory.hpp>
00065 #include <xercesc/util/XMLString.hpp>
00066
00067 XERCES_CPP_NAMESPACE_BEGIN
00068
00069 class XMLBigInteger : public XMemory
00070 {
00071 public:
00072
00086 XMLBigInteger
00087 (
00088 const XMLCh* const strValue
00089 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00090 );
00091 ~XMLBigInteger();
00092
00093 XMLBigInteger(const XMLBigInteger& toCopy);
00094
00095 static XMLCh* getCanonicalRepresentation
00096 (
00097 const XMLCh* const rawData
00098 , MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
00099 );
00100
00101 static void parseBigInteger(const XMLCh* const toConvert
00102 , XMLCh* const retBuffer
00103 , int& signValue
00104 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00105
00106 static int compareValues(const XMLBigInteger* const lValue
00107 ,const XMLBigInteger* const rValue
00108 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00109
00110
00111 void multiply(const unsigned int byteToShift);
00112
00113 void divide(const unsigned int byteToShift);
00114
00115 int getTotalDigit() const;
00116
00125 inline XMLCh* toString() const;
00126
00132 inline XMLCh* getRawData() const;
00133
00144 bool operator==(const XMLBigInteger& toCompare) const;
00145
00150 int getSign() const;
00151
00152 int intValue() const;
00153
00154 private:
00155
00156
00157
00158 XMLBigInteger& operator=(const XMLBigInteger&);
00159
00160
00161 void setSign(int);
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 int fSign;
00185 XMLCh* fMagnitude;
00186 XMLCh* fRawData;
00187 MemoryManager* fMemoryManager;
00188 };
00189
00190 inline int XMLBigInteger::getSign() const
00191 {
00192 return fSign;
00193 }
00194
00195 inline int XMLBigInteger::getTotalDigit() const
00196 {
00197 return ((getSign() ==0) ? 0 : XMLString::stringLen(fMagnitude));
00198 }
00199
00200 inline bool XMLBigInteger::operator==(const XMLBigInteger& toCompare) const
00201 {
00202 return ( compareValues(this, &toCompare, fMemoryManager) ==0 ? true : false);
00203 }
00204
00205 inline void XMLBigInteger::setSign(int newSign)
00206 {
00207 fSign = newSign;
00208 }
00209
00210 inline XMLCh* XMLBigInteger::getRawData() const
00211 {
00212 return fRawData;
00213 }
00214
00215
00216
00217
00218 inline XMLCh* XMLBigInteger::toString() const
00219 {
00220
00221 return XMLString::replicate(fRawData, fMemoryManager);
00222 }
00223
00224 XERCES_CPP_NAMESPACE_END
00225
00226 #endif