Skip to content

Commit 47588e0

Browse files
committed
to_number.hpp -> read_number.hpp
1 parent e7d5246 commit 47588e0

File tree

18 files changed

+48
-48
lines changed

18 files changed

+48
-48
lines changed

include/jsoncons/basic_json.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3512,7 +3512,7 @@ namespace jsoncons {
35123512
}
35133513
else
35143514
{
3515-
auto result = jsoncons::utility::to_double(as_cstring(), as_string_view().length(), x);
3515+
auto result = jsoncons::utility::decstr_to_double(as_cstring(), as_string_view().length(), x);
35163516
if (result.ec == std::errc::invalid_argument)
35173517
{
35183518
JSONCONS_THROW(json_runtime_error<std::invalid_argument>("Not a double"));

include/jsoncons/json_parser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <vector>
2020

2121
#include <jsoncons/config/compiler_support.hpp>
22-
#include <jsoncons/utility/to_number.hpp>
22+
#include <jsoncons/utility/read_number.hpp>
2323
#include <jsoncons/json_error.hpp>
2424
#include <jsoncons/json_exception.hpp>
2525
#include <jsoncons/json_filter.hpp>
@@ -2466,7 +2466,7 @@ class basic_json_parser : public ser_context
24662466
else
24672467
{
24682468
double d{0};
2469-
auto result = jsoncons::utility::to_double(&string_buffer_[0], string_buffer_.length(), d);
2469+
auto result = jsoncons::utility::decstr_to_double(&string_buffer_[0], string_buffer_.length(), d);
24702470
if (JSONCONS_LIKELY(result))
24712471
{
24722472
visitor.double_value(d, semantic_tag::none, *this, ec);

include/jsoncons/staj_event.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class basic_staj_event
443443
case staj_event_type::string_value:
444444
{
445445
double val{0};
446-
jsoncons::utility::to_double(value_.string_data_, length_, val);
446+
jsoncons::utility::decstr_to_double(value_.string_data_, length_, val);
447447
return val;
448448
}
449449
case staj_event_type::double_value:

include/jsoncons/utility/to_number.hpp renamed to include/jsoncons/utility/read_number.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
// See https://github.com/danielaparker/jsoncons for latest version
66

7-
#ifndef JSONCONS_UTILITY_TO_NUMBER_HPP
8-
#define JSONCONS_UTILITY_TO_NUMBER_HPP
7+
#ifndef JSONCONS_UTILITY_READ_NUMBER_HPP
8+
#define JSONCONS_UTILITY_READ_NUMBER_HPP
99

1010
#include <cctype>
1111
#include <cstddef>
@@ -743,11 +743,11 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
743743
return to_number_result<CharT>(s, std::errc());
744744
}
745745

746-
// to_double
746+
// decstr_to_double
747747

748748
#if defined(JSONCONS_HAS_STD_FROM_CHARS)
749749

750-
inline to_number_result<char> to_double(const char* s, std::size_t length, double& val)
750+
inline to_number_result<char> decstr_to_double(const char* s, std::size_t length, double& val)
751751
{
752752
const char* cur = s+length;
753753
const auto res = std::from_chars(s, cur, val);
@@ -758,7 +758,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
758758
return to_number_result<char>{res.ptr,res.ec};
759759
}
760760

761-
inline to_number_result<wchar_t> to_double(const wchar_t* s, std::size_t length, double& val)
761+
inline to_number_result<wchar_t> decstr_to_double(const wchar_t* s, std::size_t length, double& val)
762762
{
763763
std::string buf(length,'0');
764764
for (size_t i = 0; i < length; ++i)
@@ -776,7 +776,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
776776

777777
#elif defined(JSONCONS_HAS_MSC_STRTOD_L)
778778

779-
inline to_number_result<char> to_double(const char* s, std::size_t length, double& val)
779+
inline to_number_result<char> decstr_to_double(const char* s, std::size_t length, double& val)
780780
{
781781
static _locale_t locale = _create_locale(LC_NUMERIC, "C");
782782

@@ -794,7 +794,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
794794
return to_number_result<char>{end};
795795
}
796796

797-
inline to_number_result<wchar_t> to_double(const wchar_t* s, std::size_t length, double& val)
797+
inline to_number_result<wchar_t> decstr_to_double(const wchar_t* s, std::size_t length, double& val)
798798
{
799799
static _locale_t locale = _create_locale(LC_NUMERIC, "C");
800800

@@ -815,7 +815,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
815815

816816
#elif defined(JSONCONS_HAS_STRTOLD_L)
817817

818-
inline to_number_result<char> to_double(const char* s, std::size_t length, double& val)
818+
inline to_number_result<char> decstr_to_double(const char* s, std::size_t length, double& val)
819819
{
820820
locale_t locale = newlocale(LC_ALL_MASK, "C", (locale_t) 0);
821821

@@ -833,7 +833,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
833833
return to_number_result<char>{end};
834834
}
835835

836-
inline to_number_result<wchar_t> to_double(const wchar_t* s, std::size_t length, double& val)
836+
inline to_number_result<wchar_t> decstr_to_double(const wchar_t* s, std::size_t length, double& val)
837837
{
838838
locale_t locale = newlocale(LC_ALL_MASK, "C", (locale_t) 0);
839839

@@ -853,7 +853,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
853853

854854
#else
855855

856-
inline to_number_result<char> to_double(const char* s, std::size_t length, double& val)
856+
inline to_number_result<char> decstr_to_double(const char* s, std::size_t length, double& val)
857857
{
858858
const char* cur = s+length;
859859
char *end = nullptr;
@@ -882,7 +882,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
882882
return to_number_result<char>{str_end};
883883
}
884884

885-
inline to_number_result<wchar_t> to_double(const wchar_t* s, std::size_t length, double& val)
885+
inline to_number_result<wchar_t> decstr_to_double(const wchar_t* s, std::size_t length, double& val)
886886
{
887887
const wchar_t* cur = s+length;
888888
wchar_t *end = nullptr;
@@ -911,7 +911,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
911911
return to_number_result<wchar_t>{str_end};
912912
}
913913

914-
inline to_number_result<char> to_double(char* s, std::size_t length)
914+
inline to_number_result<char> decstr_to_double(char* s, std::size_t length)
915915
{
916916
char* cur = s+length;
917917
char *end = nullptr;
@@ -937,7 +937,7 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
937937
return to_number_result<char>{end};
938938
}
939939

940-
inline to_number_result<wchar_t> to_double(wchar_t* s, std::size_t length)
940+
inline to_number_result<wchar_t> decstr_to_double(wchar_t* s, std::size_t length)
941941
{
942942
wchar_t* cur = s+length;
943943
wchar_t *end = nullptr;
@@ -1026,4 +1026,4 @@ hexstr_to_integer(const CharT* s, std::size_t length, T& n)
10261026
} // namespace utility
10271027
} // namespace jsoncons
10281028

1029-
#endif // JSONCONS_UTILITY_TO_NUMBER_HPP
1029+
#endif // JSONCONS_UTILITY_READ_NUMBER_HPP

include/jsoncons/utility/uri.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <jsoncons/config/compiler_support.hpp>
2020
#include <jsoncons/config/jsoncons_config.hpp>
21-
#include <jsoncons/utility/to_number.hpp>
21+
#include <jsoncons/utility/read_number.hpp>
2222
#include <jsoncons/utility/write_number.hpp>
2323
#include <jsoncons/json_exception.hpp>
2424

include/jsoncons/utility/write_number.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <jsoncons/config/compiler_support.hpp>
2222
#include <jsoncons/config/jsoncons_config.hpp>
2323
#include <jsoncons/detail/grisu3.hpp>
24-
#include <jsoncons/utility/to_number.hpp>
24+
#include <jsoncons/utility/read_number.hpp>
2525
#include <jsoncons/json_exception.hpp>
2626
#include <jsoncons/json_options.hpp>
2727
#include <jsoncons/utility/more_type_traits.hpp>
@@ -307,7 +307,7 @@ namespace utility {
307307
return false;
308308
}
309309
double x{0};
310-
auto res = to_double(buffer, length, x);
310+
auto res = decstr_to_double(buffer, length, x);
311311
if (res.ec == std::errc::invalid_argument)
312312
{
313313
return false;
@@ -344,7 +344,7 @@ namespace utility {
344344
return false;
345345
}
346346
double x{0};
347-
auto res = to_double(buffer, length, x);
347+
auto res = decstr_to_double(buffer, length, x);
348348
if (res.ec == std::errc::invalid_argument)
349349
{
350350
return false;
@@ -415,7 +415,7 @@ namespace utility {
415415
return false;
416416
}
417417
double x{0};
418-
auto res = to_double(buffer, length, x);
418+
auto res = decstr_to_double(buffer, length, x);
419419
if (res.ec == std::errc::invalid_argument)
420420
{
421421
return false;

include/jsoncons_ext/bson/bson_decimal128.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#include <jsoncons/config/compiler_support.hpp>
4242
#include <jsoncons/config/jsoncons_config.hpp>
43-
#include <jsoncons/utility/to_number.hpp>
43+
#include <jsoncons/utility/read_number.hpp>
4444
#include <jsoncons/utility/write_number.hpp>
4545

4646
namespace jsoncons {

include/jsoncons_ext/cbor/cbor_encoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include <jsoncons/config/compiler_support.hpp>
2323
#include <jsoncons/config/jsoncons_config.hpp>
24-
#include <jsoncons/utility/to_number.hpp>
24+
#include <jsoncons/utility/read_number.hpp>
2525
#include <jsoncons/json_exception.hpp> // jsoncons::ser_error
2626
#include <jsoncons/json_type.hpp>
2727
#include <jsoncons/json_visitor.hpp>

include/jsoncons_ext/csv/csv_parser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <jsoncons/config/compiler_support.hpp>
2121
#include <jsoncons/config/jsoncons_config.hpp>
22-
#include <jsoncons/utility/to_number.hpp>
22+
#include <jsoncons/utility/read_number.hpp>
2323
#include <jsoncons/json_exception.hpp>
2424
#include <jsoncons/json_filter.hpp>
2525
#include <jsoncons/json_reader.hpp>
@@ -2307,7 +2307,7 @@ class basic_csv_parser : public ser_context
23072307
else
23082308
{
23092309
double d{0};
2310-
auto result = jsoncons::utility::to_double(buffer.c_str(), buffer.length(), d);
2310+
auto result = jsoncons::utility::decstr_to_double(buffer.c_str(), buffer.length(), d);
23112311
if (result.ec == std::errc::result_out_of_range)
23122312
{
23132313
d = buffer.front() == '-' ? -HUGE_VAL : HUGE_VAL;

include/jsoncons_ext/jmespath/jmespath.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <map>
2424

2525
#include <jsoncons/config/compiler_support.hpp>
26-
#include <jsoncons/utility/to_number.hpp>
26+
#include <jsoncons/utility/read_number.hpp>
2727
#include <jsoncons/json_decoder.hpp>
2828
#include <jsoncons/json_reader.hpp>
2929
#include <jsoncons/json_type.hpp>
@@ -2392,7 +2392,7 @@ namespace detail {
23922392
}
23932393
auto s = arg0.as_string();
23942394
double d{0};
2395-
auto result3 = jsoncons::utility::to_double(s.c_str(), s.length(), d);
2395+
auto result3 = jsoncons::utility::decstr_to_double(s.c_str(), s.length(), d);
23962396
if (result3)
23972397
{
23982398
return *context.create_json(d);

0 commit comments

Comments
 (0)