diff options
Diffstat (limited to 'pseudocode-lib/_exp_string.cc')
| -rw-r--r-- | pseudocode-lib/_exp_string.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pseudocode-lib/_exp_string.cc b/pseudocode-lib/_exp_string.cc index ae53ac1..4cfd650 100644 --- a/pseudocode-lib/_exp_string.cc +++ b/pseudocode-lib/_exp_string.cc @@ -1,6 +1,7 @@ #include <algorithm> #include <cctype> #include <cstdio> +#include <cstdlib> #include <exception> #include <stdexcept> #include <string> @@ -127,6 +128,14 @@ void _exp_string_impl_chr(void *Target, long long Code) { text(Target).assign(1, static_cast<char>(static_cast<unsigned char>(Code))); }); } +int _exp_string_impl_is_num(void *Handle) { + return checked([&]() -> int { + const auto &Source = text(Handle); + char *End = nullptr; + std::strtod(Source.c_str(), &End); + return !Source.empty() && End == Source.c_str() + Source.size(); + }); +} void _exp_string_impl_output(void *Handle) { checked([&] { const auto &Text = text(Handle); |
