145 | | 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. |
146 | | |
147 | | src – specifies the source type and value. It is converted to an FdoDataValue of the destination type. |
148 | | |
149 | | nullIfIncompatible – determines what happens if the source and destination types are incompatible (e.g. pass FdoDataTimeValue as src to FdoBoolean::Create()): |
150 | | |
151 | | true: returns a null FdoDataValue (FdoDataValue::IsNull() = true) |
152 | | |
153 | | Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
154 | | |
155 | | false: throw an exception. |
156 | | |
157 | | 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: |
158 | | |
159 | | true: shift the value by rounding it to the precision allowed by the destination type |
160 | | false: depends on the value of nullIfIncompatible: |
161 | | |
162 | | true: return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
163 | | |
164 | | false: throw an exception |
165 | | |
166 | | 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: |
167 | | |
168 | | true: truncate the value to: |
169 | | |
170 | | the maximum value for the destination type if the input value is greater than the maximum value |
171 | | the minimum value for the destination type if the input value is less than the minimum value |
172 | | |
173 | | false: depends on the value of nullIfIncompatible: |
174 | | |
175 | | true: return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
176 | | |
177 | | false: throw an exception |
178 | | |
179 | | When the source type is numeric and the destination type is Boolean, the behaviour differs from the above and is as follows: |
180 | | |
181 | | true: convert 0 to false and other values to true |
182 | | false: convert 0 to false and 1 to true. Throw an exception for other values |
183 | | |
184 | | See the chart in the attached document for information on which pairs of types are compatible and which are incompatible. |
185 | | |
186 | | Supporting Functions ¶ |
187 | | The following function will be added: |
188 | | |
| 145 | '''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. |
| 146 | |
| 147 | '''src''' – specifies the source type and value. It is converted to an FdoDataValue of the destination type. |
| 148 | |
| 149 | '''nullIfIncompatible''' – determines what happens if the source and destination types are incompatible (e.g. pass FdoDateTimeValue as src to FdoBoolean::Create()): |
| 150 | |
| 151 | ''true'': returns a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
| 152 | |
| 153 | ''false'': throw an exception. |
| 154 | |
| 155 | '''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: |
| 156 | |
| 157 | ''true'': shift the value by rounding it to the precision allowed by the destination type |
| 158 | |
| 159 | ''false'': depends on the value of nullIfIncompatible: |
| 160 | |
| 161 | ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
| 162 | |
| 163 | ''false'': throw an exception |
| 164 | |
| 165 | '''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: |
| 166 | |
| 167 | ''true'': truncate the value to: |
| 168 | |
| 169 | the maximum value for the destination type if the input value is greater than the maximum value |
| 170 | |
| 171 | the minimum value for the destination type if the input value is less than the minimum value |
| 172 | |
| 173 | ''false'': depends on the value of nullIfIncompatible: |
| 174 | |
| 175 | ''true'': return a null FdoDataValue (FdoDataValue::IsNull() = true). Note that the pointer returned is not null, the FdoDataValue returned has its null flag set |
| 176 | |
| 177 | ''false'': throw an exception |
| 178 | |
| 179 | When the source type is numeric and the destination type is Boolean, the behaviour differs from the above and is as follows: |
| 180 | |
| 181 | ''true'': convert 0 to false and other values to true |
| 182 | |
| 183 | ''false'': convert 0 to false and 1 to true. Throw an exception for other values |
| 184 | |
| 185 | See the chart in the attached document for information on which pairs of types are compatible and which are incompatible. |
| 186 | |
| 187 | === Supporting Functions === |
| 188 | |
| 189 | The following functions will be added: |
| 190 | |
| 191 | {{{ |