| 760 | } |
| 761 | |
| 762 | bool DataValue::toBool() const |
| 763 | { |
| 764 | if (value_type_ != STRING_VALUE) |
| 765 | { |
| 766 | throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, |
| 767 | "Could not convert non-string DataValue of type '" + NamesOfDataType[value_type_] + "' and value '" + this->toString(true) + "' to bool"); |
| 768 | } |
| 769 | else if (*(data_.str_) != "true" && *(data_.str_) != "false") |
| 770 | { |
| 771 | throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, |
| 772 | String("Could not convert non-string DataValue of type '") + NamesOfDataType[value_type_] + |
| 773 | "' and value '" + *(data_.str_) + "' to bool. Valid stings are 'true' and 'false'."); |
| 774 | } |
| 775 | |
| 776 | return *(data_.str_) == "true"; |
| 777 | } |
| 778 | |
| 779 | // ----------------- Comparator ---------------------- |
| 780 | |