7#include <initializer_list>
10#include <system_error>
25 static_assert(std::is_arithmetic_v<T> && !std::is_same_v<T, bool>,
"parseNumber needs a number type");
31 text.remove_prefix(1);
33 text.remove_prefix(2);
37 std::from_chars_result result{};
38 if constexpr (std::is_integral_v<T>)
43 if (result.ec != std::errc() || result.ptr !=
last)
52 for (
const std::string_view
yes : {
"true",
"yes",
"on",
"1"})
55 for (
const std::string_view
no : {
"false",
"no",
"off",
"0"})
String helpers: case, trimming, splitting, joining, replacing, parsing and hashing.
Definition Char.hpp:3
constexpr std::optional< bool > parseBool(std::string_view text) noexcept
Parses true, yes, on, 1 or false, no, off, 0, ignoring case.
Definition Convert.hpp:49
constexpr std::string_view trimView(std::string_view str, std::string_view chars=Whitespace) noexcept
Definition Trim.hpp:31
constexpr bool equalsIgnoreCase(std::string_view lhs, std::string_view rhs) noexcept
Definition Compare.hpp:15
std::optional< T > parseNumber(std::string_view text, int base=10) noexcept
Parses text as a number, or returns std::nullopt if it is not entirely one.
Definition Convert.hpp:23