Mantid
Loading...
Searching...
No Matches
ParseNumerics.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include <stdexcept>
9namespace MantidQt {
10namespace MantidWidgets {
11double parseDouble(QString const &in) {
12 static auto ok = false;
13 auto out = in.toDouble(&ok);
14 if (ok)
15 return out;
16 else
17 throw std::runtime_error("Failed to parse '" + in.toStdString() + "' as a double numerical value.");
18}
19
20int parseDenaryInteger(QString const &in) {
21 static auto ok = false;
22 auto constexpr BASE = 10;
23 auto out = in.toInt(&ok, BASE);
24 if (ok)
25 return out;
26 else
27 throw std::runtime_error("Failed to parse '" + in.toStdString() + "' as a denary integer.");
28}
29} // namespace MantidWidgets
30} // namespace MantidQt
int EXPORT_OPT_MANTIDQT_COMMON parseDenaryInteger(QString const &in)
Converts a string denoting a denary integer to it.
double EXPORT_OPT_MANTIDQT_COMMON parseDouble(QString const &in)
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...