MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / parser_isValidReal

Function parser_isValidReal

quest/src/core/parser.cpp:212–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211
212bool parser_isValidReal(string str) {
213
214 // reject str if it doesn't match regex
215 if (!parser_isAnySizedReal(str))
216 return false;
217
218 // check number is in-range of qreal via duck-typing
219 try {
220 precisionAgnosticStringToFloat(str);
221 } catch (const out_of_range&) {
222 return false;
223
224 // error if our regex permitted an unparsable string
225 } catch (const invalid_argument&) {
226 error_attemptedToParseRealFromInvalidString();
227 }
228
229 return true;
230}
231
232
233qreal parser_parseReal(string str) {

Tested by

no test coverage detected