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