From be551a1b3c324dc96750cf992b6a5784e2b92ec7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 25 Aug 2018 11:32:46 +0000 Subject: Number format checking in strict mode. Also fixes #149 --- src/mathfunc.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mathfunc.cpp') diff --git a/src/mathfunc.cpp b/src/mathfunc.cpp index 9076c47..7117700 100644 --- a/src/mathfunc.cpp +++ b/src/mathfunc.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,14 @@ bool has_inf(const gsl_matrix *m) { return false; } +bool is_integer(const std::string & s){ + return std::regex_match(s, std::regex("^[0-9]+$")); +} + +bool is_float(const std::string & s){ + return std::regex_match(s, std::regex("^[+-]?([0-9]*[.])?[0-9]+$")); +} + // calculate variance of a vector double VectorVar(const gsl_vector *v) { double d, m = 0.0, m2 = 0.0; -- cgit v1.2.3