• Main Page
  • Modules
  • Classes
  • Files
  • File List
  • File Members

DecimalValue.h

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