00001 /*00002 * Licensed to the Apache Software Foundation (ASF) under one or more00003 * contributor license agreements. See the NOTICE file distributed with00004 * this work for additional information regarding copyright ownership.00005 * The ASF licenses this file to You under the Apache License, Version 2.000006 * (the "License"); you may not use this file except in compliance with00007 * the License. You may obtain a copy of the License at00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.000010 * 00011 * Unless required by applicable law or agreed to in writing, software00012 * distributed under the License is distributed on an "AS IS" BASIS,00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.00014 * See the License for the specific language governing permissions and00015 * limitations under the License.00016 */00017
00018 /*00019 * $Id: XMLAbstractDoubleFloat.hpp 568078 2007-08-21 11:43:25Z amassari $00020 */00021
00022 #ifndef XML_ABSTRACT_DOUBLE_FLOAT_HPP00023 #define XML_ABSTRACT_DOUBLE_FLOAT_HPP00024
00025 #include <xercesc/util/XMLNumber.hpp>00026 #include <xercesc/util/PlatformUtils.hpp>00027
00028 XERCES_CPP_NAMESPACE_BEGIN00029
00030 /***00031 * 3.2.5.1 Lexical representation00032 *00033 * double values have a lexical representation consisting of a mantissa followed,00034 * optionally, by the character "E" or "e", followed by an exponent.00035 *00036 * The exponent �must� be an integer.00037 * The mantissa must be a decimal number.00038 * The representations for exponent and mantissa must follow the lexical rules00039 * for integer and decimal.00040 *00041 * If the "E" or "e" and the following exponent are omitted,00042 * an exponent value of 0 is assumed.00043 ***/00044
00045 /***00046 * 3.2.4.1 Lexical representation00047 *00048 * float values have a lexical representation consisting of a mantissa followed,00049 * optionally, by the character "E" or "e", followed by an exponent.00050 *00051 * The exponent �must� be an integer.00052 * The mantissa must be a decimal number.00053 * The representations for exponent and mantissa must follow the lexical rules00054 * for integer and decimal.00055 *00056 * If the "E" or "e" and the following exponent are omitted,00057 * an exponent value of 0 is assumed.00058 ***/00059
00060class XMLAbstractDoubleFloat : publicXMLNumber00061 {
00062 public:
00063
00064enumLiteralType00065 {
00066 NegINF,
00067 PosINF,
00068 NaN,
00069 SpecialTypeNum,
00070 Normal
00071 };
00072
00073 virtual ~XMLAbstractDoubleFloat();
00074
00075 static XMLCh* getCanonicalRepresentation
00076 (
00077 const XMLCh* const rawData
00078 , MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager00079 );
00080
00086 virtual XMLCh* toString() const;
00087
00088 virtual XMLCh* getRawData() const;
00089
00090 virtualconst XMLCh* getFormattedString() const;
00091
00092 virtualintgetSign() const;
00093
00094 MemoryManager* getMemoryManager() const;
00095
00096 inlinebool isDataConverted() const;
00097
00098 inlinebool isDataOverflowed() const;
00099
00100 inlinedouble getValue() const;
00101
00102 inline LiteralType getType() const;
00103
00104 /***00105 *00106 * The decimal point delimiter for the schema double/float type is00107 * defined to be a period and is not locale-specific. So, it must00108 * be replaced with the local-specific delimiter before converting00109 * from string to double/float.00110 *00111 ***/00112 staticvoid normalizeDecimalPoint(char* const toNormal);
00113
00114 /***00115 * Support for Serialization/De-serialization00116 ***/00117 DECL_XSERIALIZABLE(XMLAbstractDoubleFloat)
00118
00119 protected:
00120
00121 //00122 // To be used by derived class exclusively00123 //00124 XMLAbstractDoubleFloat(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00125
00126 void init(const XMLCh* const strValue);
00127
00141 static int compareValues(const XMLAbstractDoubleFloat* const lValue
00142 , const XMLAbstractDoubleFloat* const rValue
00143 , MemoryManager* const manager);
00144
00145 //00146 // to be overridden by derived class00147 //00148 virtual void checkBoundary(char* const strValue) = 0;
00149
00150 void00151 convert(char* const strValue);
00152
00153 private:
00154 //00155 // Unimplemented00156 //00157 // copy ctor00158 // assignment ctor00159 //00160 XMLAbstractDoubleFloat(const XMLAbstractDoubleFloat& toCopy);
00161 XMLAbstractDoubleFloat& operator=(const XMLAbstractDoubleFloat& toAssign);
00162
00163 void normalizeZero(XMLCh* const);
00164
00165 inline bool isSpecialValue() const;
00166
00167 static int compareSpecial(const XMLAbstractDoubleFloat* const specialValue
00168 , MemoryManager* const manager);
00169
00170 void formatString();
00171
00172 protected:
00173double fValue;
00174LiteralType fType;
00175bool fDataConverted;
00176bool fDataOverflowed;
00177
00178 private:
00179 int fSign;
00180 XMLCh* fRawData;
00181
00182 //00183 // If the original string is not lexcially the same as the five00184 // special value notations, and the value is converted to00185 // special value due underlying platform restriction on data00186 // representation, then this string is constructed and00187 // takes the form "original_string (special_value_notation)", 00188 // otherwise it is empty.00189 //00190 XMLCh* fFormattedString;
00191 MemoryManager* fMemoryManager;
00192
00193 };
00194
00195 inline boolXMLAbstractDoubleFloat::isSpecialValue() const00196 {
00197 return (fType < SpecialTypeNum);
00198 }
00199
00200inlineMemoryManager* XMLAbstractDoubleFloat::getMemoryManager() const00201 {
00202 return fMemoryManager;
00203 }
00204
00205inlineboolXMLAbstractDoubleFloat::isDataConverted() const00206 {
00207 returnfDataConverted;
00208 }
00209
00210inlineboolXMLAbstractDoubleFloat::isDataOverflowed() const00211 {
00212 returnfDataOverflowed;
00213 }
00214
00215inlinedoubleXMLAbstractDoubleFloat::getValue() const00216 {
00217 returnfValue;
00218 }
00219
00220inlineXMLAbstractDoubleFloat::LiteralTypeXMLAbstractDoubleFloat::getType() const00221 {
00222 returnfType;
00223 }
00224
00225 XERCES_CPP_NAMESPACE_END00226
00227 #endif