json


Directory: ../json_lcov_PR-1025/include/boost/json/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 25.0% 3 / 0 / 12
Functions: 50.0% 1 / 0 / 2
Branches: -% 0 / 5 / 5

detail/charconv/impl/from_chars.ipp
Line Branch Exec Source
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 std::errc boost::json::detail::charconv::detail::errno_to_errc(int errno_value) noexcept
28 {
29 switch (errno_value)
30 {
31 case EINVAL:
32 return std::errc::invalid_argument;
33 case ERANGE:
34 return std::errc::result_out_of_range;
35 default:
36 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 return boost::json::detail::charconv::detail::from_chars_float_impl(first, last, value, fmt);
47 }
48