17#include <seqan3/std/charconv>
25template <
typename number_t>
31 if (ec == std::errc::invalid_argument)
33 else if (ec == std::errc::result_out_of_range)
42 double integral_part{};
48 return static_cast<size_t>(value);
52 return static_cast<size_t>(value * 1000);
53 else if (unit ==
"Ki")
54 return static_cast<size_t>(value * 1024);
56 return static_cast<size_t>(value * 1000 * 1000);
57 else if (unit ==
"Mi")
58 return static_cast<size_t>(value * 1024 * 1024);
60 return static_cast<size_t>(value * 1000 * 1000 * 1000);
61 else if (unit ==
"Gi")
62 return static_cast<size_t>(value * 1024 * 1024 * 1024);
64 return static_cast<size_t>(value * 1000ULL * 1000ULL * 1000ULL * 1000ULL);
65 else if (unit ==
"Ti")
66 return static_cast<size_t>(value * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
68 return static_cast<size_t>(value * 1000ULL * 1000ULL * 1000ULL * 1000ULL * 1000ULL);
69 else if (unit ==
"Pi")
70 return static_cast<size_t>(value * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
72 return static_cast<size_t>(value * 1000ULL * 1000ULL * 1000ULL * 1000ULL * 1000ULL * 1000ULL);
73 else if (unit ==
"Ei")
74 return static_cast<size_t>(value * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL);
84 if (
auto const pos = input.
find_last_not_of(
' '); pos != std::string_view::npos)
93 if (input.contains(
'.'))
94 return detail::to_bytes_impl<double>(input);
96 return detail::to_bytes_impl<size_t>(input);
T find_first_not_of(T... args)
T find_last_not_of(T... args)
T remove_prefix(T... args)
T remove_suffix(T... args)