Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:14

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XML_BIGDECIMAL_HPP
0024 
0025 #include <xercesc/util/XMLNumber.hpp>
0026 #include <xercesc/util/XMLString.hpp>
0027 #include <xercesc/util/PlatformUtils.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 class XMLUTIL_EXPORT XMLBigDecimal : public XMLNumber
0032 {
0033 public:
0034 
0035     /**
0036      * Constructs a newly allocated <code>XMLBigDecimal</code> object that
0037      * represents the value represented by the string.
0038      *
0039      * @param  strValue the <code>String</code> to be converted to an
0040      *                  <code>XMLBigDecimal</code>.
0041      * @param  manager  Pointer to the memory manager to be used to
0042      *                  allocate objects.
0043      * @exception  NumberFormatException  if the <code>String</code> does not
0044      *               contain a parsable XMLBigDecimal.
0045      */
0046 
0047     XMLBigDecimal
0048     (
0049         const XMLCh* const strValue
0050         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
0051     );
0052 
0053     ~XMLBigDecimal();
0054 
0055     static int            compareValues(const XMLBigDecimal* const lValue
0056                                       , const XMLBigDecimal* const rValue
0057                                       , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0058 
0059     static XMLCh* getCanonicalRepresentation
0060                   (
0061                    const XMLCh*         const rawData
0062                  ,       MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
0063                   );
0064 
0065     static void  parseDecimal
0066                 ( 
0067                    const XMLCh* const toParse
0068                 ,        XMLCh* const retBuffer
0069                 ,        int&         sign
0070                 ,        int&         totalDigits
0071                 ,        int&         fractDigits
0072                 ,        MemoryManager* const manager
0073                 );
0074 
0075     static void  parseDecimal
0076                 ( 
0077                    const XMLCh*         const toParse
0078                 ,        MemoryManager* const manager
0079                 );
0080 
0081     virtual XMLCh*        getRawData() const;
0082 
0083     virtual const XMLCh*  getFormattedString() const;
0084 
0085     virtual int           getSign() const;
0086 
0087     const XMLCh*          getValue() const;
0088 
0089     unsigned int          getScale() const;
0090 
0091     unsigned int          getTotalDigit() const;
0092 
0093     inline XMLCh*         getIntVal() const;
0094 
0095     /**
0096      * Compares this object to the specified object.
0097      *
0098      * @param   other   the object to compare with.
0099      * @return  <code>-1</code> value is less than other's
0100      *          <code>0</code>  value equals to other's
0101      *          <code>+1</code> value is greater than other's
0102      */
0103      int toCompare(const XMLBigDecimal& other) const;
0104 
0105     /*
0106      * Sets the value to be converted
0107      *
0108      * @param   strValue the value to convert
0109      */
0110     void setDecimalValue(const XMLCh* const strValue);
0111 
0112     MemoryManager* getMemoryManager() const;
0113 
0114     /***
0115      * Support for Serialization/De-serialization
0116      ***/
0117     DECL_XSERIALIZABLE(XMLBigDecimal)
0118 
0119     XMLBigDecimal(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0120 
0121 private:
0122 
0123     void  cleanUp();
0124     
0125     // -----------------------------------------------------------------------
0126     //  Unimplemented constructors and operators
0127     // -----------------------------------------------------------------------       
0128     XMLBigDecimal(const XMLBigDecimal& other);
0129     XMLBigDecimal& operator=(const XMLBigDecimal& other);        
0130     
0131     // -----------------------------------------------------------------------
0132     //  Private data members
0133     //
0134     //  fSign
0135     //     sign
0136     //
0137     //  fTotalDigits
0138     //     the total number of digits 
0139     //
0140     //  fScale
0141     //     the number of digits to the right of the decimal point
0142     //
0143     //  fIntVal
0144     //     The value of this BigDecimal, w/o
0145     //         leading whitespace, leading zero
0146     //         decimal point
0147     //         trailing zero, trailing whitespace
0148     //
0149     //  fRawData
0150     //     to preserve the original string used to construct this object,
0151     //     needed for pattern matching.
0152     //
0153     // -----------------------------------------------------------------------
0154     int            fSign;
0155     unsigned int   fTotalDigits;
0156     unsigned int   fScale;
0157     XMLSize_t      fRawDataLen;
0158     XMLCh*         fRawData;
0159     XMLCh*         fIntVal;
0160     MemoryManager* fMemoryManager;
0161 
0162 };
0163 
0164 inline int XMLBigDecimal::getSign() const
0165 {
0166     return fSign;
0167 }
0168 
0169 inline const XMLCh* XMLBigDecimal::getValue() const
0170 {
0171     return fIntVal;
0172 }
0173 
0174 inline unsigned int XMLBigDecimal::getScale() const
0175 {
0176     return fScale;
0177 }
0178 
0179 inline unsigned int XMLBigDecimal::getTotalDigit() const
0180 {
0181     return fTotalDigits;
0182 }
0183 
0184 inline XMLCh*  XMLBigDecimal::getRawData() const
0185 {
0186     return fRawData;
0187 }
0188 
0189 inline const XMLCh*  XMLBigDecimal::getFormattedString() const
0190 {
0191     return fRawData;
0192 }
0193 
0194 inline MemoryManager* XMLBigDecimal::getMemoryManager() const
0195 {
0196     return fMemoryManager;
0197 }
0198 
0199 inline XMLCh*  XMLBigDecimal::getIntVal() const
0200 {
0201     return fIntVal;
0202 }
0203 
0204 XERCES_CPP_NAMESPACE_END
0205 
0206 #endif