| API Docs for SAX and DOM |
| Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages # XMLBigDecimal.hpp Go to the documentation of this file.
    00001 /*
    00002  * Copyright 2001-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 /*
    00018  * $Id: XMLBigDecimal.hpp 176026 2004-09-08 13:57:07Z peiyongz $
    00019  */
    00020
    00021 #ifndef XML_BIGDECIMAL_HPP
    00022 #define XML_BIGDECIMAL_HPP
    00023
    00024 #include <xercesc/util/XMLNumber.hpp>
    00025 #include <xercesc/util/XMLString.hpp>
    00026 #include <xercesc/util/PlatformUtils.hpp>
    00027
    00028 XERCES_CPP_NAMESPACE_BEGIN
    00029
    00030 class  XMLBigDecimal : public XMLNumber
    00031 {
    00032 public:
    00033
    00046     XMLBigDecimal
    00047     (
    00048         const XMLCh* const strValue
    00049         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00050     );
    00051
    00052     ~XMLBigDecimal();
    00053
    00054     static int            compareValues(const XMLBigDecimal* const lValue
    00055                                       , const XMLBigDecimal* const rValue
    00056                                       , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00057
    00058     static XMLCh* getCanonicalRepresentation
    00059                   (
    00060                    const XMLCh*         const rawData
    00061                  ,       MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
    00062                   );
    00063
    00064     static void  parseDecimal
    00065                 (
    00066                    const XMLCh* const toParse
    00067                 ,        XMLCh* const retBuffer
    00068                 ,        int&         sign
    00069                 ,        int&         totalDigits
    00070                 ,        int&         fractDigits
    00071                 ,        MemoryManager* const manager
    00072                 );
    00073
    00074     static void  parseDecimal
    00075                 (
    00076                    const XMLCh*         const toParse
    00077                 ,        MemoryManager* const manager
    00078                 );
    00079
    00085     virtual XMLCh*        toString() const;
    00086
    00087     virtual XMLCh*        getRawData() const;
    00088
    00089     virtual const XMLCh*  getFormattedString() const;
    00090
    00091     virtual int           getSign() const;
    00092
    00093     const XMLCh*          getValue() const;
    00094
    00095     unsigned int          getScale() const;
    00096
    00097     unsigned int          getTotalDigit() const;
    00098
    00099     inline XMLCh*         getIntVal() const;
    00100
    00109      int toCompare(const XMLBigDecimal& other) const;
    00110
    00111     /*
    00112      * Sets the value to be converted
    00113      *
    00114      * @param   strValue the value to convert
    00115      */
    00116     void setDecimalValue(const XMLCh* const strValue);
    00117
    00118     MemoryManager* getMemoryManager() const;
    00119
    00120     /***
    00121      * Support for Serialization/De-serialization
    00122      ***/
    00123     DECL_XSERIALIZABLE(XMLBigDecimal)
    00124
    00125     XMLBigDecimal(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00126
    00127 private:
    00128
    00129     void  cleanUp();
    00130
    00131     // -----------------------------------------------------------------------
    00132     //  Unimplemented contstructors and operators
    00133     // -----------------------------------------------------------------------
    00134     XMLBigDecimal(const XMLBigDecimal& other);
    00135     XMLBigDecimal& operator=(const XMLBigDecimal& other);
    00136
    00137     // -----------------------------------------------------------------------
    00138     //  Private data members
    00139     //
    00140     //  fSign
    00141     //     sign
    00142     //
    00143     //  fTotalDigits
    00144     //     the total number of didits
    00145     //
    00146     //  fScale
    00147     //     the number of digits to the right of the decimal point
    00148     //
    00149     //  fIntVal
    00150     //     The value of this BigDecimal, w/o
    00151     //         leading whitespace, leading zero
    00152     //         decimal point
    00153     //         trailing zero, trailing whitespace
    00154     //
    00155     //  fRawData
    00156     //     to preserve the original string used to construct this object,
    00157     //     needed for pattern matching.
    00158     //
    00159     // -----------------------------------------------------------------------
    00160     int            fSign;
    00161     unsigned int   fTotalDigits;
    00162     unsigned int   fScale;
    00163     unsigned int   fRawDataLen;
    00164     XMLCh*         fRawData;
    00165     XMLCh*         fIntVal;
    00166     MemoryManager* fMemoryManager;
    00167
    00168 };
    00169
    00170 inline int XMLBigDecimal::getSign() const
    00171 {
    00172     return fSign;
    00173 }
    00174
    00175 inline const XMLCh* XMLBigDecimal::getValue() const
    00176 {
    00177     return fIntVal;
    00178 }
    00179
    00180 inline unsigned int XMLBigDecimal::getScale() const
    00181 {
    00182     return fScale;
    00183 }
    00184
    00185 inline unsigned int XMLBigDecimal::getTotalDigit() const
    00186 {
    00187     return fTotalDigits;
    00188 }
    00189
    00190 inline XMLCh*  XMLBigDecimal::getRawData() const
    00191 {
    00192     return fRawData;
    00193 }
    00194
    00195 inline const XMLCh*  XMLBigDecimal::getFormattedString() const
    00196 {
    00197     return fRawData;
    00198 }
    00199
    00200 inline MemoryManager* XMLBigDecimal::getMemoryManager() const
    00201 {
    00202     return fMemoryManager;
    00203 }
    00204
    00205 inline XMLCh*  XMLBigDecimal::getIntVal() const
    00206 {
    00207     return fIntVal;
    00208 }
    00209
    00210 //
    00211 // The caller needs to de-allocate the memory allocated by this function
    00212 //
    00213 inline XMLCh*  XMLBigDecimal::toString() const
    00214 {
    00215     // Return data using global operator new
    00216     return XMLString::replicate(fRawData);
    00217 }
    00218
    00219 XERCES_CPP_NAMESPACE_END
    00220
    00221 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.