00001 #ifndef _DOUBLEVALUE_H_ 00002 #define _DOUBLEVALUE_H_ 00003 // 00004 00005 // 00006 // Copyright (C) 2004-2006 Autodesk, Inc. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of version 2.1 of the GNU Lesser 00010 // General Public License as published by the Free Software Foundation. 00011 // 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 // Lesser General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public 00018 // License along with this library; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 // 00021 00022 #ifdef _WIN32 00023 #pragma once 00024 #endif 00025 00026 #include <FdoStd.h> 00027 #include <Fdo/Expression/DataValue.h> 00028 #include <Fdo/Schema/DataType.h> 00029 00030 /// \brief 00031 /// The FdoDoubleValue class derives from FdoDataValue and represents a double-precision floating point number. 00032 class FdoDoubleValue : public FdoDataValue 00033 { 00034 /// \cond DOXYGEN-IGNORE 00035 friend class FdoByteValue; 00036 friend class FdoInt16Value; 00037 friend class FdoInt32Value; 00038 friend class FdoInt64Value; 00039 friend class FdoSingleValue; 00040 friend class FdoStringValue; 00041 friend class FdoDataValue; 00042 protected: 00043 /// \brief 00044 /// Constructs a default instance of an FdoDoubleValue with a 00045 /// value of null. 00046 /// 00047 /// \return 00048 /// Returns nothing 00049 /// 00050 FdoDoubleValue(); 00051 00052 /// \brief 00053 /// Constructs a default instance of an FdoDoubleValue using the 00054 /// specified arguments. 00055 /// 00056 /// \param value 00057 /// Input a double 00058 /// 00059 /// \return 00060 /// Returns nothing 00061 /// 00062 FdoDoubleValue(double value); 00063 00064 /// \brief 00065 /// Default destructor for FdoDoubleValue. 00066 /// 00067 /// \return 00068 /// Returns nothing 00069 /// 00070 virtual ~FdoDoubleValue(); 00071 00072 virtual void Dispose(); 00073 /// \endcond 00074 00075 public: 00076 00077 /// \brief 00078 /// Constructs a default instance of an FdoDoubleValue with a value of null. 00079 /// 00080 /// \return 00081 /// Returns the created FdoDoubleValue 00082 /// 00083 FDO_API static FdoDoubleValue* Create(); 00084 00085 /// \brief 00086 /// Constructs a default instance of an FdoDoubleValue using the specified arguments. 00087 /// 00088 /// \param value 00089 /// Input a double 00090 /// 00091 /// \return 00092 /// Returns the created FdoDoubleValue 00093 /// 00094 FDO_API static FdoDoubleValue* Create(double value); 00095 00096 /// \brief 00097 /// Gets the data type of the FdoDoubleValue. 00098 /// 00099 /// \return 00100 /// Returns an FdoDataType 00101 /// 00102 FDO_API FdoDataType GetDataType(); 00103 00104 /// \brief 00105 /// Gets the double value. 00106 /// 00107 /// \return 00108 /// Returns a double 00109 /// 00110 FDO_API double GetDouble(); 00111 00112 /// \brief 00113 /// Sets the double value as a double precision floating point number. 00114 /// 00115 /// \param value 00116 /// Input a double 00117 /// 00118 /// \return 00119 /// Returns nothing 00120 /// 00121 FDO_API void SetDouble(double value); 00122 00123 /// \brief 00124 /// Overrides FdoExpression.Process to pass the FdoDoubleValue to the appropriate 00125 /// expression processor operation. 00126 /// 00127 /// \param p 00128 /// Input an FdoIExpressionProcessor 00129 /// 00130 /// \return 00131 /// Returns nothing 00132 /// 00133 FDO_API void Process(FdoIExpressionProcessor* p); 00134 00135 /// \brief 00136 /// Returns the well defined text representation of this expression. 00137 /// 00138 /// \return 00139 /// Returns a character string 00140 /// 00141 FDO_API FdoString* ToString(); 00142 00143 /// \brief 00144 /// A cast operator to get the double value. 00145 /// 00146 /// \return 00147 /// Returns a double 00148 /// 00149 FDO_API operator double() 00150 { 00151 return m_data; 00152 } 00153 00154 /// \cond DOXYGEN-IGNORE 00155 protected: 00156 /// \brief 00157 /// Constructs an instance of an FdoDoubleValue from another FdoDataValue. 00158 /// 00159 /// \param src 00160 /// Input the other FdoDataValue. Must be of one of the following types: 00161 /// FdoDataType_Boolean 00162 /// FdoDataType_Byte 00163 /// FdoDataType_Decimal 00164 /// FdoDataType_Double 00165 /// FdoDataType_Int16 00166 /// FdoDataType_Int32 00167 /// FdoDataType_Int64 00168 /// FdoDataType_Single 00169 /// FdoDataType_String 00170 /// - value must be numeric. 00171 /// 00172 /// In all other cases, the src type is considered incompatible with this type. 00173 /// \param nullIfIncompatible 00174 /// Input will determine what to do if the source value cannot be converted to 00175 /// this type: 00176 /// true - return NULL. 00177 /// false - throw an exception 00178 /// 00179 /// \param shift 00180 /// Input determines whether FdoInt64 values are allowed to shift when they have 00181 // more precision that can be handled by a double. 00182 /// true - convert values allowing them to shift. 00183 /// false - behaviour depends on nullIfIncompatible: 00184 /// true - return NULL. 00185 /// false - throw an exception 00186 /// \param truncate 00187 /// Input determines what to do if source value is outside the FdoDouble range 00188 /// ( -1.7e308, 1.7e308 ): 00189 /// true - convert values less than -1.7e308 to -1.7e308, convert values greater than 1.7e308 to 1.7e308 00190 /// false - behaviour depends on nullIfIncompatible: 00191 /// true - return NULL. 00192 /// false - throw an exception 00193 /// \return 00194 /// Returns an FdoDoubleValue, whose value is converted from the src value. 00195 /// If src is an FdoBooleanValue: 00196 /// false is converted to 0 00197 /// true is converted to 1 00198 /// 00199 static FdoDoubleValue* Create( 00200 FdoDataValue* src, 00201 FdoBoolean nullIfIncompatible = false, 00202 FdoBoolean shift = true, 00203 FdoBoolean truncate = false 00204 ); 00205 00206 // See FdoDataValue::DoCompare() 00207 virtual FdoCompareType DoCompare( FdoDataValue* other ); 00208 00209 double m_data; 00210 /// \endcond 00211 }; 00212 #endif 00213 00214