GME
13
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * 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 and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * $Id: XMLFloat.cpp 803857 2009-08-13 12:16:44Z amassari $ 00020 */ 00021 00022 // --------------------------------------------------------------------------- 00023 // Includes 00024 // --------------------------------------------------------------------------- 00025 #include <xercesc/util/XMLFloat.hpp> 00026 #include <math.h> 00027 00028 XERCES_CPP_NAMESPACE_BEGIN 00029 00030 // --------------------------------------------------------------------------- 00031 // ctor/dtor 00032 // --------------------------------------------------------------------------- 00033 XMLFloat::XMLFloat(const XMLCh* const strValue, 00034 MemoryManager* const manager) 00035 :XMLAbstractDoubleFloat(manager) 00036 { 00037 init(strValue); 00038 } 00039 00040 XMLFloat::~XMLFloat() 00041 { 00042 } 00043 00044 void XMLFloat::checkBoundary(char* const strValue) 00045 { 00046 convert(strValue); 00047 00048 if (fDataConverted == false) 00049 { 00054 // 3.2.4 The basic value space of float consists of the values m × 2^e, where 00055 // m is an integer whose absolute value is less than 2^24, 00056 // and e is an integer between -149 and 104, inclusive 00057 static const double fltMin = pow(2.0,-149); 00058 static const double fltMax = pow(2.0,24) * pow(2.0,104); 00059 if (fValue < (-1) * fltMax) 00060 { 00061 fType = NegINF; 00062 fDataConverted = true; 00063 fDataOverflowed = true; 00064 } 00065 else if (fValue > (-1)*fltMin && fValue < 0) 00066 { 00067 fDataConverted = true; 00068 fValue = 0; 00069 } 00070 else if (fValue > 0 && fValue < fltMin ) 00071 { 00072 fDataConverted = true; 00073 fValue = 0; 00074 } 00075 else if (fValue > fltMax) 00076 { 00077 fType = PosINF; 00078 fDataConverted = true; 00079 fDataOverflowed = true; 00080 } 00081 } 00082 } 00083 00084 /*** 00085 * Support for Serialization/De-serialization 00086 ***/ 00087 00088 IMPL_XSERIALIZABLE_TOCREATE(XMLFloat) 00089 00090 XMLFloat::XMLFloat(MemoryManager* const manager) 00091 :XMLAbstractDoubleFloat(manager) 00092 { 00093 } 00094 00095 void XMLFloat::serialize(XSerializeEngine& serEng) 00096 { 00097 XMLAbstractDoubleFloat::serialize(serEng); 00098 } 00099 00100 XERCES_CPP_NAMESPACE_END