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_ABSTRACT_DOUBLE_FLOAT_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XML_ABSTRACT_DOUBLE_FLOAT_HPP
0024 
0025 
0026 #include <xercesc/util/XMLNumber.hpp>
0027 #include <xercesc/util/PlatformUtils.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 /***
0032  * 3.2.5.1 Lexical representation
0033  *
0034  *   double values have a lexical representation consisting of a mantissa followed,
0035  *   optionally, by the character "E" or "e", followed by an exponent.
0036  *
0037  *   The exponent must be an integer.
0038  *   The mantissa must be a decimal number.
0039  *   The representations for exponent and mantissa must follow the lexical rules
0040  *   for integer and decimal.
0041  *
0042  *   If the "E" or "e" and the following exponent are omitted,
0043  *   an exponent value of 0 is assumed.
0044 ***/
0045 
0046 /***
0047  * 3.2.4.1 Lexical representation
0048  *
0049  *   float values have a lexical representation consisting of a mantissa followed,
0050  *   optionally, by the character "E" or "e", followed by an exponent.
0051  *
0052  *   The exponent must be an integer.
0053  *   The mantissa must be a decimal number.
0054  *   The representations for exponent and mantissa must follow the lexical rules
0055  *   for integer and decimal.
0056  *
0057  *   If the "E" or "e" and the following exponent are omitted,
0058  *   an exponent value of 0 is assumed.
0059 ***/
0060 
0061 class XMLUTIL_EXPORT XMLAbstractDoubleFloat : public XMLNumber
0062 {
0063 public:
0064 
0065     enum LiteralType
0066     {
0067         NegINF,
0068         PosINF,
0069         NaN,
0070         SpecialTypeNum,
0071         Normal
0072     };
0073 
0074     virtual ~XMLAbstractDoubleFloat();
0075 
0076     static XMLCh* getCanonicalRepresentation
0077                         (
0078                           const XMLCh*         const rawData
0079                         ,       MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
0080                         );
0081     
0082     virtual XMLCh*        getRawData() const;
0083 
0084     virtual const XMLCh*  getFormattedString() const;
0085 
0086     virtual int           getSign() const;
0087 
0088     MemoryManager*        getMemoryManager() const;
0089 
0090     inline  bool          isDataConverted()  const;
0091 
0092     inline  bool          isDataOverflowed()  const;
0093 
0094     inline  double        getValue() const;
0095 
0096     inline  LiteralType   getType() const;
0097 
0098     /***
0099      *
0100      * The decimal point delimiter for the schema double/float type is
0101      * defined to be a period and is not locale-specific. So, it must
0102      * be replaced with the local-specific delimiter before converting
0103      * from string to double/float.
0104      *
0105      ***/
0106     static void            normalizeDecimalPoint(char* const toNormal);
0107 
0108     /***
0109      * Support for Serialization/De-serialization
0110      ***/
0111     DECL_XSERIALIZABLE(XMLAbstractDoubleFloat)
0112 
0113 protected:
0114 
0115     //
0116     // To be used by derived class exclusively
0117     //
0118     XMLAbstractDoubleFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0119 
0120     void                  init(const XMLCh* const strValue);
0121 
0122     /**
0123      * Compares this object to the specified object.
0124      * The result is <code>true</code> if and only if the argument is not
0125      * <code>null</code> and is an <code>XMLAbstractDoubleFloat</code> object that contains
0126      * the same <code>int</code> value as this object.
0127      *
0128      * @param   lValue the object to compare with.
0129      * @param   rValue the object to compare against.
0130      * @param manager The MemoryManager to use to allocate objects
0131      * @return  <code>true</code> if the objects are the same;
0132      *          <code>false</code> otherwise.
0133      */
0134 
0135     static int            compareValues(const XMLAbstractDoubleFloat* const lValue
0136                                       , const XMLAbstractDoubleFloat* const rValue
0137                                       , MemoryManager* const manager);
0138 
0139     //
0140     // to be overridden by derived class
0141     //
0142     virtual void          checkBoundary(char* const strValue) = 0;
0143 
0144     void
0145     convert(char* const strValue);
0146 
0147 private:
0148     //
0149     // Unimplemented
0150     //
0151     // copy ctor
0152     // assignment ctor
0153     //
0154     XMLAbstractDoubleFloat(const XMLAbstractDoubleFloat& toCopy);
0155     XMLAbstractDoubleFloat& operator=(const XMLAbstractDoubleFloat& toAssign);
0156 
0157     void                  normalizeZero(XMLCh* const);
0158 
0159     inline bool           isSpecialValue() const;
0160 
0161     static int            compareSpecial(const XMLAbstractDoubleFloat* const specialValue                                       
0162                                        , MemoryManager* const manager);
0163 
0164     void                  formatString();
0165 
0166 protected:
0167     double                  fValue;
0168     LiteralType             fType;
0169     bool                    fDataConverted;
0170     bool                    fDataOverflowed;
0171 
0172 private:
0173     int                     fSign;
0174     XMLCh*                  fRawData;
0175 
0176     //
0177     // If the original string is not lexcially the same as the five
0178     // special value notations, and the value is converted to
0179     // special value due underlying platform restriction on data
0180     // representation, then this string is constructed and
0181     // takes the form "original_string (special_value_notation)", 
0182     // otherwise it is empty.
0183     //
0184     XMLCh*                  fFormattedString;
0185     MemoryManager*          fMemoryManager;
0186 
0187 };
0188 
0189 inline bool XMLAbstractDoubleFloat::isSpecialValue() const
0190 {
0191     return (fType < SpecialTypeNum);
0192 }
0193 
0194 inline MemoryManager* XMLAbstractDoubleFloat::getMemoryManager() const
0195 {
0196     return fMemoryManager;
0197 }
0198 
0199 inline bool XMLAbstractDoubleFloat::isDataConverted() const
0200 {
0201     return fDataConverted;
0202 }
0203 
0204 inline bool XMLAbstractDoubleFloat::isDataOverflowed() const
0205 {
0206     return fDataOverflowed;
0207 }
0208 
0209 inline double XMLAbstractDoubleFloat::getValue() const
0210 {
0211     return fValue;
0212 }
0213 
0214 inline  XMLAbstractDoubleFloat::LiteralType   XMLAbstractDoubleFloat::getType() const
0215 {
0216     return fType;
0217 }
0218 
0219 XERCES_CPP_NAMESPACE_END
0220 
0221 #endif