Xerces-C++ 3.3.0
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$
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{
63public:
64
73
75
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
113protected:
114
115 //
116 // To be used by derived class exclusively
117 //
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
147private:
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
166protected:
167 double fValue;
171
172private:
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
189inline 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
210{
211 return fValue;
212}
213
218
220
221#endif
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XMLUTIL_EXPORT
Definition XercesDefs.hpp:162
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Configurable memory manager.
Definition MemoryManager.hpp:40
Definition XMLAbstractDoubleFloat.hpp:62
double getValue() const
Definition XMLAbstractDoubleFloat.hpp:209
void convert(char *const strValue)
virtual void checkBoundary(char *const strValue)=0
XMLAbstractDoubleFloat(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
LiteralType
Definition XMLAbstractDoubleFloat.hpp:66
@ SpecialTypeNum
Definition XMLAbstractDoubleFloat.hpp:70
@ NegINF
Definition XMLAbstractDoubleFloat.hpp:67
@ NaN
Definition XMLAbstractDoubleFloat.hpp:69
@ PosINF
Definition XMLAbstractDoubleFloat.hpp:68
static XMLCh * getCanonicalRepresentation(const XMLCh *const rawData, MemoryManager *const memMgr=XMLPlatformUtils::fgMemoryManager)
bool fDataOverflowed
Definition XMLAbstractDoubleFloat.hpp:170
LiteralType fType
Definition XMLAbstractDoubleFloat.hpp:168
double fValue
Definition XMLAbstractDoubleFloat.hpp:167
virtual XMLCh * getRawData() const
Return string representation of the decimal value.
bool isDataOverflowed() const
Definition XMLAbstractDoubleFloat.hpp:204
virtual const XMLCh * getFormattedString() const
Return the original and converted value of the original data.
bool fDataConverted
Definition XMLAbstractDoubleFloat.hpp:169
LiteralType getType() const
Definition XMLAbstractDoubleFloat.hpp:214
static void normalizeDecimalPoint(char *const toNormal)
MemoryManager * getMemoryManager() const
Definition XMLAbstractDoubleFloat.hpp:194
bool isDataConverted() const
Definition XMLAbstractDoubleFloat.hpp:199
virtual int getSign() const
Returns the sign of this number.
static int compareValues(const XMLAbstractDoubleFloat *const lValue, const XMLAbstractDoubleFloat *const rValue, MemoryManager *const manager)
Compares this object to the specified object.
void init(const XMLCh *const strValue)
virtual ~XMLAbstractDoubleFloat()
Definition XMLNumber.hpp:31
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121