12 const QString trimmed = text.trimmed();
13 if (trimmed.isEmpty())
15 error = QStringLiteral(
"the cell is empty");
20 static const QRegularExpression
number(
21 QStringLiteral(
"^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$"));
22 if (!
number.match(trimmed).hasMatch())
24 static const QRegularExpression non_finite(
25 QStringLiteral(
"^[+-]?(nan|inf|infinity)$"), QRegularExpression::CaseInsensitiveOption);
26 static const QRegularExpression comma_number(QStringLiteral(
"^[+-]?\\d*,\\d+$"));
27 if (non_finite.match(trimmed).hasMatch())
28 error = QStringLiteral(
"'%1' is not a finite number").arg(trimmed);
29 else if (comma_number.match(trimmed).hasMatch())
30 error = QStringLiteral(
"'%1' is not a number; use a point as the decimal separator "
31 "and no thousands separator").arg(trimmed);
33 error = QStringLiteral(
"'%1' is not a number").arg(trimmed);
38 const double value = trimmed.toDouble(&ok);
39 if (!ok || !std::isfinite(value))
41 error = QStringLiteral(
"'%1' is too large to represent").arg(trimmed);