aboutsummaryrefslogtreecommitdiff
path: root/src/conversion.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-06-02 20:11:29 +0200
committerHampusM <hampus@hampusmat.com>2022-06-13 17:57:00 +0200
commit2d8e52e59af27fc68f4ff5b63d1b53e8d6d4c043 (patch)
treee00b263afb9f3ef7356ec755b60ce03062110628 /src/conversion.cpp
parentcf3bfd60ad03f2feb2ccc62a12fc2922bdc2fb71 (diff)
refactor: remove conversion & ctre dependency
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));
-}