Skip to content

Commit 8ccf0ce

Browse files
committed
integer_from_json -> to_integer_unchecked
1 parent a8a402a commit 8ccf0ce

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/jsoncons/detail/parse_number.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace jsoncons { namespace detail {
2828
public:
2929
const char* name() const noexcept override
3030
{
31-
return "jsoncons/integer_from_json";
31+
return "jsoncons/to_integer_unchecked";
3232
}
3333
std::string message(int ev) const override
3434
{
@@ -39,7 +39,7 @@ namespace jsoncons { namespace detail {
3939
case to_integer_errc::invalid_digit:
4040
return "Invalid digit";
4141
default:
42-
return "Unknown integer_from_json error";
42+
return "Unknown to_integer_unchecked error";
4343
}
4444
}
4545
};
@@ -514,7 +514,7 @@ to_integer(const CharT* s, std::size_t length)
514514

515515
template <class T, class CharT>
516516
typename std::enable_if<std::is_integral<T>::value && !std::is_signed<T>::value,to_integer_result<T>>::type
517-
integer_from_json(const CharT* s, std::size_t length)
517+
to_integer_unchecked(const CharT* s, std::size_t length)
518518
{
519519
static_assert(std::numeric_limits<T>::is_specialized, "Integer type not specialized");
520520
JSONCONS_ASSERT(length > 0);
@@ -575,7 +575,7 @@ integer_from_json(const CharT* s, std::size_t length)
575575

576576
template <class T, class CharT>
577577
typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value,to_integer_result<T>>::type
578-
integer_from_json(const CharT* s, std::size_t length)
578+
to_integer_unchecked(const CharT* s, std::size_t length)
579579
{
580580
static_assert(std::numeric_limits<T>::is_specialized, "Integer type not specialized");
581581
JSONCONS_ASSERT(length > 0);

include/jsoncons/json_parser.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2579,7 +2579,7 @@ class basic_json_parser : public ser_context
25792579

25802580
void end_negative_value(basic_json_visitor<CharT>& visitor, std::error_code& ec)
25812581
{
2582-
auto result = jsoncons::detail::integer_from_json<int64_t>(string_buffer_.data(), string_buffer_.length());
2582+
auto result = jsoncons::detail::to_integer_unchecked<int64_t>(string_buffer_.data(), string_buffer_.length());
25832583
if (result)
25842584
{
25852585
more_ = visitor.int64_value(result.value(), semantic_tag::none, *this, ec);
@@ -2593,7 +2593,7 @@ class basic_json_parser : public ser_context
25932593

25942594
void end_positive_value(basic_json_visitor<CharT>& visitor, std::error_code& ec)
25952595
{
2596-
auto result = jsoncons::detail::integer_from_json<uint64_t>(string_buffer_.data(), string_buffer_.length());
2596+
auto result = jsoncons::detail::to_integer_unchecked<uint64_t>(string_buffer_.data(), string_buffer_.length());
25972597
if (result)
25982598
{
25992599
more_ = visitor.uint64_value(result.value(), semantic_tag::none, *this, ec);

tests/src/json_as_tests.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ TEST_CASE("json::as<__int128>()")
102102
{
103103
std::string s = "-18446744073709551617";
104104

105-
jsoncons::detail::to_integer_result<__int128> result = jsoncons::detail::integer_from_json<__int128>(s.data(),s.size());
105+
jsoncons::detail::to_integer_result<__int128> result = jsoncons::detail::to_integer_unchecked<__int128>(s.data(),s.size());
106106
REQUIRE(result);
107107

108108
jsoncons::json j(s);
@@ -115,7 +115,7 @@ TEST_CASE("json::as<unsigned __int128>()")
115115
{
116116
std::string s = "18446744073709551616";
117117

118-
jsoncons::detail::to_integer_result<unsigned __int128> result = jsoncons::detail::integer_from_json<unsigned __int128>(s.data(),s.size());
118+
jsoncons::detail::to_integer_result<unsigned __int128> result = jsoncons::detail::to_integer_unchecked<unsigned __int128>(s.data(),s.size());
119119
REQUIRE(result);
120120

121121
jsoncons::json j(s);

0 commit comments

Comments
 (0)