Xerces-C++  3.1.2
XMLAbstractDoubleFloat.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * $Id: XMLAbstractDoubleFloat.hpp 605828 2007-12-20 08:05:47Z amassari $
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_XML_ABSTRACT_DOUBLE_FLOAT_HPP)
23 #define XERCESC_INCLUDE_GUARD_XML_ABSTRACT_DOUBLE_FLOAT_HPP
24 
25 
28 
30 
31 /***
32  * 3.2.5.1 Lexical representation
33  *
34  * double values have a lexical representation consisting of a mantissa followed,
35  * optionally, by the character "E" or "e", followed by an exponent.
36  *
37  * The exponent must be an integer.
38  * The mantissa must be a decimal number.
39  * The representations for exponent and mantissa must follow the lexical rules
40  * for integer and decimal.
41  *
42  * If the "E" or "e" and the following exponent are omitted,
43  * an exponent value of 0 is assumed.
44 ***/
45 
46 /***
47  * 3.2.4.1 Lexical representation
48  *
49  * float values have a lexical representation consisting of a mantissa followed,
50  * optionally, by the character "E" or "e", followed by an exponent.
51  *
52  * The exponent must be an integer.
53  * The mantissa must be a decimal number.
54  * The representations for exponent and mantissa must follow the lexical rules
55  * for integer and decimal.
56  *
57  * If the "E" or "e" and the following exponent are omitted,
58  * an exponent value of 0 is assumed.
59 ***/
60 
62 {
63 public:
64 
66  {
69  NaN,
71  Normal
72  };
73 
74  virtual ~XMLAbstractDoubleFloat();
75 
76  static XMLCh* getCanonicalRepresentation
77  (
78  const XMLCh* const rawData
80  );
81 
82  virtual XMLCh* getRawData() const;
83 
84  virtual const XMLCh* getFormattedString() const;
85 
86  virtual int getSign() const;
87 
88  MemoryManager* getMemoryManager() const;
89 
90  inline bool isDataConverted() const;
91 
92  inline bool isDataOverflowed() const;
93 
94  inline double getValue() const;
95 
96  inline LiteralType getType() const;
97 
98  /***
99  *
100  * The decimal point delimiter for the schema double/float type is
101  * defined to be a period and is not locale-specific. So, it must
102  * be replaced with the local-specific delimiter before converting
103  * from string to double/float.
104  *
105  ***/
106  static void normalizeDecimalPoint(char* const toNormal);
107 
108  /***
109  * Support for Serialization/De-serialization
110  ***/
111  DECL_XSERIALIZABLE(XMLAbstractDoubleFloat)
112 
113 protected:
114 
115  //
116  // To be used by derived class exclusively
117  //
118  XMLAbstractDoubleFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
119 
120  void init(const XMLCh* const strValue);
121 
135  static int compareValues(const XMLAbstractDoubleFloat* const lValue
136  , const XMLAbstractDoubleFloat* const rValue
137  , MemoryManager* const manager);
138 
139  //
140  // to be overridden by derived class
141  //
142  virtual void checkBoundary(char* const strValue) = 0;
143 
144  void
145  convert(char* const strValue);
146 
147 private:
148  //
149  // Unimplemented
150  //
151  // copy ctor
152  // assignment ctor
153  //
155  XMLAbstractDoubleFloat& operator=(const XMLAbstractDoubleFloat& toAssign);
156 
157  void normalizeZero(XMLCh* const);
158 
159  inline bool isSpecialValue() const;
160 
161  static int compareSpecial(const XMLAbstractDoubleFloat* const specialValue
162  , MemoryManager* const manager);
163 
164  void formatString();
165 
166 protected:
167  double fValue;
168  LiteralType fType;
169  bool fDataConverted;
170  bool fDataOverflowed;
171 
172 private:
173  int fSign;
174  XMLCh* fRawData;
175 
176  //
177  // If the original string is not lexcially the same as the five
178  // special value notations, and the value is converted to
179  // special value due underlying platform restriction on data
180  // representation, then this string is constructed and
181  // takes the form "original_string (special_value_notation)",
182  // otherwise it is empty.
183  //
184  XMLCh* fFormattedString;
185  MemoryManager* fMemoryManager;
186 
187 };
188 
189 inline bool XMLAbstractDoubleFloat::isSpecialValue() const
190 {
191  return (fType < SpecialTypeNum);
192 }
193 
195 {
196  return fMemoryManager;
197 }
198 
200 {
201  return fDataConverted;
202 }
203 
205 {
206  return fDataOverflowed;
207 }
208 
209 inline double XMLAbstractDoubleFloat::getValue() const
210 {
211  return fValue;
212 }
213 
215 {
216  return fType;
217 }
218 
220 
221 #endif
Definition: XMLAbstractDoubleFloat.hpp:61
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
Definition: XMLAbstractDoubleFloat.hpp:69
bool isDataOverflowed() const
Definition: XMLAbstractDoubleFloat.hpp:204
MemoryManager * getMemoryManager() const
Definition: XMLAbstractDoubleFloat.hpp:194
bool isDataConverted() const
Definition: XMLAbstractDoubleFloat.hpp:199
LiteralType
Definition: XMLAbstractDoubleFloat.hpp:65
Configurable memory manager.
Definition: MemoryManager.hpp:39
virtual XMLCh * getRawData() const =0
Return string representation of the decimal value.
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
Definition: XMLAbstractDoubleFloat.hpp:68
Utilities that must be implemented in a platform-specific way.
Definition: PlatformUtils.hpp:68
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
LiteralType getType() const
Definition: XMLAbstractDoubleFloat.hpp:214
Definition: XMLNumber.hpp:30
double getValue() const
Definition: XMLAbstractDoubleFloat.hpp:209
#define XMLUTIL_EXPORT
Definition: XercesDefs.hpp:162
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
Definition: XMLAbstractDoubleFloat.hpp:67
virtual const XMLCh * getFormattedString() const =0
Return the original and converted value of the original data.
virtual int getSign() const =0
Returns the sign of this number.
Definition: XMLAbstractDoubleFloat.hpp:70