Line data Source code
1 : // Copyright 2022 Peter Dimov
2 : // Copyright 2023 Matt Borland
3 : // Distributed under the Boost Software License, Version 1.0.
4 : // https://www.boost.org/LICENSE_1_0.txt
5 :
6 : // https://stackoverflow.com/questions/38060411/visual-studio-2015-wont-suppress-error-c4996
7 : #ifndef _SCL_SECURE_NO_WARNINGS
8 : # define _SCL_SECURE_NO_WARNINGS
9 : #endif
10 : #ifndef NO_WARN_MBCS_MFC_DEPRECATION
11 : # define NO_WARN_MBCS_MFC_DEPRECATION
12 : #endif
13 :
14 : #include <boost/json/detail/charconv/detail/fast_float/fast_float.hpp>
15 : #include <boost/json/detail/charconv/detail/from_chars_float_impl.hpp>
16 : #include <boost/json/detail/charconv/from_chars.hpp>
17 : #include <system_error>
18 : #include <string>
19 : #include <cstdlib>
20 : #include <cerrno>
21 : #include <cstring>
22 :
23 : #if defined(__GNUC__) && __GNUC__ < 5
24 : # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
25 : #endif
26 :
27 0 : std::errc boost::json::detail::charconv::detail::errno_to_errc(int errno_value) noexcept
28 : {
29 0 : switch (errno_value)
30 : {
31 0 : case EINVAL:
32 0 : return std::errc::invalid_argument;
33 0 : case ERANGE:
34 0 : return std::errc::result_out_of_range;
35 0 : default:
36 0 : return std::errc();
37 : }
38 : }
39 :
40 1009310 : boost::json::detail::charconv::from_chars_result boost::json::detail::charconv::from_chars(const char* first, const char* last, double& value, boost::json::detail::charconv::chars_format fmt) noexcept
41 : {
42 1009310 : if (fmt != boost::json::detail::charconv::chars_format::hex)
43 : {
44 1009310 : return boost::json::detail::charconv::detail::fast_float::from_chars(first, last, value, fmt);
45 : }
46 0 : return boost::json::detail::charconv::detail::from_chars_float_impl(first, last, value, fmt);
47 : }
|