| 106 | |
| 107 | where: |
| 108 | |
| 109 | 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. |
| 110 | |
| 111 | src – specifies the source type and value. It is converted to an !FdoDataValue of the destination type. |
| 112 | |
| 113 | shift – 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 | |
| 119 | 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: |
| 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 | |
| 126 | When 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 | |
| 132 | nullIfIncompatible – 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 | |
| 139 | See the chart in the attached document for information on which pairs of types are compatible and which are incompatible. |
| 140 | |
| 141 | There 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 | |
| 145 | The following function will be added: |
| 146 | |
| 147 | {{{ |
| 148 | FDO_API FdoInt64 FdoStringP::ToInt64() |
| 149 | }}} |
| 150 | |
| 151 | which converts a string to int64 value, and |
| 152 | |
| 153 | {{{ |
| 154 | FDO_API FdoStringP::FdoStringP( FdoInt64 value ) |
| 155 | }}} |
| 156 | |
| 157 | to convert an int64 to string. These functions hide the Win32 and Linux specific differences in doing these conversions. |
| 158 | |