* Global function to convert from a string to an integer. This function is * preferred over the QString::toInt() method since this function will throw an * IException if the conversion is unsuccessful. * * @param string QString to be converted to an integer. * @return The integer equivalent to the string */
| 92 | * @return The integer equivalent to the string |
| 93 | */ |
| 94 | int toInt(const QString &string) { |
| 95 | bool ok = true; |
| 96 | |
| 97 | int result = string.toInt(&ok); |
| 98 | |
| 99 | if (!ok) { |
| 100 | QString message = QObject::tr("Failed to convert string [%1] to an integer").arg(string); |
| 101 | throw IException(IException::Unknown, message, _FILEINFO_); |
| 102 | } |
| 103 | |
| 104 | return result; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /** |