Changes between Version 9 and Version 10 of FDORfc30
- Timestamp:
- 11/19/08 06:42:30 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FDORfc30
v9 v10 1 = FDO RFC 30 - Data Value Type Conversion =1 = FDO RFC 30 - Data Value Type Conversion = 2 2 3 3 This page contains a request for comments document (RFC) for the FDO Open Source project. … … 44 44 * more difficult for developers to find the type conversion functions currently available, since these can be in various places 45 45 46 Data values are encapsulated in the FdoDataValueclass and its derivations. There is a derivation for each data type supported by FDO. Example data types include various integer types (8bit, 16bit, 32bit, 64bit), string and datetime.47 48 The FdoDataValueclass effectively provides this type conversion now, by supporting the conversion from strings to other data types and vice-versa. For example, a double can be converted to an int32 by converting it to a string and then to an int32. However, providing a more direct conversion, without converting to and from strings, would provide better performance. It also allows very large or small values to be converted more accurately.46 Data values are encapsulated in the [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] class and its derivations. There is a derivation for each data type supported by FDO. Example data types include various integer types (8bit, 16bit, 32bit, 64bit), string and datetime. 47 48 The [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] class effectively provides this type conversion now, by supporting the conversion from strings to other data types and vice-versa. For example, a double can be converted to an int32 by converting it to a string and then to an int32. However, providing a more direct conversion, without converting to and from strings, would provide better performance. It also allows very large or small values to be converted more accurately. 49 49 50 50 It is also possible to convert between various numeric types through simple casting. However, this leads to source code with sizeable switch statements when converting between two arbitrary data types. … … 60 60 == Proposed Solution == 61 61 62 This RFC proposes that data type conversions be encapsulated in new API functions on the FdoDataValueclass.62 This RFC proposes that data type conversions be encapsulated in new API functions on the [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] class. 63 63 64 64 Direct conversion from a source to a destination type will be supported by adding Create functions to each destination type, which take a value of the source type as a parameter. … … 151 151 where: 152 152 153 '''dataType''' – specifies the destination type. This parameter is only specified for FdoDataValue::Create(). For the other functions, the destination type is determined by the return type.153 '''dataType''' – specifies the destination type. This parameter is only specified for [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue::Create()]. For the other functions, the destination type is determined by the return type. 154 154 155 155 '''src''' – specifies the source type and value. It is converted to an FdoDataValue of the destination type. 156 156 157 '''nullIfIncompatible''' – determines what happens if the source and destination types are incompatible (e.g. pass FdoDateTimeValue as src to FdoBoolean::Create()):158 159 ''true'': returns a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValuereturned has its null flag set157 '''nullIfIncompatible''' – determines what happens if the source and destination types are incompatible (e.g. pass [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DateTimeValue.h FdoDateTimeValue] as src to [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/BooleanValue.h FdoBooleanValue::Create()]): 158 159 ''true'': returns a null [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] ([http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue::IsNull()] = true). Note that the pointer returned is not null, the [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] returned has its null flag set 160 160 161 161 ''false'': throw an exception. … … 169 169 ''false'': depends on the value of nullIfIncompatible: 170 170 171 ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValuereturned has its null flag set171 ''true'': return a null [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] ([http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue::IsNull()] = true). Note that the pointer returned is not null, the [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] returned has its null flag set 172 172 173 173 ''false'': throw an exception 174 174 175 '''truncate''' – determines what happens if the value is outside the valid range for the destination type (e.g. convert 1000000 from FdoInt32Value to FdoInt16Value). Applicable only when both source and destination types are one of Boolean, Byte, Decimal, Double, Int16, Int32, Int64 or Single:175 '''truncate''' – determines what happens if the value is outside the valid range for the destination type (e.g. convert 1000000 from [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/Int32Value.h FdoInt32Value]to [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/Int16Value.h FdoInt16Value]). Applicable only when both source and destination types are one of Boolean, Byte, Decimal, Double, Int16, Int32, Int64 or Single: 176 176 177 177 ''true'': truncate the value to: … … 183 183 ''false'': depends on the value of nullIfIncompatible: 184 184 185 ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValuereturned has its null flag set185 ''true'': return a null [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] ([http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue::IsNull()] = true). Note that the pointer returned is not null, the [http://svn.osgeo.org/fdo/trunk/Fdo/Unmanaged/Inc/Fdo/Expression/DataValue.h FdoDataValue] returned has its null flag set 186 186 187 187 ''false'': throw an exception