XMLBigDecimal.hpp

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

Generated on Thu Feb 19 11:35:44 2009 for Xerces-C++ by  doxygen 1.5.4