FDO API Reference Feature Data Objects
Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

DataValue.h

Go to the documentation of this file.
00001 #ifndef _DATAVALUE_H_
00002 #define _DATAVALUE_H_
00003 // 
00004 
00005 //
00006 // Copyright (C) 2004-2007  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/LiteralValue.h>
00028 #include <Fdo/Schema/DataType.h>
00029 
00030 /// \brief
00031 /// The FdoDataValue class derives from FdoLiteralValue and represents a literal
00032 /// value such as a string or a number.
00033 class FdoDataValue : public FdoLiteralValue
00034 {
00035 /// \cond DOXYGEN-IGNORE
00036     friend class FdoInternalDataValue;
00037     friend class FdoByteValue;
00038     friend class FdoDecimalValue;
00039     friend class FdoDoubleValue;
00040     friend class FdoInt16Value;
00041     friend class FdoInt32Value;
00042     friend class FdoInt64Value;
00043     friend class FdoSingleValue;
00044 protected:
00045     /// \brief
00046     ///  Constructs a default instance of an FdoDataValue with data type string and a
00047     /// value of null.
00048     /// 
00049     /// \return
00050     /// Returns nothing
00051     /// 
00052     FdoDataValue();
00053 /// \endcond
00054 
00055 public:
00056     /// \brief
00057     /// Constructs an instance of a null FdoDataValue using the specified arguments.
00058     /// 
00059     /// \param dataType 
00060     /// Input data type
00061     /// 
00062     /// \return
00063     /// Returns nothing
00064     /// 
00065     FDO_API static FdoDataValue* Create(FdoDataType dataType);
00066 
00067     /// \brief
00068     /// Constructs an instance of an FdoBooleanValue using the specified argument.
00069     /// 
00070     /// \param value 
00071     /// Input a Boolean value
00072     /// 
00073     /// \return
00074     /// Returns an FdoBooleanValue
00075     /// 
00076     FDO_API static FdoDataValue* Create(bool value);
00077 
00078     /// \brief
00079     /// Constructs an instance of an FdoByteValue using the specified argument.
00080     /// 
00081     /// \param value 
00082     /// Input a byte
00083     /// 
00084     /// \return
00085     /// Returns an FdoByteValue
00086     /// 
00087     FDO_API static FdoDataValue* Create(FdoByte value);
00088 
00089     /// \brief
00090     /// Constructs an instance of an FdoDateTimeValue using the specified argument.
00091     /// 
00092     /// \param value 
00093     /// Input a FdoDateTime
00094     /// 
00095     /// \return
00096     /// Returns an FdoDateTimeValue
00097     /// 
00098     FDO_API static FdoDataValue* Create(FdoDateTime value);
00099 
00100     /// \brief
00101     /// Constructs an instance of an FdoDecimalValue or FdoDoubleValue using 
00102     /// the specified arguments.
00103     /// 
00104     /// \param value 
00105     /// Input a double
00106     /// \param dataType 
00107     /// Input a data type
00108     /// 
00109     /// \return
00110     /// Returns an FdoDecimalValue or FdoDoubleValue
00111     /// 
00112     FDO_API static FdoDataValue* Create(double value, FdoDataType dataType);
00113 
00114     /// \brief
00115     /// Constructs an instance of an FdoInt16Value using the specified argument.
00116     /// 
00117     /// \param value 
00118     /// Input a 16 bit integer
00119     /// 
00120     /// \return
00121     /// Returns an FdoInt16Value
00122     /// 
00123     FDO_API static FdoDataValue* Create(FdoInt16 value);
00124 
00125     /// \brief
00126     /// Constructs an instance of an FdoInt32Value using the specified argument.
00127     /// 
00128     /// \param value 
00129     /// Input a 32 bit integer
00130     /// 
00131     /// \return
00132     /// Returns an FdoInt32Value
00133     /// 
00134     FDO_API static FdoDataValue* Create(FdoInt32 value);
00135 
00136     /// \brief
00137     /// Constructs an instance of an FdoInt64Value using the specified argument.
00138     /// 
00139     /// \param value 
00140     /// Input a 64 bit integer
00141     /// 
00142     /// \return
00143     /// Returns an FdoInt64Value
00144     /// 
00145     FDO_API static FdoDataValue* Create(FdoInt64 value);
00146 
00147     /// \brief
00148     /// Constructs an instance of an FdoSingleValue using the specified argument.
00149     /// 
00150     /// \param value 
00151     /// Input a single precision floating point value
00152     /// 
00153     /// \return
00154     /// Returns an FdoSingleValue
00155     /// 
00156     FDO_API static FdoDataValue* Create(float value);
00157 
00158     /// \brief
00159     /// Constructs an instance of an FdoStringValue using the specified argument.
00160     /// 
00161     /// \param value 
00162     /// Input a character string
00163     /// 
00164     /// \return
00165     /// Returns an FdoStringValue
00166     /// 
00167     FDO_API static FdoDataValue* Create(FdoString* value);
00168 
00169     /// \brief
00170     /// Constructs an instance of an FdoBLOBValue or FdoCLOBValue using the specified arguments.
00171     /// 
00172     /// \param value 
00173     /// Input a byte array
00174     /// \param length 
00175     /// Input the length of the byte array
00176     /// \param dataType 
00177     /// Input the type of value to create
00178     /// 
00179     /// \return
00180     /// Returns an FdoBLOBValue or an FdoCLOBValue
00181     /// 
00182     FDO_API static FdoDataValue* Create(FdoByte* value, FdoInt32 length, FdoDataType dataType);
00183 
00184     /// \brief
00185     /// Constructs an instance of an FdoBLOBValue or FdoCLOBValue using the specified arguments.
00186     /// 
00187     /// \param value 
00188     /// Input a byte array
00189     /// \param dataType 
00190     /// Input the type of value to create
00191     /// 
00192     /// \return
00193     /// Returns an FdoBLOBValue or an FdoCLOBValue
00194     /// 
00195     FDO_API static FdoDataValue* Create(FdoByteArray* value, FdoDataType dataType);
00196 
00197     /// \brief
00198     /// Gets the data type of the FdoDataValue.
00199     /// 
00200     /// \return
00201     /// Returns an FdoDataType
00202     /// 
00203     FDO_API virtual FdoDataType GetDataType() = 0;
00204 
00205     /// \brief
00206     /// Returns true if the FdoDataValue represents a null value.
00207     /// 
00208     /// \return
00209     /// Returns true if the FdoDataValue represents a null value
00210     /// 
00211     FDO_API virtual bool IsNull();
00212 
00213     /// \brief
00214     /// Sets the FdoDataValue to a null value of the specified type.
00215     /// 
00216     /// \return
00217     /// Returns nothing
00218     /// 
00219     FDO_API virtual void SetNull();
00220 
00221     /// \brief
00222     /// Gets the literal value type of the FdoDataValue.
00223     /// 
00224     /// \return
00225     /// Returns an FdoLiteralValueType
00226     /// 
00227     FDO_API virtual FdoLiteralValueType GetLiteralValueType () const;
00228 
00229     static FdoDataValue* Create(FdoString* value, FdoDataType dataType);
00230 
00231     // Get the value as an XML format string.
00232     FdoString* GetXmlValue();
00233 
00234 /// \cond DOXYGEN-IGNORE
00235 protected:
00236     /// \brief
00237     /// Compares this data value with another data value
00238     /// 
00239     /// \param other 
00240     /// Input the other data value
00241     /// 
00242     /// \return
00243     /// Returns:
00244     ///     FdoCompareType_Equal when this and the other value are equal or both null.
00245     ///     FdoCompareType_Greater when this value is greater than the other value
00246     ///     FdoCompareType_Less when this value is less than the other value
00247     ///     FdoCompareType_Undefined when these two values cannot be compared. Cases where this happens
00248     ///      are:
00249     ///         - one value is null and the other is not null
00250     ///         - the values have incompatible types (e.g. Int32 and DateTime).
00251     ///         
00252     /// 
00253     FdoCompareType Compare( FdoDataValue* other );
00254 
00255     // ReverseCompare is the same as Compare except for two of the return values:
00256     ///     FdoCompareType_Greater when the other value is greater than this value
00257     ///     FdoCompareType_Less when the other value is less than this value
00258     FdoCompareType ReverseCompare( FdoDataValue* other );
00259 
00260     /// \brief
00261     /// Type-specific comparison function. Each sub-class has its own implementation.
00262     /// 
00263     /// \param other 
00264     /// Input the other data value
00265     /// 
00266     /// \return
00267     /// Returns:
00268     ///     FdoCompareType_Equal when this and the other value are equal or both null.
00269     ///     FdoCompareType_Greater when this value is greater than the other value
00270     ///     FdoCompareType_Less when this value is less than the other value
00271     ///     FdoCompareType_Undefined when these two values cannot be compared. Cases where this happens
00272     ///      are:
00273     ///         - one value is null and the other is not null
00274     ///         - the values have incompatible types (e.g. Int32 and DateTime).
00275     ///
00276     ///     Base implementation always returns FdoCompareType_Undefined.
00277     ///         
00278     /// 
00279     virtual FdoCompareType DoCompare( FdoDataValue* other );
00280 
00281     bool        m_isNull;
00282     FdoStringP  m_XmlValue; // Manages GetXmlValue return string when datatype is datetime.
00283 /// \endcond
00284 
00285 };
00286 
00287 /// \ingroup (typedefs)
00288 /// \brief
00289 /// FdoDataValueP is a FdoPtr on FdoDataValue, provided for convenience.
00290 typedef FdoPtr<FdoDataValue> FdoDataValueP;
00291 
00292 #endif
00293 
00294 

Comments or suggestions? Send us feedback.