Changes between Version 9 and Version 10 of FDORfc30


Ignore:
Timestamp:
11/19/08 06:42:30 (16 years ago)
Author:
brentrobinson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc30

    v9 v10  
    1 = FDO RFC 30 - DataValue Type Conversion =
     1= FDO RFC 30 - Data Value Type Conversion =
    22
    33This page contains a request for comments document (RFC) for the FDO Open Source project. 
     
    4444 * more difficult for developers to find the type conversion functions currently available, since these can be in various places
    4545
    46 Data values are encapsulated in the 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 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.
     46Data 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
     48The [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.
    4949
    5050It 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.
     
    6060== Proposed Solution ==
    6161
    62 This RFC proposes that data type conversions be encapsulated in new API functions on the FdoDataValue class.
     62This 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.
    6363
    6464Direct 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.
     
    151151where:
    152152
    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.
    154154
    155155 '''src''' – specifies the source type and value. It is converted to an FdoDataValue of the destination type.
    156156
    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 FdoDataValue returned has its null flag set
     157 '''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
    160160
    161161  ''false'': throw an exception.
     
    169169  ''false'': depends on the value of nullIfIncompatible:
    170170
    171    ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set
     171   ''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
    172172
    173173   ''false'': throw an exception
    174174
    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:
    176176
    177177  ''true'': truncate the value to:
     
    183183  ''false'': depends on the value of nullIfIncompatible:
    184184 
    185    ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set
     185   ''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
    186186
    187187   ''false'': throw an exception