aboutsummaryrefslogtreecommitdiff
path: root/src/debug.h
diff options
context:
space:
mode:
authorPjotr Prins2018-08-25 11:32:46 +0000
committerPjotr Prins2018-08-25 11:32:46 +0000
commitbe551a1b3c324dc96750cf992b6a5784e2b92ec7 (patch)
tree01830a02558f85b33fcb6ce7d54d1daab28ca669 /src/debug.h
parenta24297bb1cb686d3630db3a0da8fa8a2079ad178 (diff)
downloadpangemma-be551a1b3c324dc96750cf992b6a5784e2b92ec7.tar.gz
Number format checking in strict mode. Also fixes #149
Diffstat (limited to 'src/debug.h')
-rw-r--r--src/debug.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/debug.h b/src/debug.h
index ced8e72..b08d75d 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -147,6 +147,12 @@ inline void __enforce_fail(const char *__assertion, const char *__file,
? __ASSERT_VOID_CAST(0) \
: __enforce_fail((msg).c_str(), __FILE__, __LINE__, __SHOW_FUNC))
+#define enforce_is_int(s) \
+ enforce_str(std::regex_match(s, std::regex("^[-+]?[0-9]+$")),s + " not an integer")
+
+#define enforce_is_float(s) \
+ enforce_str(std::regex_match(s, std::regex("^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$")),s + " not a float")
+
// Helpers to create a unique varname per MACRO
#define COMBINE1(X, Y) X##Y
#define COMBINE(X, Y) COMBINE1(X, Y)