Changes between Version 2 and Version 3 of FdoDataValueTypeConversion


Ignore:
Timestamp:
Oct 17, 2007, 3:17:11 PM (17 years ago)
Author:
gregboone
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FdoDataValueTypeConversion

    v2 v3  
    22== FDO !DataValue Type Conversions ==
    33
    4 == Overview ==
     4=== Overview ===
    55
    66There are a number of places in core FDO and Provider source code where data values are converted from one type to another. These data values include property values for features and property constraint values. Also, as various FDO client applications are written, some of them may also need to do data type conversion. 
     
    104104 );
    105105}}}
     106
     107where:
     108
     109dataType – 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.
     110
     111src – specifies the source type and value. It is converted to an !FdoDataValue of the destination type.
     112
     113shift – determines what happens if conversion would cause the value to change. This can happen when converting between numeric types and the destination type does not have enough precision to hold the value as is (e.g convert 1.9 from Double to Int32 ). Applicable only when both source and destination types are one of Byte, Decimal, Double, Int16, Int32, Int64 or Single:
     114
     115      true: shift the value by rounding it to the precision allowed by the destination type[[br]]
     116      false: throw an exception[[br]]
     117
     118
     119truncate – 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:
     120
     121      true: truncate the value to:
     122              the maximum value for the destination type if the input value is greater than the maximum value[[br]]
     123              the minimum value for the destination type if the input value is less than the minimum value[[br]]
     124      false: throw an exception[[br]]
     125
     126When the source type is numeric and the destination type is Boolean, the behaviour differs from the above and is as follows:
     127
     128      true: convert 0 to false and other values to true[[br]]
     129      false: convert 0 to false and 1 to true. Throw an exception for other values[[br]]
     130
     131
     132nullIfIncompatible – determines what happens if the source and destination types are incompatible (e.g. pass !FdoDataTimeValue as src to FdoBoolean::Create()):
     133
     134      true: returns a null !FdoDataValue (FdoDataValue::!IsNull() = true)[[br]]
     135             Note that the pointer returned is not null, the !FdoDataValue returned has its null flag set[[br]]
     136
     137      false: throw an exception.
     138
     139See the chart in the attached document for information on which pairs of types are compatible and which are incompatible.
     140
     141There are no new functions for converting from other types to Strings. This can already be done by the FdoDataValue::!ToString() function.
     142
     143==== Supporting Functions ====
     144
     145The following function will be added:
     146
     147{{{
     148FDO_API FdoInt64 FdoStringP::ToInt64()
     149}}}
     150
     151which converts a string to int64 value, and
     152
     153{{{
     154FDO_API FdoStringP::FdoStringP( FdoInt64 value )
     155}}}
     156 
     157to convert an int64 to string. These functions hide the Win32 and Linux specific differences in doing these conversions.
     158