00001 #ifndef _SINGLEVALUE_H_ 00002 #define _SINGLEVALUE_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 FdoSingleValue class derives from FdoDataValue and represents a single precision floating point number. 00032 class FdoSingleValue : 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 FdoStringValue; 00040 friend class FdoDataValue; 00041 protected: 00042 /// \brief 00043 /// Constructs a default instance of an FdoSingleValue with a 00044 /// value of null. 00045 /// \return 00046 /// Returns nothing 00047 /// 00048 FdoSingleValue(); 00049 00050 /// \brief 00051 /// Constructs a default instance of an FdoSingleValue using the specified arguments. 00052 /// \param value 00053 /// Input a single precision floating point value 00054 /// 00055 /// \return 00056 /// Returns nothing 00057 /// 00058 FdoSingleValue(float value); 00059 00060 /// \brief 00061 /// Default destructor for FdoSingleValue. 00062 virtual ~FdoSingleValue(); 00063 00064 virtual void Dispose(); 00065 /// \endcond 00066 00067 public: 00068 00069 /// \brief 00070 /// Constructs a default instance of an FdoSingleValue with a value of null. 00071 /// 00072 /// \return 00073 /// Returns the created FdoSingleValue 00074 /// 00075 FDO_API static FdoSingleValue* Create(); 00076 00077 /// \brief 00078 /// Constructs a default instance of an FdoSingleValue using the specified arguments. 00079 /// 00080 /// \param value 00081 /// Input a single precision floating point value 00082 /// 00083 /// \return 00084 /// Returns the created FdoSingleValue 00085 /// 00086 FDO_API static FdoSingleValue* Create(float value); 00087 00088 /// \brief 00089 /// Gets the data type of the FdoSingleValue. 00090 /// 00091 /// \return 00092 /// Returns an FdoDataType 00093 /// 00094 FDO_API FdoDataType GetDataType(); 00095 00096 /// \brief 00097 /// Gets the FdoSingleValue as a single precision floating point number. 00098 /// 00099 /// \return 00100 /// Returns a single precision floating point value 00101 /// 00102 FDO_API float GetSingle(); 00103 00104 /// \brief 00105 /// Sets the FdoSingleValue as a single precision floating point number. 00106 /// 00107 /// \param value 00108 /// Input a single precision floating point value 00109 /// 00110 /// \return 00111 /// Returns nothing 00112 /// 00113 FDO_API void SetSingle(float value); 00114 00115 /// \brief 00116 /// Overrides FdoExpression.Process to pass the FdoSingleValue to the appropriate 00117 /// expression processor operation. 00118 /// 00119 /// \param p 00120 /// Input an FdoIExpressionProcessor 00121 /// 00122 /// \return 00123 /// Returns nothing 00124 /// 00125 FDO_API void Process(FdoIExpressionProcessor* p); 00126 00127 /// \brief 00128 /// Returns the well defined text representation of this expression. 00129 /// 00130 /// \return 00131 /// Returns a character string 00132 /// 00133 FDO_API FdoString* ToString(); 00134 00135 /// \brief 00136 /// A cast operator to get the floating point value. 00137 /// 00138 /// \return 00139 /// Returns a single precision floating point value 00140 /// 00141 FDO_API operator float() 00142 { 00143 return m_data; 00144 } 00145 00146 /// \cond DOXYGEN-IGNORE 00147 protected: 00148 /// \brief 00149 /// Constructs an instance of an FdoSingleValue from another FdoDataValue. 00150 /// 00151 /// \param src 00152 /// Input the other FdoDataValue. Must be of one of the following types: 00153 /// FdoDataType_Boolean 00154 /// FdoDataType_Byte 00155 /// FdoDataType_Decimal 00156 /// FdoDataType_Double 00157 /// FdoDataType_Int16 00158 /// FdoDataType_Int32 00159 /// FdoDataType_Int64 00160 /// FdoDataType_Single 00161 /// FdoDataType_String 00162 /// - value must be numeric. 00163 /// 00164 /// In all other cases, the src type is considered incompatible with this type. 00165 /// \param nullIfIncompatible 00166 /// Input will determine what to do if the source value cannot be converted to 00167 /// this type: 00168 /// true - return NULL. 00169 /// false - throw an exception 00170 /// 00171 /// \param shift 00172 /// Input determines whether FdoInt32 or FdoInt64 values are allowed to shift 00173 /// when they have more precision that can be handled by a float. 00174 /// true - convert values allowing them to shift. 00175 /// false - behaviour depends on nullIfIncompatible: 00176 /// true - return NULL. 00177 /// false - throw an exception 00178 /// \param truncate 00179 /// Input determines what to do if source value is outside the FdoFloat range 00180 /// ( -3.4e38, 3.4e38 ): 00181 /// true - convert values less than -3.4e38 to -3.4e38, convert values greater than 3.4e38 to 3.4e38 00182 /// false - behaviour depends on nullIfIncompatible: 00183 /// true - return NULL. 00184 /// false - throw an exception 00185 /// \return 00186 /// Returns an FdoSingleValue, whose value is converted from the src value. 00187 /// If src is an FdoBooleanValue: 00188 /// false is converted to 0 00189 /// true is converted to 1 00190 /// 00191 static FdoSingleValue* Create( 00192 FdoDataValue* src, 00193 FdoBoolean nullIfIncompatible = false, 00194 FdoBoolean shift = true, 00195 FdoBoolean truncate = false 00196 ); 00197 00198 // See FdoDataValue::DoCompare() 00199 virtual FdoCompareType DoCompare( FdoDataValue* other ); 00200 00201 float m_data; 00202 /// \endcond 00203 }; 00204 #endif 00205 00206