| API Docs for SAX and DOM |

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

# XMLAbstractDoubleFloat.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: XMLAbstractDoubleFloat.hpp 191054 2005-06-17 02:56:35Z jberry $
    00019  */
    00020
    00021 #ifndef XML_ABSTRACT_DOUBLE_FLOAT_HPP
    00022 #define XML_ABSTRACT_DOUBLE_FLOAT_HPP
    00023
    00024 #include <xercesc/util/XMLNumber.hpp>
    00025 #include <xercesc/util/PlatformUtils.hpp>
    00026
    00027 XERCES_CPP_NAMESPACE_BEGIN
    00028
    00029 /***
    00030  * 3.2.5.1 Lexical representation
    00031  *
    00032  *   double values have a lexical representation consisting of a mantissa followed,
    00033  *   optionally, by the character "E" or "e", followed by an exponent.
    00034  *
    00035  *   The exponent �must� be an integer.
    00036  *   The mantissa must be a decimal number.
    00037  *   The representations for exponent and mantissa must follow the lexical rules
    00038  *   for integer and decimal.
    00039  *
    00040  *   If the "E" or "e" and the following exponent are omitted,
    00041  *   an exponent value of 0 is assumed.
    00042 ***/
    00043
    00044 /***
    00045  * 3.2.4.1 Lexical representation
    00046  *
    00047  *   float values have a lexical representation consisting of a mantissa followed,
    00048  *   optionally, by the character "E" or "e", followed by an exponent.
    00049  *
    00050  *   The exponent �must� be an integer.
    00051  *   The mantissa must be a decimal number.
    00052  *   The representations for exponent and mantissa must follow the lexical rules
    00053  *   for integer and decimal.
    00054  *
    00055  *   If the "E" or "e" and the following exponent are omitted,
    00056  *   an exponent value of 0 is assumed.
    00057 ***/
    00058
    00059 class  XMLAbstractDoubleFloat : public XMLNumber
    00060 {
    00061 public:
    00062
    00063     enum LiteralType
    00064     {
    00065         NegINF,
    00066         PosINF,
    00067         NaN,
    00068         SpecialTypeNum,
    00069         Normal
    00070     };
    00071
    00072     virtual ~XMLAbstractDoubleFloat();
    00073
    00074     static XMLCh* getCanonicalRepresentation
    00075                         (
    00076                           const XMLCh*         const rawData
    00077                         ,       MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager
    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     MemoryManager*        getMemoryManager() const;
    00094
    00095     inline  bool          isDataConverted()  const;
    00096
    00097     inline  bool          isDataOverflowed()  const;
    00098
    00099     inline  double        getValue() const;
    00100
    00101     inline  LiteralType   getType() const;
    00102
    00103     /***
    00104      *
    00105      * The decimal point delimiter for the schema double/float type is
    00106      * defined to be a period and is not locale-specific. So, it must
    00107      * be replaced with the local-specific delimiter before converting
    00108      * from string to double/float.
    00109      *
    00110      ***/
    00111     static void            normalizeDecimalPoint(char* const toNormal);
    00112
    00113     /***
    00114      * Support for Serialization/De-serialization
    00115      ***/
    00116     DECL_XSERIALIZABLE(XMLAbstractDoubleFloat)
    00117
    00118 protected:
    00119
    00120     //
    00121     // To be used by derived class exclusively
    00122     //
    00123     XMLAbstractDoubleFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00124
    00125     void                  init(const XMLCh* const strValue);
    00126
    00140     static int            compareValues(const XMLAbstractDoubleFloat* const lValue
    00141                                       , const XMLAbstractDoubleFloat* const rValue
    00142                                       , MemoryManager* const manager);
    00143
    00144     //
    00145     // to be overridden by derived class
    00146     //
    00147     virtual void          checkBoundary(char* const strValue) = 0;
    00148
    00149     void
    00150     convert(char* const strValue);
    00151
    00152 private:
    00153     //
    00154     // Unimplemented
    00155     //
    00156     // copy ctor
    00157     // assignment ctor
    00158     //
    00159     XMLAbstractDoubleFloat(const XMLAbstractDoubleFloat& toCopy);
    00160     XMLAbstractDoubleFloat& operator=(const XMLAbstractDoubleFloat& toAssign);
    00161
    00162     void                  normalizeZero(XMLCh* const);
    00163
    00164     inline bool           isSpecialValue() const;
    00165
    00166     static int            compareSpecial(const XMLAbstractDoubleFloat* const specialValue
    00167                                        , MemoryManager* const manager);
    00168
    00169     void                  formatString();
    00170
    00171 protected:
    00172     double                  fValue;
    00173     LiteralType             fType;
    00174     bool                    fDataConverted;
    00175     bool                    fDataOverflowed;
    00176
    00177 private:
    00178     int                     fSign;
    00179     XMLCh*                  fRawData;
    00180
    00181     //
    00182     // If the original string is not lexcially the same as the five
    00183     // special value notations, and the value is converted to
    00184     // special value due underlying platform restriction on data
    00185     // representation, then this string is constructed and
    00186     // takes the form "original_string (special_value_notation)",
    00187     // otherwise it is empty.
    00188     //
    00189     XMLCh*                  fFormattedString;
    00190     MemoryManager*          fMemoryManager;
    00191
    00192 };
    00193
    00194 inline bool XMLAbstractDoubleFloat::isSpecialValue() const
    00195 {
    00196     return (fType < SpecialTypeNum);
    00197 }
    00198
    00199 inline MemoryManager* XMLAbstractDoubleFloat::getMemoryManager() const
    00200 {
    00201     return fMemoryManager;
    00202 }
    00203
    00204 inline bool XMLAbstractDoubleFloat::isDataConverted() const
    00205 {
    00206     return fDataConverted;
    00207 }
    00208
    00209 inline bool XMLAbstractDoubleFloat::isDataOverflowed() const
    00210 {
    00211     return fDataOverflowed;
    00212 }
    00213
    00214 inline double XMLAbstractDoubleFloat::getValue() const
    00215 {
    00216     return fValue;
    00217 }
    00218
    00219 inline  XMLAbstractDoubleFloat::LiteralType   XMLAbstractDoubleFloat::getType() const
    00220 {
    00221     return fType;
    00222 }
    00223
    00224 XERCES_CPP_NAMESPACE_END
    00225
    00226 #endif

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