mirror of
https://github.com/boostorg/charconv.git
synced 2026-02-03 09:02:11 +00:00
Refactor detail namespace
This commit is contained in:
@@ -14,6 +14,30 @@
|
||||
|
||||
namespace boost { namespace charconv { namespace detail {
|
||||
|
||||
static constexpr std::array<unsigned char, 256> uchar_values =
|
||||
{{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255,
|
||||
255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 255, 255, 255, 255, 255,
|
||||
255, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}};
|
||||
|
||||
// Convert characters for 0-9, A-Z, a-z to 0-35. Anything else is 255
|
||||
inline unsigned char digit_from_char(char val) noexcept
|
||||
{
|
||||
return uchar_values[static_cast<std::size_t>(val)];
|
||||
}
|
||||
|
||||
template <typename Integer, typename std::enable_if<std::is_signed<Integer>::value, bool>::type = true>
|
||||
inline Integer apply_sign(Integer val) noexcept
|
||||
{
|
||||
@@ -26,10 +50,8 @@ inline Integer apply_sign(Integer val) noexcept
|
||||
return val;
|
||||
}
|
||||
|
||||
}}} // Namespaces
|
||||
|
||||
template <typename Integer, typename std::enable_if<std::is_integral<Integer>::value, bool>::type>
|
||||
boost::charconv::from_chars_result boost::charconv::detail::from_chars(const char* first, const char* last, Integer& value, int base) noexcept
|
||||
template <typename Integer, typename std::enable_if<std::is_integral<Integer>::value, bool>::type = true>
|
||||
boost::charconv::from_chars_result from_chars_impl(const char* first, const char* last, Integer& value, int base) noexcept
|
||||
{
|
||||
using Unsigned_Integer = typename std::make_unsigned<Integer>::type;
|
||||
Unsigned_Integer result = 0;
|
||||
@@ -126,52 +148,54 @@ boost::charconv::from_chars_result boost::charconv::detail::from_chars(const cha
|
||||
return {next, 0};
|
||||
}
|
||||
|
||||
}}} // Namespace boost::charconv::detail
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, char& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, unsigned char& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, short& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, unsigned short& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, int& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, unsigned int& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, long& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, unsigned long& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, long long& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
boost::charconv::from_chars_result boost::charconv::from_chars(const char* first, const char* last, unsigned long long& value, int base) noexcept
|
||||
{
|
||||
return boost::charconv::detail::from_chars(first, last, value, base);
|
||||
return boost::charconv::detail::from_chars_impl(first, last, value, base);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user