aboutsummaryrefslogtreecommitdiff
path: root/src/conversion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversion.cpp')
-rw-r--r--src/conversion.cpp33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/conversion.cpp b/src/conversion.cpp
deleted file mode 100644
index 078d66b..0000000
--- a/src/conversion.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "conversion.hpp"
-
-#include <climits>
-#include <stdexcept>
-
-auto str_to_uint(const std::string_view &str) noexcept -> ConversionResult<uint32_t>
-{
- if (!ctre::match<IS_VALID_UINT>(str))
- {
- return ConversionResult(false, 0U, "Not a number");
- }
-
- if (!ctre::match<IS_UINT_IN_RANGE>(str))
- {
- return ConversionResult(false, 0U, "Out of range");
- }
-
- std::size_t waste_pos = 0;
-
- auto num = std::stoul(str.data(), &waste_pos, NUMBER_BASE);
-
- if (waste_pos != str.length())
- {
- return ConversionResult(false, 0U, "Not a number");
- }
-
- if (num > UINT_MAX)
- {
- return ConversionResult(false, 0U, "Out of range");
- }
-
- return ConversionResult(true, static_cast<uint32_t>(num));
-}