Get the value of a boolean descriptor.
| 1341 | |
| 1342 | // Get the value of a boolean descriptor. |
| 1343 | bool CVT_get_boolean(const dsc* desc, ErrorFunction err) |
| 1344 | { |
| 1345 | switch (desc->dsc_dtype) |
| 1346 | { |
| 1347 | case dtype_boolean: |
| 1348 | return *desc->dsc_address != '\0'; |
| 1349 | |
| 1350 | case dtype_varying: |
| 1351 | case dtype_cstring: |
| 1352 | case dtype_text: |
| 1353 | { |
| 1354 | VaryStr<TEMP_STR_LENGTH> buffer; // arbitrarily large |
| 1355 | const char* p = NULL; |
| 1356 | int len = CVT_make_string(desc, ttype_ascii, &p, &buffer, sizeof(buffer), 0, err); |
| 1357 | |
| 1358 | // Remove heading and trailing spaces. |
| 1359 | |
| 1360 | while (len > 0 && isspace((UCHAR) *p)) |
| 1361 | { |
| 1362 | ++p; |
| 1363 | --len; |
| 1364 | } |
| 1365 | |
| 1366 | while (len > 0 && isspace((UCHAR) p[len - 1])) |
| 1367 | --len; |
| 1368 | |
| 1369 | if (len == 4 && fb_utils::strnicmp(p, "TRUE", len) == 0) |
| 1370 | return true; |
| 1371 | else if (len == 5 && fb_utils::strnicmp(p, "FALSE", len) == 0) |
| 1372 | return false; |
| 1373 | |
| 1374 | // fall into |
| 1375 | } |
| 1376 | |
| 1377 | default: |
| 1378 | CVT_conversion_error(desc, err); |
| 1379 | return false; // silence warning |
| 1380 | } |
| 1381 | } |
| 1382 | |
| 1383 | |
| 1384 | double CVT_get_double(const dsc* desc, DecimalStatus decSt, ErrorFunction err, bool* getNumericOverflow) |
no test coverage detected