99.22% Lines (1268/1278) 100.00% Functions (30/30)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3   // Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com) 3   // Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com)
4   // 4   //
5   // Distributed under the Boost Software License, Version 1.0. (See accompanying 5   // Distributed under the Boost Software License, Version 1.0. (See accompanying
6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7   // 7   //
8   // Official repository: https://github.com/boostorg/json 8   // Official repository: https://github.com/boostorg/json
9   // 9   //
10   10  
11   #ifndef BOOST_JSON_BASIC_PARSER_IMPL_HPP 11   #ifndef BOOST_JSON_BASIC_PARSER_IMPL_HPP
12   #define BOOST_JSON_BASIC_PARSER_IMPL_HPP 12   #define BOOST_JSON_BASIC_PARSER_IMPL_HPP
13   13  
14   #include <boost/json/detail/config.hpp> 14   #include <boost/json/detail/config.hpp>
15   #include <boost/json/detail/literals.hpp> 15   #include <boost/json/detail/literals.hpp>
16   #include <boost/json/basic_parser.hpp> 16   #include <boost/json/basic_parser.hpp>
17   #include <boost/json/error.hpp> 17   #include <boost/json/error.hpp>
18   #include <boost/json/detail/buffer.hpp> 18   #include <boost/json/detail/buffer.hpp>
19   #include <boost/json/detail/charconv/from_chars.hpp> 19   #include <boost/json/detail/charconv/from_chars.hpp>
20   #include <boost/json/detail/sse2.hpp> 20   #include <boost/json/detail/sse2.hpp>
21   #include <boost/mp11/algorithm.hpp> 21   #include <boost/mp11/algorithm.hpp>
22   #include <boost/mp11/integral.hpp> 22   #include <boost/mp11/integral.hpp>
23   #include <cmath> 23   #include <cmath>
24   #include <limits> 24   #include <limits>
25   #include <cstring> 25   #include <cstring>
26   26  
27   #ifdef _MSC_VER 27   #ifdef _MSC_VER
28   #pragma warning(push) 28   #pragma warning(push)
29   #pragma warning(disable: 4702) // unreachable code 29   #pragma warning(disable: 4702) // unreachable code
30   #pragma warning(disable: 4127) // conditional expression is constant 30   #pragma warning(disable: 4127) // conditional expression is constant
31   #endif 31   #endif
32   32  
33   /* This file must be manually included to get the 33   /* This file must be manually included to get the
34   function template definitions for basic_parser. 34   function template definitions for basic_parser.
35   */ 35   */
36   36  
37   /* Reference: 37   /* Reference:
38   38  
39   https://www.json.org/ 39   https://www.json.org/
40   40  
41   RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format 41   RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format
42   https://tools.ietf.org/html/rfc7159 42   https://tools.ietf.org/html/rfc7159
43   43  
44   https://ampl.com/netlib/fp/dtoa.c 44   https://ampl.com/netlib/fp/dtoa.c
45   */ 45   */
46   46  
47   #ifndef BOOST_JSON_DOCS 47   #ifndef BOOST_JSON_DOCS
48   48  
49   namespace boost { 49   namespace boost {
50   namespace json { 50   namespace json {
51   namespace detail { 51   namespace detail {
52   52  
53   inline 53   inline
54   double 54   double
HITCBC 55   1043144 pow10(int exp) noexcept 55   1035607 pow10(int exp) noexcept
56   { 56   {
57   static double const tab[618] = { 57   static double const tab[618] = {
58   1e-308, 1e-307, 1e-306, 1e-305, 1e-304, 1e-303, 1e-302, 1e-301, 58   1e-308, 1e-307, 1e-306, 1e-305, 1e-304, 1e-303, 1e-302, 1e-301,
59   59  
60   1e-300, 1e-299, 1e-298, 1e-297, 1e-296, 1e-295, 1e-294, 1e-293, 1e-292, 1e-291, 60   1e-300, 1e-299, 1e-298, 1e-297, 1e-296, 1e-295, 1e-294, 1e-293, 1e-292, 1e-291,
61   1e-290, 1e-289, 1e-288, 1e-287, 1e-286, 1e-285, 1e-284, 1e-283, 1e-282, 1e-281, 61   1e-290, 1e-289, 1e-288, 1e-287, 1e-286, 1e-285, 1e-284, 1e-283, 1e-282, 1e-281,
62   1e-280, 1e-279, 1e-278, 1e-277, 1e-276, 1e-275, 1e-274, 1e-273, 1e-272, 1e-271, 62   1e-280, 1e-279, 1e-278, 1e-277, 1e-276, 1e-275, 1e-274, 1e-273, 1e-272, 1e-271,
63   1e-270, 1e-269, 1e-268, 1e-267, 1e-266, 1e-265, 1e-264, 1e-263, 1e-262, 1e-261, 63   1e-270, 1e-269, 1e-268, 1e-267, 1e-266, 1e-265, 1e-264, 1e-263, 1e-262, 1e-261,
64   1e-260, 1e-259, 1e-258, 1e-257, 1e-256, 1e-255, 1e-254, 1e-253, 1e-252, 1e-251, 64   1e-260, 1e-259, 1e-258, 1e-257, 1e-256, 1e-255, 1e-254, 1e-253, 1e-252, 1e-251,
65   1e-250, 1e-249, 1e-248, 1e-247, 1e-246, 1e-245, 1e-244, 1e-243, 1e-242, 1e-241, 65   1e-250, 1e-249, 1e-248, 1e-247, 1e-246, 1e-245, 1e-244, 1e-243, 1e-242, 1e-241,
66   1e-240, 1e-239, 1e-238, 1e-237, 1e-236, 1e-235, 1e-234, 1e-233, 1e-232, 1e-231, 66   1e-240, 1e-239, 1e-238, 1e-237, 1e-236, 1e-235, 1e-234, 1e-233, 1e-232, 1e-231,
67   1e-230, 1e-229, 1e-228, 1e-227, 1e-226, 1e-225, 1e-224, 1e-223, 1e-222, 1e-221, 67   1e-230, 1e-229, 1e-228, 1e-227, 1e-226, 1e-225, 1e-224, 1e-223, 1e-222, 1e-221,
68   1e-220, 1e-219, 1e-218, 1e-217, 1e-216, 1e-215, 1e-214, 1e-213, 1e-212, 1e-211, 68   1e-220, 1e-219, 1e-218, 1e-217, 1e-216, 1e-215, 1e-214, 1e-213, 1e-212, 1e-211,
69   1e-210, 1e-209, 1e-208, 1e-207, 1e-206, 1e-205, 1e-204, 1e-203, 1e-202, 1e-201, 69   1e-210, 1e-209, 1e-208, 1e-207, 1e-206, 1e-205, 1e-204, 1e-203, 1e-202, 1e-201,
70   70  
71   1e-200, 1e-199, 1e-198, 1e-197, 1e-196, 1e-195, 1e-194, 1e-193, 1e-192, 1e-191, 71   1e-200, 1e-199, 1e-198, 1e-197, 1e-196, 1e-195, 1e-194, 1e-193, 1e-192, 1e-191,
72   1e-190, 1e-189, 1e-188, 1e-187, 1e-186, 1e-185, 1e-184, 1e-183, 1e-182, 1e-181, 72   1e-190, 1e-189, 1e-188, 1e-187, 1e-186, 1e-185, 1e-184, 1e-183, 1e-182, 1e-181,
73   1e-180, 1e-179, 1e-178, 1e-177, 1e-176, 1e-175, 1e-174, 1e-173, 1e-172, 1e-171, 73   1e-180, 1e-179, 1e-178, 1e-177, 1e-176, 1e-175, 1e-174, 1e-173, 1e-172, 1e-171,
74   1e-170, 1e-169, 1e-168, 1e-167, 1e-166, 1e-165, 1e-164, 1e-163, 1e-162, 1e-161, 74   1e-170, 1e-169, 1e-168, 1e-167, 1e-166, 1e-165, 1e-164, 1e-163, 1e-162, 1e-161,
75   1e-160, 1e-159, 1e-158, 1e-157, 1e-156, 1e-155, 1e-154, 1e-153, 1e-152, 1e-151, 75   1e-160, 1e-159, 1e-158, 1e-157, 1e-156, 1e-155, 1e-154, 1e-153, 1e-152, 1e-151,
76   1e-150, 1e-149, 1e-148, 1e-147, 1e-146, 1e-145, 1e-144, 1e-143, 1e-142, 1e-141, 76   1e-150, 1e-149, 1e-148, 1e-147, 1e-146, 1e-145, 1e-144, 1e-143, 1e-142, 1e-141,
77   1e-140, 1e-139, 1e-138, 1e-137, 1e-136, 1e-135, 1e-134, 1e-133, 1e-132, 1e-131, 77   1e-140, 1e-139, 1e-138, 1e-137, 1e-136, 1e-135, 1e-134, 1e-133, 1e-132, 1e-131,
78   1e-130, 1e-129, 1e-128, 1e-127, 1e-126, 1e-125, 1e-124, 1e-123, 1e-122, 1e-121, 78   1e-130, 1e-129, 1e-128, 1e-127, 1e-126, 1e-125, 1e-124, 1e-123, 1e-122, 1e-121,
79   1e-120, 1e-119, 1e-118, 1e-117, 1e-116, 1e-115, 1e-114, 1e-113, 1e-112, 1e-111, 79   1e-120, 1e-119, 1e-118, 1e-117, 1e-116, 1e-115, 1e-114, 1e-113, 1e-112, 1e-111,
80   1e-110, 1e-109, 1e-108, 1e-107, 1e-106, 1e-105, 1e-104, 1e-103, 1e-102, 1e-101, 80   1e-110, 1e-109, 1e-108, 1e-107, 1e-106, 1e-105, 1e-104, 1e-103, 1e-102, 1e-101,
81   81  
82   1e-100, 1e-099, 1e-098, 1e-097, 1e-096, 1e-095, 1e-094, 1e-093, 1e-092, 1e-091, 82   1e-100, 1e-099, 1e-098, 1e-097, 1e-096, 1e-095, 1e-094, 1e-093, 1e-092, 1e-091,
83   1e-090, 1e-089, 1e-088, 1e-087, 1e-086, 1e-085, 1e-084, 1e-083, 1e-082, 1e-081, 83   1e-090, 1e-089, 1e-088, 1e-087, 1e-086, 1e-085, 1e-084, 1e-083, 1e-082, 1e-081,
84   1e-080, 1e-079, 1e-078, 1e-077, 1e-076, 1e-075, 1e-074, 1e-073, 1e-072, 1e-071, 84   1e-080, 1e-079, 1e-078, 1e-077, 1e-076, 1e-075, 1e-074, 1e-073, 1e-072, 1e-071,
85   1e-070, 1e-069, 1e-068, 1e-067, 1e-066, 1e-065, 1e-064, 1e-063, 1e-062, 1e-061, 85   1e-070, 1e-069, 1e-068, 1e-067, 1e-066, 1e-065, 1e-064, 1e-063, 1e-062, 1e-061,
86   1e-060, 1e-059, 1e-058, 1e-057, 1e-056, 1e-055, 1e-054, 1e-053, 1e-052, 1e-051, 86   1e-060, 1e-059, 1e-058, 1e-057, 1e-056, 1e-055, 1e-054, 1e-053, 1e-052, 1e-051,
87   1e-050, 1e-049, 1e-048, 1e-047, 1e-046, 1e-045, 1e-044, 1e-043, 1e-042, 1e-041, 87   1e-050, 1e-049, 1e-048, 1e-047, 1e-046, 1e-045, 1e-044, 1e-043, 1e-042, 1e-041,
88   1e-040, 1e-039, 1e-038, 1e-037, 1e-036, 1e-035, 1e-034, 1e-033, 1e-032, 1e-031, 88   1e-040, 1e-039, 1e-038, 1e-037, 1e-036, 1e-035, 1e-034, 1e-033, 1e-032, 1e-031,
89   1e-030, 1e-029, 1e-028, 1e-027, 1e-026, 1e-025, 1e-024, 1e-023, 1e-022, 1e-021, 89   1e-030, 1e-029, 1e-028, 1e-027, 1e-026, 1e-025, 1e-024, 1e-023, 1e-022, 1e-021,
90   1e-020, 1e-019, 1e-018, 1e-017, 1e-016, 1e-015, 1e-014, 1e-013, 1e-012, 1e-011, 90   1e-020, 1e-019, 1e-018, 1e-017, 1e-016, 1e-015, 1e-014, 1e-013, 1e-012, 1e-011,
91   1e-010, 1e-009, 1e-008, 1e-007, 1e-006, 1e-005, 1e-004, 1e-003, 1e-002, 1e-001, 91   1e-010, 1e-009, 1e-008, 1e-007, 1e-006, 1e-005, 1e-004, 1e-003, 1e-002, 1e-001,
92   92  
93   1e+000, 1e+001, 1e+002, 1e+003, 1e+004, 1e+005, 1e+006, 1e+007, 1e+008, 1e+009, 93   1e+000, 1e+001, 1e+002, 1e+003, 1e+004, 1e+005, 1e+006, 1e+007, 1e+008, 1e+009,
94   1e+010, 1e+011, 1e+012, 1e+013, 1e+014, 1e+015, 1e+016, 1e+017, 1e+018, 1e+019, 94   1e+010, 1e+011, 1e+012, 1e+013, 1e+014, 1e+015, 1e+016, 1e+017, 1e+018, 1e+019,
95   1e+020, 1e+021, 1e+022, 1e+023, 1e+024, 1e+025, 1e+026, 1e+027, 1e+028, 1e+029, 95   1e+020, 1e+021, 1e+022, 1e+023, 1e+024, 1e+025, 1e+026, 1e+027, 1e+028, 1e+029,
96   1e+030, 1e+031, 1e+032, 1e+033, 1e+034, 1e+035, 1e+036, 1e+037, 1e+038, 1e+039, 96   1e+030, 1e+031, 1e+032, 1e+033, 1e+034, 1e+035, 1e+036, 1e+037, 1e+038, 1e+039,
97   1e+040, 1e+041, 1e+042, 1e+043, 1e+044, 1e+045, 1e+046, 1e+047, 1e+048, 1e+049, 97   1e+040, 1e+041, 1e+042, 1e+043, 1e+044, 1e+045, 1e+046, 1e+047, 1e+048, 1e+049,
98   1e+050, 1e+051, 1e+052, 1e+053, 1e+054, 1e+055, 1e+056, 1e+057, 1e+058, 1e+059, 98   1e+050, 1e+051, 1e+052, 1e+053, 1e+054, 1e+055, 1e+056, 1e+057, 1e+058, 1e+059,
99   1e+060, 1e+061, 1e+062, 1e+063, 1e+064, 1e+065, 1e+066, 1e+067, 1e+068, 1e+069, 99   1e+060, 1e+061, 1e+062, 1e+063, 1e+064, 1e+065, 1e+066, 1e+067, 1e+068, 1e+069,
100   1e+070, 1e+071, 1e+072, 1e+073, 1e+074, 1e+075, 1e+076, 1e+077, 1e+078, 1e+079, 100   1e+070, 1e+071, 1e+072, 1e+073, 1e+074, 1e+075, 1e+076, 1e+077, 1e+078, 1e+079,
101   1e+080, 1e+081, 1e+082, 1e+083, 1e+084, 1e+085, 1e+086, 1e+087, 1e+088, 1e+089, 101   1e+080, 1e+081, 1e+082, 1e+083, 1e+084, 1e+085, 1e+086, 1e+087, 1e+088, 1e+089,
102   1e+090, 1e+091, 1e+092, 1e+093, 1e+094, 1e+095, 1e+096, 1e+097, 1e+098, 1e+099, 102   1e+090, 1e+091, 1e+092, 1e+093, 1e+094, 1e+095, 1e+096, 1e+097, 1e+098, 1e+099,
103   103  
104   1e+100, 1e+101, 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109, 104   1e+100, 1e+101, 1e+102, 1e+103, 1e+104, 1e+105, 1e+106, 1e+107, 1e+108, 1e+109,
105   1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, 1e+119, 105   1e+110, 1e+111, 1e+112, 1e+113, 1e+114, 1e+115, 1e+116, 1e+117, 1e+118, 1e+119,
106   1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129, 106   1e+120, 1e+121, 1e+122, 1e+123, 1e+124, 1e+125, 1e+126, 1e+127, 1e+128, 1e+129,
107   1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, 1e+136, 1e+137, 1e+138, 1e+139, 107   1e+130, 1e+131, 1e+132, 1e+133, 1e+134, 1e+135, 1e+136, 1e+137, 1e+138, 1e+139,
108   1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148, 1e+149, 108   1e+140, 1e+141, 1e+142, 1e+143, 1e+144, 1e+145, 1e+146, 1e+147, 1e+148, 1e+149,
109   1e+150, 1e+151, 1e+152, 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159, 109   1e+150, 1e+151, 1e+152, 1e+153, 1e+154, 1e+155, 1e+156, 1e+157, 1e+158, 1e+159,
110   1e+160, 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169, 110   1e+160, 1e+161, 1e+162, 1e+163, 1e+164, 1e+165, 1e+166, 1e+167, 1e+168, 1e+169,
111   1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178, 1e+179, 111   1e+170, 1e+171, 1e+172, 1e+173, 1e+174, 1e+175, 1e+176, 1e+177, 1e+178, 1e+179,
112   1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, 1e+187, 1e+188, 1e+189, 112   1e+180, 1e+181, 1e+182, 1e+183, 1e+184, 1e+185, 1e+186, 1e+187, 1e+188, 1e+189,
113   1e+190, 1e+191, 1e+192, 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199, 113   1e+190, 1e+191, 1e+192, 1e+193, 1e+194, 1e+195, 1e+196, 1e+197, 1e+198, 1e+199,
114   114  
115   1e+200, 1e+201, 1e+202, 1e+203, 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, 1e+209, 115   1e+200, 1e+201, 1e+202, 1e+203, 1e+204, 1e+205, 1e+206, 1e+207, 1e+208, 1e+209,
116   1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219, 116   1e+210, 1e+211, 1e+212, 1e+213, 1e+214, 1e+215, 1e+216, 1e+217, 1e+218, 1e+219,
117   1e+220, 1e+221, 1e+222, 1e+223, 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229, 117   1e+220, 1e+221, 1e+222, 1e+223, 1e+224, 1e+225, 1e+226, 1e+227, 1e+228, 1e+229,
118   1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, 1e+238, 1e+239, 118   1e+230, 1e+231, 1e+232, 1e+233, 1e+234, 1e+235, 1e+236, 1e+237, 1e+238, 1e+239,
119   1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249, 119   1e+240, 1e+241, 1e+242, 1e+243, 1e+244, 1e+245, 1e+246, 1e+247, 1e+248, 1e+249,
120   1e+250, 1e+251, 1e+252, 1e+253, 1e+254, 1e+255, 1e+256, 1e+257, 1e+258, 1e+259, 120   1e+250, 1e+251, 1e+252, 1e+253, 1e+254, 1e+255, 1e+256, 1e+257, 1e+258, 1e+259,
121   1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269, 121   1e+260, 1e+261, 1e+262, 1e+263, 1e+264, 1e+265, 1e+266, 1e+267, 1e+268, 1e+269,
122   1e+270, 1e+271, 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279, 122   1e+270, 1e+271, 1e+272, 1e+273, 1e+274, 1e+275, 1e+276, 1e+277, 1e+278, 1e+279,
123   1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, 1e+289, 123   1e+280, 1e+281, 1e+282, 1e+283, 1e+284, 1e+285, 1e+286, 1e+287, 1e+288, 1e+289,
124   1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299, 124   1e+290, 1e+291, 1e+292, 1e+293, 1e+294, 1e+295, 1e+296, 1e+297, 1e+298, 1e+299,
125   125  
126   1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, 1e+306, 1e+307, 1e+308 }; 126   1e+300, 1e+301, 1e+302, 1e+303, 1e+304, 1e+305, 1e+306, 1e+307, 1e+308 };
127   127  
HITCBC 128   1043144 if( exp > 308 ) 128   1035607 if( exp > 308 )
129   { 129   {
HITCBC 130   534 return std::numeric_limits<double>::infinity(); 130   455 return std::numeric_limits<double>::infinity();
131   } 131   }
HITCBC 132   1042610 else if( exp < -308 ) 132   1035152 else if( exp < -308 )
133   { 133   {
134   // due to the way pow10 is used by dec_to_float, 134   // due to the way pow10 is used by dec_to_float,
135   // we can afford to return 0.0 here 135   // we can afford to return 0.0 here
HITCBC 136   151 return 0.0; 136   151 return 0.0;
137   } 137   }
138   else 138   else
139   { 139   {
HITCBC 140   1042459 exp += 308; 140   1035001 exp += 308;
HITCBC 141   1042459 BOOST_ASSERT(exp >= 0 && exp < 618); 141   1035001 BOOST_ASSERT(exp >= 0 && exp < 618);
HITCBC 142   1042459 return tab[exp]; 142   1035001 return tab[exp];
143   } 143   }
144   } 144   }
145   145  
146   inline 146   inline
147   double 147   double
HITCBC 148   1043144 dec_to_float( 148   1043157 dec_to_float(
149   std::uint64_t m, 149   std::uint64_t m,
150   std::int32_t e, 150   std::int32_t e,
151   bool neg) noexcept 151   bool neg) noexcept
152   { 152   {
153   // convert to double explicitly to silence warnings 153   // convert to double explicitly to silence warnings
HITCBC 154   1043144 double x = static_cast<double>(m); 154   1043157 double x = static_cast<double>(m);
HITCBC 155   1043144 if(neg) 155   1043157 if(neg)
HITCBC 156   17062 x = -x; 156   17069 x = -x;
157   157  
  158 + // pow10 returns infinity for large exponents,
  159 + // and zero times infinity is NaN
HITGNC   160 + 1043157 if(m == 0)
HITGNC   161 + 7550 return x;
  162 +
HITCBC 158   1043144 if(e < -305) 163   1035607 if(e < -305)
159   { 164   {
HITCBC 160   5269 x *= 1e-305 ; 165   5269 x *= 1e-305 ;
HITCBC 161   5269 e += 305; 166   5269 e += 305;
162   } 167   }
163   168  
HITCBC 164   1043144 if(e >= -22 && e < 0) 169   1035607 if(e >= -22 && e < 0)
HITCBC 165   59279 return x / pow10(-e); 170   57637 return x / pow10(-e);
166   171  
HITCBC 167   983865 return x * pow10(e); 172   977970 return x * pow10(e);
168   } 173   }
169   174  
170   inline 175   inline
171   bool 176   bool
172   is_control(char c) noexcept 177   is_control(char c) noexcept
173   { 178   {
174   return static_cast<unsigned char>(c) < 32; 179   return static_cast<unsigned char>(c) < 32;
175   } 180   }
176   181  
177   inline 182   inline
178   int 183   int
HITCBC 179   66931 hex_digit(unsigned char c) noexcept 184   66931 hex_digit(unsigned char c) noexcept
180   { 185   {
181   // by Peter Dimov 186   // by Peter Dimov
HITCBC 182   66931 if( c >= '0' && c <= '9' ) 187   66931 if( c >= '0' && c <= '9' )
HITCBC 183   35759 return c - '0'; 188   35759 return c - '0';
HITCBC 184   31172 c &= ~0x20; 189   31172 c &= ~0x20;
HITCBC 185   31172 if( c >= 'A' && c <= 'F' ) 190   31172 if( c >= 'A' && c <= 'F' )
HITCBC 186   30562 return 10 + c - 'A'; 191   30562 return 10 + c - 'A';
HITCBC 187   610 return -1; 192   610 return -1;
188   } 193   }
189   194  
190   } // detail 195   } // detail
191   196  
192   //---------------------------------------------------------- 197   //----------------------------------------------------------
193   198  
194   template< class Handler > 199   template< class Handler >
195   template< bool StackEmpty_, char First_ > 200   template< bool StackEmpty_, char First_ >
196   struct basic_parser<Handler>:: 201   struct basic_parser<Handler>::
197   parse_number_helper 202   parse_number_helper
198   { 203   {
199   basic_parser* parser; 204   basic_parser* parser;
200   char const* p; 205   char const* p;
201   206  
202   template< std::size_t N > 207   template< std::size_t N >
203   char const* 208   char const*
HITCBC 204   10515955 operator()( mp11::mp_size_t<N> ) const 209   10515990 operator()( mp11::mp_size_t<N> ) const
205   { 210   {
HITCBC 206   21026405 return parser->parse_number( 211   21026475 return parser->parse_number(
HITCBC 207   10515955 p, 212   10515990 p,
208   std::integral_constant<bool, StackEmpty_>(), 213   std::integral_constant<bool, StackEmpty_>(),
209   std::integral_constant<char, First_>(), 214   std::integral_constant<char, First_>(),
210   std::integral_constant< 215   std::integral_constant<
HITCBC 211   10510451 number_precision, static_cast<number_precision>(N)>() ); 216   10510486 number_precision, static_cast<number_precision>(N)>() );
212   } 217   }
213   }; 218   };
214   219  
215   //---------------------------------------------------------- 220   //----------------------------------------------------------
216   221  
217   template<class Handler> 222   template<class Handler>
218   void 223   void
HITCBC 219   8602410 basic_parser<Handler>:: 224   8602432 basic_parser<Handler>::
220   reserve() 225   reserve()
221   { 226   {
HITCBC 222   8602410 if(BOOST_JSON_LIKELY( 227   8602432 if(BOOST_JSON_LIKELY(
223   ! st_.empty())) 228   ! st_.empty()))
HITCBC 224   37477 return; 229   37477 return;
225   // Reserve the largest stack we need, 230   // Reserve the largest stack we need,
226   // to avoid reallocation during suspend. 231   // to avoid reallocation during suspend.
HITCBC 227   17129866 st_.reserve( 232   17129910 st_.reserve(
228   sizeof(state) + // document parsing state 233   sizeof(state) + // document parsing state
229   (sizeof(state) + 234   (sizeof(state) +
HITCBC 230   8564933 sizeof(std::size_t)) * depth() + // array and object state + size 235   8564955 sizeof(std::size_t)) * depth() + // array and object state + size
231   sizeof(state) + // value parsing state 236   sizeof(state) + // value parsing state
232   sizeof(std::size_t) + // string size 237   sizeof(std::size_t) + // string size
233   sizeof(state)); // comment state 238   sizeof(state)); // comment state
234   } 239   }
235   240  
236   //---------------------------------------------------------- 241   //----------------------------------------------------------
237   // 242   //
238   // The sentinel value is returned by parse functions 243   // The sentinel value is returned by parse functions
239   // to indicate that the parser failed, or suspended. 244   // to indicate that the parser failed, or suspended.
240   // this is used as it is distinct from all valid values 245   // this is used as it is distinct from all valid values
241   // for data in write 246   // for data in write
242   247  
243   template<class Handler> 248   template<class Handler>
244   const char* 249   const char*
HITCBC 245   47301011 basic_parser<Handler>:: 250   47301147 basic_parser<Handler>::
246   sentinel() 251   sentinel()
247   { 252   {
248   // the "+1" ensures that the returned pointer is unique even if 253   // the "+1" ensures that the returned pointer is unique even if
249   // the given input buffer borders on this object 254   // the given input buffer borders on this object
250   return reinterpret_cast< 255   return reinterpret_cast<
HITCBC 251   47301011 const char*>(this) + 1; 256   47301147 const char*>(this) + 1;
252   } 257   }
253   258  
254   template<class Handler> 259   template<class Handler>
255   bool 260   bool
HITCBC 256   10851956 basic_parser<Handler>:: 261   10851991 basic_parser<Handler>::
257   incomplete( 262   incomplete(
258   const detail::const_stream_wrapper& cs) 263   const detail::const_stream_wrapper& cs)
259   { 264   {
HITCBC 260   10851956 return cs.begin() == sentinel(); 265   10851991 return cs.begin() == sentinel();
261   } 266   }
262   267  
263   //---------------------------------------------------------- 268   //----------------------------------------------------------
264   // 269   //
265   // These functions are declared with the BOOST_NOINLINE 270   // These functions are declared with the BOOST_NOINLINE
266   // attribute to avoid polluting the parsers hot-path. 271   // attribute to avoid polluting the parsers hot-path.
267   // They return the canary value to indicate suspension 272   // They return the canary value to indicate suspension
268   // or failure. 273   // or failure.
269   274  
270   template<class Handler> 275   template<class Handler>
271   const char* 276   const char*
272   basic_parser<Handler>:: 277   basic_parser<Handler>::
273   suspend_or_fail(state st) 278   suspend_or_fail(state st)
274   { 279   {
275   if(BOOST_JSON_LIKELY( 280   if(BOOST_JSON_LIKELY(
276   ! ec_ && more_)) 281   ! ec_ && more_))
277   { 282   {
278   // suspend 283   // suspend
279   reserve(); 284   reserve();
280   st_.push_unchecked(st); 285   st_.push_unchecked(st);
281   } 286   }
282   return sentinel(); 287   return sentinel();
283   } 288   }
284   289  
285   template<class Handler> 290   template<class Handler>
286   const char* 291   const char*
HITCBC 287   56179 basic_parser<Handler>:: 292   56179 basic_parser<Handler>::
288   suspend_or_fail( 293   suspend_or_fail(
289   state st, 294   state st,
290   std::size_t n) 295   std::size_t n)
291   { 296   {
HITCBC 292   56179 if(BOOST_JSON_LIKELY( 297   56179 if(BOOST_JSON_LIKELY(
293   ! ec_ && more_)) 298   ! ec_ && more_))
294   { 299   {
295   // suspend 300   // suspend
HITCBC 296   35861 reserve(); 301   35861 reserve();
HITCBC 297   35861 st_.push_unchecked(n); 302   35861 st_.push_unchecked(n);
HITCBC 298   35861 st_.push_unchecked(st); 303   35861 st_.push_unchecked(st);
299   } 304   }
HITCBC 300   56179 return sentinel(); 305   56179 return sentinel();
301   } 306   }
302   307  
303   308  
304   template<class Handler> 309   template<class Handler>
305   const char* 310   const char*
HITCBC 306   19074 basic_parser<Handler>:: 311   19074 basic_parser<Handler>::
307   fail(const char* p) noexcept 312   fail(const char* p) noexcept
308   { 313   {
HITCBC 309   19074 BOOST_ASSERT( p != sentinel() ); 314   19074 BOOST_ASSERT( p != sentinel() );
HITCBC 310   19074 end_ = p; 315   19074 end_ = p;
HITCBC 311   19074 return sentinel(); 316   19074 return sentinel();
312   } 317   }
313   318  
314   template<class Handler> 319   template<class Handler>
315   const char* 320   const char*
HITCBC 316   7781 basic_parser<Handler>:: 321   7781 basic_parser<Handler>::
317   fail( 322   fail(
318   const char* p, 323   const char* p,
319   error ev, 324   error ev,
320   source_location const* loc) noexcept 325   source_location const* loc) noexcept
321   { 326   {
HITCBC 322   7781 BOOST_ASSERT( p != sentinel() ); 327   7781 BOOST_ASSERT( p != sentinel() );
HITCBC 323   7781 end_ = p; 328   7781 end_ = p;
HITCBC 324   7781 ec_.assign(ev, loc); 329   7781 ec_.assign(ev, loc);
HITCBC 325   7781 return sentinel(); 330   7781 return sentinel();
326   } 331   }
327   332  
328   template<class Handler> 333   template<class Handler>
329   const char* 334   const char*
HITCBC 330   11323 basic_parser<Handler>:: 335   11323 basic_parser<Handler>::
331   maybe_suspend( 336   maybe_suspend(
332   const char* p, 337   const char* p,
333   state st) 338   state st)
334   { 339   {
HITCBC 335   11323 if( p != sentinel() ) 340   11323 if( p != sentinel() )
HITCBC 336   9445 end_ = p; 341   9445 end_ = p;
HITCBC 337   11323 if(BOOST_JSON_LIKELY(more_)) 342   11323 if(BOOST_JSON_LIKELY(more_))
338   { 343   {
339   // suspend 344   // suspend
HITCBC 340   11050 reserve(); 345   11050 reserve();
HITCBC 341   11050 st_.push_unchecked(st); 346   11050 st_.push_unchecked(st);
342   } 347   }
HITCBC 343   11323 return sentinel(); 348   11323 return sentinel();
344   } 349   }
345   350  
346   template<class Handler> 351   template<class Handler>
347   const char* 352   const char*
HITCBC 348   41250 basic_parser<Handler>:: 353   41250 basic_parser<Handler>::
349   maybe_suspend( 354   maybe_suspend(
350   const char* p, 355   const char* p,
351   state st, 356   state st,
352   std::size_t n) 357   std::size_t n)
353   { 358   {
HITCBC 354   41250 BOOST_ASSERT( p != sentinel() ); 359   41250 BOOST_ASSERT( p != sentinel() );
HITCBC 355   41250 end_ = p; 360   41250 end_ = p;
HITCBC 356   41250 if(BOOST_JSON_LIKELY(more_)) 361   41250 if(BOOST_JSON_LIKELY(more_))
357   { 362   {
358   // suspend 363   // suspend
HITCBC 359   40842 reserve(); 364   40842 reserve();
HITCBC 360   40842 st_.push_unchecked(n); 365   40842 st_.push_unchecked(n);
HITCBC 361   40842 st_.push_unchecked(st); 366   40842 st_.push_unchecked(st);
362   } 367   }
HITCBC 363   41250 return sentinel(); 368   41250 return sentinel();
364   } 369   }
365   370  
366   template<class Handler> 371   template<class Handler>
367   const char* 372   const char*
HITCBC 368   1129 basic_parser<Handler>:: 373   1132 basic_parser<Handler>::
369   maybe_suspend( 374   maybe_suspend(
370   const char* p, 375   const char* p,
371   state st, 376   state st,
372   const number& num) 377   const number& num)
373   { 378   {
HITCBC 374   1129 BOOST_ASSERT( p != sentinel() ); 379   1132 BOOST_ASSERT( p != sentinel() );
HITCBC 375   1129 end_ = p; 380   1132 end_ = p;
HITCBC 376   1129 if(BOOST_JSON_LIKELY(more_)) 381   1132 if(BOOST_JSON_LIKELY(more_))
377   { 382   {
378   // suspend 383   // suspend
HITCBC 379   1129 num_ = num; 384   1132 num_ = num;
HITCBC 380   1129 reserve(); 385   1132 reserve();
HITCBC 381   1129 st_.push_unchecked(st);; 386   1132 st_.push_unchecked(st);;
382   } 387   }
HITCBC 383   1129 return sentinel(); 388   1132 return sentinel();
384   } 389   }
385   390  
386   template<class Handler> 391   template<class Handler>
387   const char* 392   const char*
HITCBC 388   88657 basic_parser<Handler>:: 393   88657 basic_parser<Handler>::
389   suspend( 394   suspend(
390   const char* p, 395   const char* p,
391   state st) 396   state st)
392   { 397   {
HITCBC 393   88657 BOOST_ASSERT( p != sentinel() ); 398   88657 BOOST_ASSERT( p != sentinel() );
HITCBC 394   88657 end_ = p; 399   88657 end_ = p;
395   // suspend 400   // suspend
HITCBC 396   88657 reserve(); 401   88657 reserve();
HITCBC 397   88657 st_.push_unchecked(st); 402   88657 st_.push_unchecked(st);
HITCBC 398   88657 return sentinel(); 403   88657 return sentinel();
399   } 404   }
400   405  
401   template<class Handler> 406   template<class Handler>
402   const char* 407   const char*
HITCBC 403   8424871 basic_parser<Handler>:: 408   8424890 basic_parser<Handler>::
404   suspend( 409   suspend(
405   const char* p, 410   const char* p,
406   state st, 411   state st,
407   const number& num) 412   const number& num)
408   { 413   {
HITCBC 409   8424871 BOOST_ASSERT( p != sentinel() ); 414   8424890 BOOST_ASSERT( p != sentinel() );
HITCBC 410   8424871 end_ = p; 415   8424890 end_ = p;
411   // suspend 416   // suspend
HITCBC 412   8424871 num_ = num; 417   8424890 num_ = num;
HITCBC 413   8424871 reserve(); 418   8424890 reserve();
HITCBC 414   8424871 st_.push_unchecked(st); 419   8424890 st_.push_unchecked(st);
HITCBC 415   8424871 return sentinel(); 420   8424890 return sentinel();
416   } 421   }
417   422  
418   template<class Handler> 423   template<class Handler>
419   template< 424   template<
420   bool StackEmpty_/*, 425   bool StackEmpty_/*,
421   bool Terminal_*/> 426   bool Terminal_*/>
422   const char* 427   const char*
HITCBC 423   21764 basic_parser<Handler>:: 428   21764 basic_parser<Handler>::
424   parse_comment(const char* p, 429   parse_comment(const char* p,
425   std::integral_constant<bool, StackEmpty_> stack_empty, 430   std::integral_constant<bool, StackEmpty_> stack_empty,
426   /*std::integral_constant<bool, Terminal_>*/ bool terminal) 431   /*std::integral_constant<bool, Terminal_>*/ bool terminal)
427   { 432   {
HITCBC 428   21764 detail::const_stream_wrapper cs(p, end_); 433   21764 detail::const_stream_wrapper cs(p, end_);
HITCBC 429   21764 const char* start = cs.begin(); 434   21764 const char* start = cs.begin();
430   std::size_t remain; 435   std::size_t remain;
HITCBC 431   21764 if(! stack_empty && ! st_.empty()) 436   21764 if(! stack_empty && ! st_.empty())
432   { 437   {
433   state st; 438   state st;
HITCBC 434   3515 st_.pop(st); 439   3515 st_.pop(st);
HITCBC 435   3515 switch(st) 440   3515 switch(st)
436   { 441   {
437   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 442   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 438   538 case state::com1: goto do_com1; 443   538 case state::com1: goto do_com1;
HITCBC 439   2323 case state::com2: goto do_com2; 444   2323 case state::com2: goto do_com2;
HITCBC 440   438 case state::com3: goto do_com3; 445   438 case state::com3: goto do_com3;
HITCBC 441   216 case state::com4: goto do_com4; 446   216 case state::com4: goto do_com4;
442   } 447   }
443   } 448   }
HITCBC 444   18249 BOOST_ASSERT(*cs == '/'); 449   18249 BOOST_ASSERT(*cs == '/');
HITCBC 445   18249 ++cs; 450   18249 ++cs;
HITCBC 446   18787 do_com1: 451   18787 do_com1:
HITCBC 447   18787 if(BOOST_JSON_UNLIKELY(! cs)) 452   18787 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 448   555 return maybe_suspend(cs.begin(), state::com1); 453   555 return maybe_suspend(cs.begin(), state::com1);
HITCBC 449   18232 switch(*cs) 454   18232 switch(*cs)
450   { 455   {
HITCBC 451   5 default: 456   5 default:
452   { 457   {
453   BOOST_STATIC_CONSTEXPR source_location loc 458   BOOST_STATIC_CONSTEXPR source_location loc
454   = BOOST_CURRENT_LOCATION; 459   = BOOST_CURRENT_LOCATION;
HITCBC 455   5 return fail(cs.begin(), error::syntax, &loc); 460   5 return fail(cs.begin(), error::syntax, &loc);
456   } 461   }
HITCBC 457   10543 case '/': 462   10543 case '/':
HITCBC 458   10543 ++cs; 463   10543 ++cs;
HITCBC 459   12866 do_com2: 464   12866 do_com2:
460   // KRYSTIAN TODO: this is a mess, we have to fix this 465   // KRYSTIAN TODO: this is a mess, we have to fix this
HITCBC 461   12866 remain = cs.remain(); 466   12866 remain = cs.remain();
HITCBC 462   25732 cs = remain ? static_cast<const char*>( 467   25732 cs = remain ? static_cast<const char*>(
HITCBC 463   12866 std::memchr(cs.begin(), '\n', remain)) : sentinel(); 468   12866 std::memchr(cs.begin(), '\n', remain)) : sentinel();
HITCBC 464   12866 if(! cs.begin()) 469   12866 if(! cs.begin())
HITCBC 465   2143 cs = sentinel(); 470   2143 cs = sentinel();
HITCBC 466   12866 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 471   12866 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
467   { 472   {
468   // if the doc does not terminate 473   // if the doc does not terminate
469   // with a newline, treat it as the 474   // with a newline, treat it as the
470   // end of the comment 475   // end of the comment
HITCBC 471   2574 if(terminal && ! more_) 476   2574 if(terminal && ! more_)
472   { 477   {
HITCBC 473   39 if(BOOST_JSON_UNLIKELY(! h_.on_comment( 478   39 if(BOOST_JSON_UNLIKELY(! h_.on_comment(
474   {start, cs.remain(start)}, ec_))) 479   {start, cs.remain(start)}, ec_)))
HITCBC 475   2 return fail(cs.end()); 480   2 return fail(cs.end());
HITCBC 476   35 return cs.end(); 481   35 return cs.end();
477   } 482   }
HITCBC 478   2535 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part( 483   2535 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part(
479   {start, cs.remain(start)}, ec_))) 484   {start, cs.remain(start)}, ec_)))
HITCBC 480   96 return fail(cs.end()); 485   96 return fail(cs.end());
HITCBC 481   2343 if(terminal) 486   2343 if(terminal)
HITCBC 482   106 return suspend(cs.end(), state::com2); 487   106 return suspend(cs.end(), state::com2);
HITCBC 483   2237 return maybe_suspend(cs.end(), state::com2); 488   2237 return maybe_suspend(cs.end(), state::com2);
484   } 489   }
HITCBC 485   10292 break; 490   10292 break;
HITCBC 486   1684 case '*': 491   1684 case '*':
487   do 492   do
488   { 493   {
HITCBC 489   9368 ++cs; 494   9368 ++cs;
HITCBC 490   9806 do_com3: 495   9806 do_com3:
491   // KRYSTIAN TODO: this is a mess, we have to fix this 496   // KRYSTIAN TODO: this is a mess, we have to fix this
HITCBC 492   9806 remain = cs.remain(); 497   9806 remain = cs.remain();
HITCBC 493   19612 cs = remain ? static_cast<const char*>( 498   19612 cs = remain ? static_cast<const char*>(
HITCBC 494   9806 std::memchr(cs.begin(), '*', remain)) : sentinel(); 499   9806 std::memchr(cs.begin(), '*', remain)) : sentinel();
HITCBC 495   9806 if(! cs.begin()) 500   9806 if(! cs.begin())
HITCBC 496   242 cs = sentinel(); 501   242 cs = sentinel();
497   // stopped inside a c comment 502   // stopped inside a c comment
HITCBC 498   9806 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 503   9806 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
499   { 504   {
HITCBC 500   503 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part( 505   503 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part(
501   {start, cs.remain(start)}, ec_))) 506   {start, cs.remain(start)}, ec_)))
HITCBC 502   30 return fail(cs.end()); 507   30 return fail(cs.end());
HITCBC 503   443 return maybe_suspend(cs.end(), state::com3); 508   443 return maybe_suspend(cs.end(), state::com3);
504   } 509   }
505   // found a asterisk, check if the next char is a slash 510   // found a asterisk, check if the next char is a slash
HITCBC 506   9303 ++cs; 511   9303 ++cs;
HITCBC 507   9519 do_com4: 512   9519 do_com4:
HITCBC 508   9519 if(BOOST_JSON_UNLIKELY(! cs)) 513   9519 if(BOOST_JSON_UNLIKELY(! cs))
509   { 514   {
HITCBC 510   259 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part( 515   259 if(BOOST_JSON_UNLIKELY(! h_.on_comment_part(
511   {start, cs.used(start)}, ec_))) 516   {start, cs.used(start)}, ec_)))
HITCBC 512   18 return fail(cs.begin()); 517   18 return fail(cs.begin());
HITCBC 513   223 return maybe_suspend(cs.begin(), state::com4); 518   223 return maybe_suspend(cs.begin(), state::com4);
514   } 519   }
515   } 520   }
HITCBC 516   9260 while(*cs != '/'); 521   9260 while(*cs != '/');
517   } 522   }
HITCBC 518   17868 ++cs; 523   17868 ++cs;
HITCBC 519   17868 if(BOOST_JSON_UNLIKELY(! h_.on_comment( 524   17868 if(BOOST_JSON_UNLIKELY(! h_.on_comment(
520   {start, cs.used(start)}, ec_))) 525   {start, cs.used(start)}, ec_)))
HITCBC 521   968 return fail(cs.begin()); 526   968 return fail(cs.begin());
HITCBC 522   15932 return cs.begin(); 527   15932 return cs.begin();
523   } 528   }
524   529  
525   template<class Handler> 530   template<class Handler>
526   template<bool StackEmpty_> 531   template<bool StackEmpty_>
527   const char* 532   const char*
HITCBC 528   10710557 basic_parser<Handler>:: 533   10710592 basic_parser<Handler>::
529   parse_document(const char* p, 534   parse_document(const char* p,
530   std::integral_constant<bool, StackEmpty_> stack_empty) 535   std::integral_constant<bool, StackEmpty_> stack_empty)
531   { 536   {
HITCBC 532   10710557 detail::const_stream_wrapper cs(p, end_); 537   10710592 detail::const_stream_wrapper cs(p, end_);
HITCBC 533   10710557 if(! stack_empty && ! st_.empty()) 538   10710592 if(! stack_empty && ! st_.empty())
534   { 539   {
535   state st; 540   state st;
HITCBC 536   8561451 st_.peek(st); 541   8561473 st_.peek(st);
HITCBC 537   8561451 switch(st) 542   8561473 switch(st)
538   { 543   {
HITCBC 539   8475386 default: goto do_doc2; 544   8475408 default: goto do_doc2;
HITCBC 540   601 case state::doc1: 545   601 case state::doc1:
HITCBC 541   601 st_.pop(st); 546   601 st_.pop(st);
HITCBC 542   601 goto do_doc1; 547   601 goto do_doc1;
HITCBC 543   85244 case state::doc3: 548   85244 case state::doc3:
HITCBC 544   85244 st_.pop(st); 549   85244 st_.pop(st);
HITCBC 545   85244 goto do_doc3; 550   85244 goto do_doc3;
HITCBC 546   220 case state::com1: case state::com2: 551   220 case state::com1: case state::com2:
547   case state::com3: case state::com4: 552   case state::com3: case state::com4:
HITCBC 548   220 goto do_doc4; 553   220 goto do_doc4;
549   } 554   }
550   } 555   }
HITCBC 551   2149106 do_doc1: 556   2149119 do_doc1:
HITCBC 552   2149707 cs = detail::count_whitespace(cs.begin(), cs.end()); 557   2149720 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 553   2149707 if(BOOST_JSON_UNLIKELY(! cs)) 558   2149720 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 554   633 return maybe_suspend(cs.begin(), state::doc1); 559   633 return maybe_suspend(cs.begin(), state::doc1);
HITCBC 555   2149074 do_doc2: 560   2149087 do_doc2:
HITCBC 556   10624460 switch(+opt_.allow_comments | 561   10624495 switch(+opt_.allow_comments |
HITCBC 557   10624460 (opt_.allow_trailing_commas << 1) | 562   10624495 (opt_.allow_trailing_commas << 1) |
HITCBC 558   10624460 (opt_.allow_invalid_utf8 << 2)) 563   10624495 (opt_.allow_invalid_utf8 << 2))
559   { 564   {
560   // no extensions 565   // no extensions
HITCBC 561   10600747 default: 566   10600782 default:
HITCBC 562   10600747 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::false_type(), std::false_type(), opt_.allow_invalid_utf16); 567   10600782 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::false_type(), std::false_type(), opt_.allow_invalid_utf16);
HITCBC 563   10585525 break; 568   10585560 break;
564   // comments 569   // comments
HITCBC 565   13582 case 1: 570   13582 case 1:
HITCBC 566   13582 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::false_type(), std::false_type(), opt_.allow_invalid_utf16); 571   13582 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::false_type(), std::false_type(), opt_.allow_invalid_utf16);
HITCBC 567   11314 break; 572   11314 break;
568   // trailing 573   // trailing
HITCBC 569   6710 case 2: 574   6710 case 2:
HITCBC 570   6710 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::true_type(), std::false_type(), opt_.allow_invalid_utf16); 575   6710 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::true_type(), std::false_type(), opt_.allow_invalid_utf16);
HITCBC 571   5117 break; 576   5117 break;
572   // comments & trailing 577   // comments & trailing
HITCBC 573   761 case 3: 578   761 case 3:
HITCBC 574   761 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::true_type(), std::false_type(), opt_.allow_invalid_utf16); 579   761 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::true_type(), std::false_type(), opt_.allow_invalid_utf16);
HITCBC 575   761 break; 580   761 break;
576   // skip validation 581   // skip validation
HITCBC 577   760 case 4: 582   760 case 4:
HITCBC 578   760 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::false_type(), std::true_type(), opt_.allow_invalid_utf16); 583   760 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::false_type(), std::true_type(), opt_.allow_invalid_utf16);
HITCBC 579   760 break; 584   760 break;
580   // comments & skip validation 585   // comments & skip validation
HITCBC 581   760 case 5: 586   760 case 5:
HITCBC 582   760 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::false_type(), std::true_type(), opt_.allow_invalid_utf16); 587   760 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::false_type(), std::true_type(), opt_.allow_invalid_utf16);
HITCBC 583   760 break; 588   760 break;
584   // trailing & skip validation 589   // trailing & skip validation
HITCBC 585   760 case 6: 590   760 case 6:
HITCBC 586   760 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::true_type(), std::true_type(), opt_.allow_invalid_utf16); 591   760 cs = parse_value(cs.begin(), stack_empty, std::false_type(), std::true_type(), std::true_type(), opt_.allow_invalid_utf16);
HITCBC 587   760 break; 592   760 break;
588   // comments & trailing & skip validation 593   // comments & trailing & skip validation
HITCBC 589   380 case 7: 594   380 case 7:
HITCBC 590   380 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::true_type(), std::true_type(), opt_.allow_invalid_utf16); 595   380 cs = parse_value(cs.begin(), stack_empty, std::true_type(), std::true_type(), std::true_type(), opt_.allow_invalid_utf16);
HITCBC 591   380 break; 596   380 break;
592   } 597   }
HITCBC 593   10605377 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 598   10605412 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
594   // the appropriate state has already been pushed into stack 599   // the appropriate state has already been pushed into stack
HITCBC 595   8502684 return sentinel(); 600   8502706 return sentinel();
HITCBC 596   2102693 do_doc3: 601   2102706 do_doc3:
HITCBC 597   2188269 cs = detail::count_whitespace(cs.begin(), cs.end()); 602   2188282 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 598   2188269 if(BOOST_JSON_UNLIKELY(! cs)) 603   2188282 if(BOOST_JSON_UNLIKELY(! cs))
599   { 604   {
HITCBC 600   2185671 if(more_) 605   2185684 if(more_)
HITCBC 601   88551 return suspend(cs.begin(), state::doc3); 606   88551 return suspend(cs.begin(), state::doc3);
602   } 607   }
HITCBC 603   2598 else if(opt_.allow_comments && *cs == '/') 608   2598 else if(opt_.allow_comments && *cs == '/')
604   { 609   {
HITCBC 605   536 do_doc4: 610   536 do_doc4:
HITCBC 606   756 cs = parse_comment(cs.begin(), stack_empty, std::true_type()); 611   756 cs = parse_comment(cs.begin(), stack_empty, std::true_type());
HITCBC 607   671 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 612   671 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 608   339 return sentinel(); 613   339 return sentinel();
HITCBC 609   332 goto do_doc3; 614   332 goto do_doc3;
610   } 615   }
HITCBC 611   2099182 return cs.begin(); 616   2099195 return cs.begin();
612   } 617   }
613   618  
614   template<class Handler> 619   template<class Handler>
615   template< 620   template<
616   bool StackEmpty_, 621   bool StackEmpty_,
617   bool AllowComments_/*, 622   bool AllowComments_/*,
618   bool AllowTrailing_, 623   bool AllowTrailing_,
619   bool AllowBadUTF8_*/> 624   bool AllowBadUTF8_*/>
620   const char* 625   const char*
HITCBC 621   10742094 basic_parser<Handler>:: 626   10742129 basic_parser<Handler>::
622   parse_value(const char* p, 627   parse_value(const char* p,
623   std::integral_constant<bool, StackEmpty_> stack_empty, 628   std::integral_constant<bool, StackEmpty_> stack_empty,
624   std::integral_constant<bool, AllowComments_> allow_comments, 629   std::integral_constant<bool, AllowComments_> allow_comments,
625   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing, 630   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
626   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8, 631   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
627   bool allow_bad_utf16) 632   bool allow_bad_utf16)
628   { 633   {
HITCBC 629   10742094 if(stack_empty || st_.empty()) 634   10742129 if(stack_empty || st_.empty())
630   { 635   {
HITCBC 631   2248322 loop: 636   2248335 loop:
HITCBC 632   2253238 switch(*p) 637   2253251 switch(*p)
633   { 638   {
HITCBC 634   22755 case '0': 639   22761 case '0':
HITCBC 635   22755 return mp11::mp_with_index<3>( 640   22761 return mp11::mp_with_index<3>(
HITCBC 636   22755 static_cast<unsigned char>(opt_.numbers), 641   22761 static_cast<unsigned char>(opt_.numbers),
HITCBC 637   22094 parse_number_helper<true, '0'>{ this, p }); 642   22100 parse_number_helper<true, '0'>{ this, p });
HITCBC 638   25178 case '-': 643   25185 case '-':
HITCBC 639   25178 return mp11::mp_with_index<3>( 644   25185 return mp11::mp_with_index<3>(
HITCBC 640   25178 static_cast<unsigned char>(opt_.numbers), 645   25185 static_cast<unsigned char>(opt_.numbers),
HITCBC 641   24066 parse_number_helper<true, '-'>{ this, p }); 646   24073 parse_number_helper<true, '-'>{ this, p });
HITCBC 642   2042025 case '1': case '2': case '3': 647   2042025 case '1': case '2': case '3':
643   case '4': case '5': case '6': 648   case '4': case '5': case '6':
644   case '7': case '8': case '9': 649   case '7': case '8': case '9':
HITCBC 645   2042025 return mp11::mp_with_index<3>( 650   2042025 return mp11::mp_with_index<3>(
HITCBC 646   2042025 static_cast<unsigned char>(opt_.numbers), 651   2042025 static_cast<unsigned char>(opt_.numbers),
HITCBC 647   2039149 parse_number_helper<true, '+'>{ this, p }); 652   2039149 parse_number_helper<true, '+'>{ this, p });
HITCBC 648   11381 case 'n': 653   11381 case 'n':
HITCBC 649   11381 return parse_literal( p, detail::literals_c<detail::literals::null>() ); 654   11381 return parse_literal( p, detail::literals_c<detail::literals::null>() );
HITCBC 650   664 case 't': 655   664 case 't':
HITCBC 651   664 return parse_literal( p, detail::literals_c<detail::literals::true_>() ); 656   664 return parse_literal( p, detail::literals_c<detail::literals::true_>() );
HITCBC 652   722 case 'f': 657   722 case 'f':
HITCBC 653   722 return parse_literal( p, detail::literals_c<detail::literals::false_>() ); 658   722 return parse_literal( p, detail::literals_c<detail::literals::false_>() );
HITCBC 654   681 case 'I': 659   681 case 'I':
HITCBC 655   681 if( !opt_.allow_infinity_and_nan ) 660   681 if( !opt_.allow_infinity_and_nan )
656   { 661   {
657   BOOST_STATIC_CONSTEXPR source_location loc 662   BOOST_STATIC_CONSTEXPR source_location loc
658   = BOOST_CURRENT_LOCATION; 663   = BOOST_CURRENT_LOCATION;
HITCBC 659   24 return fail(p, error::syntax, &loc); 664   24 return fail(p, error::syntax, &loc);
660   } 665   }
HITCBC 661   657 return parse_literal( p, detail::literals_c<detail::literals::infinity>() ); 666   657 return parse_literal( p, detail::literals_c<detail::literals::infinity>() );
HITCBC 662   231 case 'N': 667   231 case 'N':
HITCBC 663   231 if( !opt_.allow_infinity_and_nan ) 668   231 if( !opt_.allow_infinity_and_nan )
664   { 669   {
665   BOOST_STATIC_CONSTEXPR source_location loc 670   BOOST_STATIC_CONSTEXPR source_location loc
666   = BOOST_CURRENT_LOCATION; 671   = BOOST_CURRENT_LOCATION;
HITCBC 667   30 return fail(p, error::syntax, &loc); 672   30 return fail(p, error::syntax, &loc);
668   } 673   }
HITCBC 669   201 return parse_literal(p, detail::literals_c<detail::literals::nan>() ); 674   201 return parse_literal(p, detail::literals_c<detail::literals::nan>() );
HITCBC 670   47587 case '"': 675   47587 case '"':
HITCBC 671   47587 return parse_string(p, std::true_type(), std::false_type(), allow_bad_utf8, allow_bad_utf16); 676   47587 return parse_string(p, std::true_type(), std::false_type(), allow_bad_utf8, allow_bad_utf16);
HITCBC 672   20618 case '[': 677   20618 case '[':
HITCBC 673   20618 return parse_array(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 678   20618 return parse_array(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
HITCBC 674   74131 case '{': 679   74131 case '{':
HITCBC 675   74131 return parse_object(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 680   74131 return parse_object(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
HITCBC 676   6144 case '/': 681   6144 case '/':
HITCBC 677   6144 if(! allow_comments) 682   6144 if(! allow_comments)
678   { 683   {
679   BOOST_STATIC_CONSTEXPR source_location loc 684   BOOST_STATIC_CONSTEXPR source_location loc
680   = BOOST_CURRENT_LOCATION; 685   = BOOST_CURRENT_LOCATION;
HITCBC 681   284 return fail(p, error::syntax, &loc); 686   284 return fail(p, error::syntax, &loc);
682   } 687   }
HITCBC 683   5860 p = parse_comment(p, stack_empty, std::false_type()); 688   5860 p = parse_comment(p, stack_empty, std::false_type());
684   // KRYSTIAN NOTE: incomplete takes const_stream, we either 689   // KRYSTIAN NOTE: incomplete takes const_stream, we either
685   // can add an overload, change the existing one to take a pointer, 690   // can add an overload, change the existing one to take a pointer,
686   // or just leave it as is 691   // or just leave it as is
HITCBC 687   5621 if(BOOST_JSON_UNLIKELY(p == sentinel())) 692   5621 if(BOOST_JSON_UNLIKELY(p == sentinel()))
HITCBC 688   602 return maybe_suspend(p, state::val2); 693   602 return maybe_suspend(p, state::val2);
689   BOOST_FALLTHROUGH; 694   BOOST_FALLTHROUGH;
690   case ' ': 695   case ' ':
691   case '\t': 696   case '\t':
692   case '\n': 697   case '\n':
693   case '\r': 698   case '\r':
HITCBC 694   5035 p = detail::count_whitespace(p, end_); 699   5035 p = detail::count_whitespace(p, end_);
HITCBC 695   5035 if(BOOST_JSON_UNLIKELY(p == end_)) 700   5035 if(BOOST_JSON_UNLIKELY(p == end_))
HITCBC 696   119 return maybe_suspend(p, state::val1); 701   119 return maybe_suspend(p, state::val1);
HITCBC 697   4916 goto loop; 702   4916 goto loop;
HITCBC 698   1105 default: 703   1105 default:
699   { 704   {
700   BOOST_STATIC_CONSTEXPR source_location loc 705   BOOST_STATIC_CONSTEXPR source_location loc
701   = BOOST_CURRENT_LOCATION; 706   = BOOST_CURRENT_LOCATION;
HITCBC 702   1105 return fail(p, error::syntax, &loc); 707   1105 return fail(p, error::syntax, &loc);
703   } 708   }
704   } 709   }
705   } 710   }
HITCBC 706   8493772 return resume_value(p, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 711   8493794 return resume_value(p, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
707   } 712   }
708   713  
709   template<class Handler> 714   template<class Handler>
710   template< 715   template<
711   bool AllowComments_/*, 716   bool AllowComments_/*,
712   bool AllowTrailing_, 717   bool AllowTrailing_,
713   bool AllowBadUTF8_*/> 718   bool AllowBadUTF8_*/>
714   const char* 719   const char*
HITCBC 715   8493772 basic_parser<Handler>:: 720   8493794 basic_parser<Handler>::
716   resume_value(const char* p, 721   resume_value(const char* p,
717   std::integral_constant<bool, AllowComments_> allow_comments, 722   std::integral_constant<bool, AllowComments_> allow_comments,
718   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing, 723   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
719   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8, 724   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
720   bool allow_bad_utf16) 725   bool allow_bad_utf16)
721   { 726   {
722   state st; 727   state st;
HITCBC 723   8493772 st_.peek(st); 728   8493794 st_.peek(st);
HITCBC 724   8493772 switch(st) 729   8493794 switch(st)
725   { 730   {
726   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 731   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 727   1924 case state::lit1: 732   1924 case state::lit1:
HITCBC 728   1924 return parse_literal(p, detail::literals_c<detail::literals::resume>() ); 733   1924 return parse_literal(p, detail::literals_c<detail::literals::resume>() );
729   734  
HITCBC 730   23268 case state::str1: case state::str2: 735   23268 case state::str1: case state::str2:
731   case state::str8: 736   case state::str8:
HITCBC 732   23268 return parse_string(p, std::false_type(), std::false_type(), allow_bad_utf8, allow_bad_utf16); 737   23268 return parse_string(p, std::false_type(), std::false_type(), allow_bad_utf8, allow_bad_utf16);
733   738  
HITCBC 734   5730 case state::arr1: case state::arr2: 739   5730 case state::arr1: case state::arr2:
735   case state::arr3: case state::arr4: 740   case state::arr3: case state::arr4:
736   case state::arr5: case state::arr6: 741   case state::arr5: case state::arr6:
HITCBC 737   5730 return parse_array(p, std::false_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 742   5730 return parse_array(p, std::false_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
738   743  
HITCBC 739   35058 case state::obj1: case state::obj2: 744   35058 case state::obj1: case state::obj2:
740   case state::obj3: case state::obj4: 745   case state::obj3: case state::obj4:
741   case state::obj5: case state::obj6: 746   case state::obj5: case state::obj6:
742   case state::obj7: case state::obj8: 747   case state::obj7: case state::obj8:
743   case state::obj9: case state::obj10: 748   case state::obj9: case state::obj10:
744   case state::obj11: 749   case state::obj11:
HITCBC 745   35058 return parse_object(p, std::false_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 750   35058 return parse_object(p, std::false_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
746   751  
HITCBC 747   8425997 case state::num1: case state::num2: 752   8426019 case state::num1: case state::num2:
748   case state::num3: case state::num4: 753   case state::num3: case state::num4:
749   case state::num5: case state::num6: 754   case state::num5: case state::num6:
750   case state::num7: case state::num8: 755   case state::num7: case state::num8:
751   case state::exp1: case state::exp2: 756   case state::exp1: case state::exp2:
752   case state::exp3: 757   case state::exp3:
HITCBC 753   8425997 return mp11::mp_with_index<3>( 758   8426019 return mp11::mp_with_index<3>(
HITCBC 754   8425997 static_cast<unsigned char>(opt_.numbers), 759   8426019 static_cast<unsigned char>(opt_.numbers),
HITCBC 755   8425142 parse_number_helper<false, 0>{ this, p }); 760   8425164 parse_number_helper<false, 0>{ this, p });
756   761  
757   // KRYSTIAN NOTE: these are special cases 762   // KRYSTIAN NOTE: these are special cases
HITCBC 758   112 case state::val1: 763   112 case state::val1:
759   { 764   {
HITCBC 760   112 st_.pop(st); 765   112 st_.pop(st);
HITCBC 761   112 BOOST_ASSERT(st_.empty()); 766   112 BOOST_ASSERT(st_.empty());
HITCBC 762   112 p = detail::count_whitespace(p, end_); 767   112 p = detail::count_whitespace(p, end_);
HITCBC 763   112 if(BOOST_JSON_UNLIKELY(p == end_)) 768   112 if(BOOST_JSON_UNLIKELY(p == end_))
HITCBC 764   4 return maybe_suspend(p, state::val1); 769   4 return maybe_suspend(p, state::val1);
HITCBC 765   108 return parse_value(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 770   108 return parse_value(p, std::true_type(), allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
766   } 771   }
767   772  
HITCBC 768   1616 case state::val2: 773   1616 case state::val2:
769   { 774   {
HITCBC 770   1616 st_.pop(st); 775   1616 st_.pop(st);
HITCBC 771   1616 p = parse_comment(p, std::false_type(), std::false_type()); 776   1616 p = parse_comment(p, std::false_type(), std::false_type());
HITCBC 772   1596 if(BOOST_JSON_UNLIKELY(p == sentinel())) 777   1596 if(BOOST_JSON_UNLIKELY(p == sentinel()))
HITCBC 773   1276 return maybe_suspend(p, state::val2); 778   1276 return maybe_suspend(p, state::val2);
HITCBC 774   320 if(BOOST_JSON_UNLIKELY( p == end_ )) 779   320 if(BOOST_JSON_UNLIKELY( p == end_ ))
HITCBC 775   77 return maybe_suspend(p, state::val3); 780   77 return maybe_suspend(p, state::val3);
HITCBC 776   243 BOOST_ASSERT(st_.empty()); 781   243 BOOST_ASSERT(st_.empty());
HITCBC 777   243 return parse_value(p, std::true_type(), std::true_type(), allow_trailing, allow_bad_utf8, allow_bad_utf16); 782   243 return parse_value(p, std::true_type(), std::true_type(), allow_trailing, allow_bad_utf8, allow_bad_utf16);
778   } 783   }
779   784  
HITCBC 780   67 case state::val3: 785   67 case state::val3:
781   { 786   {
HITCBC 782   67 st_.pop(st); 787   67 st_.pop(st);
HITCBC 783   67 return parse_value(p, std::true_type(), std::true_type(), allow_trailing, allow_bad_utf8, allow_bad_utf16); 788   67 return parse_value(p, std::true_type(), std::true_type(), allow_trailing, allow_bad_utf8, allow_bad_utf16);
784   } 789   }
785   } 790   }
786   } 791   }
787   792  
788   template<class Handler> 793   template<class Handler>
789   template<class Literal> 794   template<class Literal>
790   const char* 795   const char*
HITCBC 791   16565 basic_parser<Handler>:: 796   16565 basic_parser<Handler>::
792   parse_literal(const char* p, Literal) 797   parse_literal(const char* p, Literal)
793   { 798   {
794   using L = detail::literals; 799   using L = detail::literals;
795   800  
796   std::size_t cur_lit; 801   std::size_t cur_lit;
797   std::size_t offset; 802   std::size_t offset;
798   803  
HITCBC 799   16565 detail::const_stream_wrapper cs(p, end_); 804   16565 detail::const_stream_wrapper cs(p, end_);
800   BOOST_IF_CONSTEXPR( Literal::value != L::resume ) 805   BOOST_IF_CONSTEXPR( Literal::value != L::resume )
801   { 806   {
HITCBC 802   13634 constexpr std::size_t index = literal_index(Literal::value); 807   13634 constexpr std::size_t index = literal_index(Literal::value);
HITCBC 803   13634 constexpr char const* literal = detail::literal_strings[index]; 808   13634 constexpr char const* literal = detail::literal_strings[index];
HITCBC 804   13634 constexpr std::size_t sz = detail::literal_sizes[index]; 809   13634 constexpr std::size_t sz = detail::literal_sizes[index];
805   810  
HITCBC 806   13634 if(BOOST_JSON_LIKELY( cs.remain() >= sz )) 811   13634 if(BOOST_JSON_LIKELY( cs.remain() >= sz ))
807   { 812   {
HITCBC 808   11984 int const cmp = std::memcmp(cs.begin(), literal, sz); 813   11984 int const cmp = std::memcmp(cs.begin(), literal, sz);
HITCBC 809   11984 if( cmp != 0 ) 814   11984 if( cmp != 0 )
810   { 815   {
811   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 816   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 812   197 return fail(cs.begin(), error::syntax, &loc); 817   197 return fail(cs.begin(), error::syntax, &loc);
813   } 818   }
814   819  
815   BOOST_IF_CONSTEXPR( Literal::value == L::null ) 820   BOOST_IF_CONSTEXPR( Literal::value == L::null )
816   { 821   {
HITCBC 817   10789 if(BOOST_JSON_UNLIKELY( 822   10789 if(BOOST_JSON_UNLIKELY(
818   ! h_.on_null(ec_))) 823   ! h_.on_null(ec_)))
HITCBC 819   161 return fail(cs.begin()); 824   161 return fail(cs.begin());
820   } 825   }
821   else BOOST_IF_CONSTEXPR( Literal::value == L::true_ ) 826   else BOOST_IF_CONSTEXPR( Literal::value == L::true_ )
822   { 827   {
HITCBC 823   384 if(BOOST_JSON_UNLIKELY( 828   384 if(BOOST_JSON_UNLIKELY(
824   ! h_.on_bool(true, ec_))) 829   ! h_.on_bool(true, ec_)))
HITCBC 825   14 return fail(cs.begin()); 830   14 return fail(cs.begin());
826   } 831   }
827   else BOOST_IF_CONSTEXPR( Literal::value == L::false_ ) 832   else BOOST_IF_CONSTEXPR( Literal::value == L::false_ )
828   { 833   {
HITCBC 829   406 if(BOOST_JSON_UNLIKELY( 834   406 if(BOOST_JSON_UNLIKELY(
830   ! h_.on_bool(false, ec_))) 835   ! h_.on_bool(false, ec_)))
HITCBC 831   13 return fail(cs.begin()); 836   13 return fail(cs.begin());
832   } 837   }
833   else BOOST_IF_CONSTEXPR( Literal::value == L::infinity ) 838   else BOOST_IF_CONSTEXPR( Literal::value == L::infinity )
834   { 839   {
HITCBC 835   103 if(BOOST_JSON_UNLIKELY( 840   103 if(BOOST_JSON_UNLIKELY(
836   ! h_.on_double( 841   ! h_.on_double(
837   std::numeric_limits<double>::infinity(), 842   std::numeric_limits<double>::infinity(),
838   string_view(literal, sz), 843   string_view(literal, sz),
839   ec_))) 844   ec_)))
HITCBC 840   13 return fail(cs.begin()); 845   13 return fail(cs.begin());
841   } 846   }
842   else BOOST_IF_CONSTEXPR( Literal::value == L::neg_infinity ) 847   else BOOST_IF_CONSTEXPR( Literal::value == L::neg_infinity )
843   { 848   {
HITCBC 844   9 if(BOOST_JSON_UNLIKELY( 849   9 if(BOOST_JSON_UNLIKELY(
845   ! h_.on_double( 850   ! h_.on_double(
846   -std::numeric_limits<double>::infinity(), 851   -std::numeric_limits<double>::infinity(),
847   string_view(literal, sz), 852   string_view(literal, sz),
848   ec_))) 853   ec_)))
HITCBC 849   1 return fail(cs.begin()); 854   1 return fail(cs.begin());
850   } 855   }
851   else BOOST_IF_CONSTEXPR( Literal::value == L::nan ) 856   else BOOST_IF_CONSTEXPR( Literal::value == L::nan )
852   { 857   {
HITCBC 853   96 if(BOOST_JSON_UNLIKELY( 858   96 if(BOOST_JSON_UNLIKELY(
854   ! h_.on_double( 859   ! h_.on_double(
855   std::numeric_limits<double>::quiet_NaN(), 860   std::numeric_limits<double>::quiet_NaN(),
856   string_view(literal, sz), 861   string_view(literal, sz),
857   ec_))) 862   ec_)))
HITCBC 858   12 return fail(cs.begin()); 863   12 return fail(cs.begin());
859   } 864   }
860   else 865   else
861   { 866   {
862   BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 867   BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
863   } 868   }
864   869  
HITCBC 865   11363 cs += sz; 870   11363 cs += sz;
HITCBC 866   11363 return cs.begin(); 871   11363 return cs.begin();
867   } 872   }
868   873  
HITCBC 869   1650 offset = 0; 874   1650 offset = 0;
HITCBC 870   1650 cur_lit = index; 875   1650 cur_lit = index;
871   } 876   }
872   else 877   else
873   { 878   {
874   state st; 879   state st;
HITCBC 875   2931 st_.pop(st); 880   2931 st_.pop(st);
HITCBC 876   2931 BOOST_ASSERT( st == state::lit1 ); 881   2931 BOOST_ASSERT( st == state::lit1 );
877   882  
HITCBC 878   2931 cur_lit = cur_lit_; 883   2931 cur_lit = cur_lit_;
HITCBC 879   2931 offset = lit_offset_; 884   2931 offset = lit_offset_;
880   } 885   }
881   886  
HITCBC 882   4581 std::size_t const lit_size = detail::literal_sizes[cur_lit]; 887   4581 std::size_t const lit_size = detail::literal_sizes[cur_lit];
HITCBC 883   4581 std::size_t const size = (std::min)( lit_size - offset, cs.remain() ); 888   4581 std::size_t const size = (std::min)( lit_size - offset, cs.remain() );
HITCBC 884   4581 int cmp = 0; 889   4581 int cmp = 0;
HITCBC 885   4581 if(BOOST_JSON_LIKELY( cs.begin() )) 890   4581 if(BOOST_JSON_LIKELY( cs.begin() ))
HITCBC 886   4580 cmp = std::memcmp( 891   4580 cmp = std::memcmp(
HITCBC 887   4580 cs.begin(), detail::literal_strings[cur_lit] + offset, size ); 892   4580 cs.begin(), detail::literal_strings[cur_lit] + offset, size );
HITCBC 888   4581 if( cmp != 0 ) 893   4581 if( cmp != 0 )
889   { 894   {
890   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 895   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 891   699 return fail(cs.begin(), error::syntax, &loc); 896   699 return fail(cs.begin(), error::syntax, &loc);
892   } 897   }
893   898  
HITCBC 894   3882 if(BOOST_JSON_UNLIKELY( offset + size < lit_size )) 899   3882 if(BOOST_JSON_UNLIKELY( offset + size < lit_size ))
895   { 900   {
HITCBC 896   1990 BOOST_ASSERT( cur_lit < 256 ); 901   1990 BOOST_ASSERT( cur_lit < 256 );
HITCBC 897   1990 cur_lit_ = static_cast<unsigned char>( cur_lit ); 902   1990 cur_lit_ = static_cast<unsigned char>( cur_lit );
HITCBC 898   1990 BOOST_ASSERT( offset + size < 256 ); 903   1990 BOOST_ASSERT( offset + size < 256 );
HITCBC 899   1990 lit_offset_ = static_cast<unsigned char>( offset + size ); 904   1990 lit_offset_ = static_cast<unsigned char>( offset + size );
HITCBC 900   1990 return maybe_suspend(cs.begin() + size, state::lit1); 905   1990 return maybe_suspend(cs.begin() + size, state::lit1);
901   } 906   }
902   907  
HITCBC 903   1892 switch( static_cast<L>(cur_lit) ) 908   1892 switch( static_cast<L>(cur_lit) )
904   { 909   {
HITCBC 905   472 case L::null: 910   472 case L::null:
HITCBC 906   472 if(BOOST_JSON_UNLIKELY( 911   472 if(BOOST_JSON_UNLIKELY(
907   ! h_.on_null(ec_))) 912   ! h_.on_null(ec_)))
HITCBC 908   61 return fail(cs.begin()); 913   61 return fail(cs.begin());
HITCBC 909   351 break; 914   351 break;
HITCBC 910   152 case L::true_: 915   152 case L::true_:
HITCBC 911   152 if(BOOST_JSON_UNLIKELY( 916   152 if(BOOST_JSON_UNLIKELY(
912   ! h_.on_bool(true, ec_))) 917   ! h_.on_bool(true, ec_)))
HITCBC 913   22 return fail(cs.begin()); 918   22 return fail(cs.begin());
HITCBC 914   109 break; 919   109 break;
HITCBC 915   198 case L::false_: 920   198 case L::false_:
HITCBC 916   198 if(BOOST_JSON_UNLIKELY( 921   198 if(BOOST_JSON_UNLIKELY(
917   ! h_.on_bool(false, ec_))) 922   ! h_.on_bool(false, ec_)))
HITCBC 918   28 return fail(cs.begin()); 923   28 return fail(cs.begin());
HITCBC 919   142 break; 924   142 break;
HITCBC 920   308 case L::infinity: 925   308 case L::infinity:
HITCBC 921   308 if(BOOST_JSON_UNLIKELY( 926   308 if(BOOST_JSON_UNLIKELY(
922   ! h_.on_double( 927   ! h_.on_double(
923   std::numeric_limits<double>::infinity(), 928   std::numeric_limits<double>::infinity(),
924   string_view( 929   string_view(
925   detail::literal_strings[ literal_index(L::infinity) ], 930   detail::literal_strings[ literal_index(L::infinity) ],
926   detail::literal_sizes[ literal_index(L::infinity) ]), 931   detail::literal_sizes[ literal_index(L::infinity) ]),
927   ec_))) 932   ec_)))
HITCBC 928   49 return fail(cs.begin()); 933   49 return fail(cs.begin());
HITCBC 929   210 break; 934   210 break;
HITCBC 930   686 case L::neg_infinity: 935   686 case L::neg_infinity:
HITCBC 931   686 if(BOOST_JSON_UNLIKELY( 936   686 if(BOOST_JSON_UNLIKELY(
932   ! h_.on_double( 937   ! h_.on_double(
933   -std::numeric_limits<double>::infinity(), 938   -std::numeric_limits<double>::infinity(),
934   string_view( 939   string_view(
935   detail::literal_strings[ literal_index(L::neg_infinity) ], 940   detail::literal_strings[ literal_index(L::neg_infinity) ],
936   detail::literal_sizes[ literal_index(L::neg_infinity) ]), 941   detail::literal_sizes[ literal_index(L::neg_infinity) ]),
937   ec_))) 942   ec_)))
HITCBC 938   102 return fail(cs.begin()); 943   102 return fail(cs.begin());
HITCBC 939   482 break; 944   482 break;
HITCBC 940   76 case L::nan: 945   76 case L::nan:
HITCBC 941   76 if(BOOST_JSON_UNLIKELY( 946   76 if(BOOST_JSON_UNLIKELY(
942   ! h_.on_double( 947   ! h_.on_double(
943   std::numeric_limits<double>::quiet_NaN(), 948   std::numeric_limits<double>::quiet_NaN(),
944   string_view( 949   string_view(
945   detail::literal_strings[ literal_index(L::nan) ], 950   detail::literal_strings[ literal_index(L::nan) ],
946   detail::literal_sizes[ literal_index(L::nan) ]), 951   detail::literal_sizes[ literal_index(L::nan) ]),
947   ec_))) 952   ec_)))
HITCBC 948   12 return fail(cs.begin()); 953   12 return fail(cs.begin());
HITCBC 949   52 break; 954   52 break;
950   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 955   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
951   } 956   }
952   957  
HITCBC 953   1346 cs += size; 958   1346 cs += size;
HITCBC 954   1346 return cs.begin(); 959   1346 return cs.begin();
955   } 960   }
956   961  
957   //---------------------------------------------------------- 962   //----------------------------------------------------------
958   963  
959   template<class Handler> 964   template<class Handler>
960   template<bool StackEmpty_, bool IsKey_> 965   template<bool StackEmpty_, bool IsKey_>
961   const char* 966   const char*
HITCBC 962   164330 basic_parser<Handler>:: 967   164330 basic_parser<Handler>::
963   parse_string(const char* p, 968   parse_string(const char* p,
964   std::integral_constant<bool, StackEmpty_> stack_empty, 969   std::integral_constant<bool, StackEmpty_> stack_empty,
965   std::integral_constant<bool, IsKey_> is_key, 970   std::integral_constant<bool, IsKey_> is_key,
966   bool allow_bad_utf8, 971   bool allow_bad_utf8,
967   bool allow_bad_utf16) 972   bool allow_bad_utf16)
968   { 973   {
HITCBC 969   164330 detail::const_stream_wrapper cs(p, end_); 974   164330 detail::const_stream_wrapper cs(p, end_);
970   std::size_t total; 975   std::size_t total;
971   char const* start; 976   char const* start;
972   std::size_t size; 977   std::size_t size;
HITCBC 973   164330 if(! stack_empty && ! st_.empty()) 978   164330 if(! stack_empty && ! st_.empty())
974   { 979   {
975   state st; 980   state st;
HITCBC 976   35915 st_.pop(st); 981   35915 st_.pop(st);
HITCBC 977   35915 st_.pop(total); 982   35915 st_.pop(total);
HITCBC 978   35915 switch(st) 983   35915 switch(st)
979   { 984   {
980   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 985   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 981   3149 case state::str2: goto do_str2; 986   3149 case state::str2: goto do_str2;
HITCBC 982   1868 case state::str8: goto do_str8; 987   1868 case state::str8: goto do_str8;
HITCBC 983   30898 case state::str1: break; 988   30898 case state::str1: break;
984   } 989   }
985   } 990   }
986   else 991   else
987   { 992   {
HITCBC 988   128415 BOOST_ASSERT(*cs == '\x22'); // '"' 993   128415 BOOST_ASSERT(*cs == '\x22'); // '"'
HITCBC 989   128415 ++cs; 994   128415 ++cs;
HITCBC 990   128415 total = 0; 995   128415 total = 0;
991   } 996   }
992   997  
HITCBC 993   167806 do_str1: 998   167806 do_str1:
HITCBC 994   167806 start = cs.begin(); 999   167806 start = cs.begin();
HITCBC 995   335612 cs = allow_bad_utf8? 1000   335612 cs = allow_bad_utf8?
HITCBC 996   2177 detail::count_valid<true>(cs.begin(), cs.end()): 1001   2177 detail::count_valid<true>(cs.begin(), cs.end()):
HITCBC 997   165629 detail::count_valid<false>(cs.begin(), cs.end()); 1002   165629 detail::count_valid<false>(cs.begin(), cs.end());
HITCBC 998   167806 size = cs.used(start); 1003   167806 size = cs.used(start);
HITCBC 999   167806 if(is_key) 1004   167806 if(is_key)
1000   { 1005   {
HITCBC 1001   46694 BOOST_ASSERT(total <= Handler::max_key_size); 1006   46694 BOOST_ASSERT(total <= Handler::max_key_size);
HITCBC 1002   94005 if(BOOST_JSON_UNLIKELY(size > 1007   94005 if(BOOST_JSON_UNLIKELY(size >
1003   Handler::max_key_size - total)) 1008   Handler::max_key_size - total))
1004   { 1009   {
1005   BOOST_STATIC_CONSTEXPR source_location loc 1010   BOOST_STATIC_CONSTEXPR source_location loc
1006   = BOOST_CURRENT_LOCATION; 1011   = BOOST_CURRENT_LOCATION;
HITCBC 1007   3 return fail(cs.begin(), error::key_too_large, &loc); 1012   3 return fail(cs.begin(), error::key_too_large, &loc);
1008   } 1013   }
1009   } 1014   }
1010   else 1015   else
1011   { 1016   {
HITCBC 1012   38330 BOOST_ASSERT(total <= Handler::max_string_size); 1017   38330 BOOST_ASSERT(total <= Handler::max_string_size);
HITCBC 1013   73801 if(BOOST_JSON_UNLIKELY(size > 1018   73801 if(BOOST_JSON_UNLIKELY(size >
1014   Handler::max_string_size - total)) 1019   Handler::max_string_size - total))
1015   { 1020   {
1016   BOOST_STATIC_CONSTEXPR source_location loc 1021   BOOST_STATIC_CONSTEXPR source_location loc
1017   = BOOST_CURRENT_LOCATION; 1022   = BOOST_CURRENT_LOCATION;
HITCBC 1018   3 return fail(cs.begin(), error::string_too_large, &loc); 1023   3 return fail(cs.begin(), error::string_too_large, &loc);
1019   } 1024   }
1020   } 1025   }
HITCBC 1021   167800 total += size; 1026   167800 total += size;
HITCBC 1022   167800 if(BOOST_JSON_UNLIKELY(! cs)) 1027   167800 if(BOOST_JSON_UNLIKELY(! cs))
1023   { 1028   {
1024   // call handler if the string isn't empty 1029   // call handler if the string isn't empty
HITCBC 1025   33232 if(BOOST_JSON_LIKELY(size)) 1030   33232 if(BOOST_JSON_LIKELY(size))
1026   { 1031   {
1027   { 1032   {
HITCBC 1028   30066 bool r = is_key? 1033   30066 bool r = is_key?
HITCBC 1029   12404 h_.on_key_part( {start, size}, total, ec_ ): 1034   12404 h_.on_key_part( {start, size}, total, ec_ ):
HITCBC 1030   18996 h_.on_string_part( {start, size}, total, ec_ ); 1035   18996 h_.on_string_part( {start, size}, total, ec_ );
1031   1036  
HITCBC 1032   28958 if(BOOST_JSON_UNLIKELY(!r)) 1037   28958 if(BOOST_JSON_UNLIKELY(!r))
1033   { 1038   {
HITCBC 1034   1110 return fail(cs.begin()); 1039   1110 return fail(cs.begin());
1035   } 1040   }
1036   } 1041   }
1037   } 1042   }
HITCBC 1038   31014 return maybe_suspend(cs.begin(), state::str1, total); 1043   31014 return maybe_suspend(cs.begin(), state::str1, total);
1039   } 1044   }
1040   // at this point all valid characters have been skipped, so any remaining 1045   // at this point all valid characters have been skipped, so any remaining
1041   // if there are any more characters, they are either escaped, or incomplete 1046   // if there are any more characters, they are either escaped, or incomplete
1042   // utf8, or invalid utf8 1047   // utf8, or invalid utf8
HITCBC 1043   134568 if(BOOST_JSON_UNLIKELY(*cs != '\x22')) // '"' 1048   134568 if(BOOST_JSON_UNLIKELY(*cs != '\x22')) // '"'
1044   { 1049   {
1045   // sequence is invalid or incomplete 1050   // sequence is invalid or incomplete
HITCBC 1046   15081 if((*cs & 0x80) && !allow_bad_utf8) 1051   15081 if((*cs & 0x80) && !allow_bad_utf8)
1047   { 1052   {
HITCBC 1048   3472 seq_.save(cs.begin(), cs.remain()); 1053   3472 seq_.save(cs.begin(), cs.remain());
HITCBC 1049   3472 if(BOOST_JSON_UNLIKELY(seq_.complete())) 1054   3472 if(BOOST_JSON_UNLIKELY(seq_.complete()))
1050   { 1055   {
1051   BOOST_STATIC_CONSTEXPR source_location loc 1056   BOOST_STATIC_CONSTEXPR source_location loc
1052   = BOOST_CURRENT_LOCATION; 1057   = BOOST_CURRENT_LOCATION;
HITCBC 1053   1557 return fail(cs.begin(), error::syntax, &loc); 1058   1557 return fail(cs.begin(), error::syntax, &loc);
1054   } 1059   }
HITCBC 1055   1915 if(BOOST_JSON_LIKELY(size)) 1060   1915 if(BOOST_JSON_LIKELY(size))
1056   { 1061   {
HITCBC 1057   245 bool const r = is_key? 1062   245 bool const r = is_key?
HITCBC 1058   22 h_.on_key_part( {start, size}, total, ec_ ): 1063   22 h_.on_key_part( {start, size}, total, ec_ ):
HITCBC 1059   245 h_.on_string_part( {start, size}, total, ec_ ); 1064   245 h_.on_string_part( {start, size}, total, ec_ );
HITCBC 1060   223 if(BOOST_JSON_UNLIKELY( !r )) 1065   223 if(BOOST_JSON_UNLIKELY( !r ))
HITCBC 1061   22 return fail( cs.begin() ); 1066   22 return fail( cs.begin() );
1062   } 1067   }
HITCBC 1063   1871 return maybe_suspend(cs.end(), state::str8, total); 1068   1871 return maybe_suspend(cs.end(), state::str8, total);
1064   } 1069   }
HITCBC 1065   11609 else if(BOOST_JSON_LIKELY(*cs == '\\')) 1070   11609 else if(BOOST_JSON_LIKELY(*cs == '\\'))
1066   { 1071   {
1067   // flush unescaped run from input 1072   // flush unescaped run from input
HITCBC 1068   11500 if(BOOST_JSON_LIKELY(size)) 1073   11500 if(BOOST_JSON_LIKELY(size))
1069   { 1074   {
HITCBC 1070   4250 bool const r = is_key? 1075   4250 bool const r = is_key?
HITCBC 1071   1226 h_.on_key_part( {start, size}, total, ec_ ): 1076   1226 h_.on_key_part( {start, size}, total, ec_ ):
HITCBC 1072   3554 h_.on_string_part( {start, size}, total, ec_ ); 1077   3554 h_.on_string_part( {start, size}, total, ec_ );
HITCBC 1073   3766 if(BOOST_JSON_UNLIKELY( !r )) 1078   3766 if(BOOST_JSON_UNLIKELY( !r ))
HITCBC 1074   484 return fail( cs.begin() ); 1079   484 return fail( cs.begin() );
1075   } 1080   }
HITCBC 1076   7250 do_str2: 1081   7250 do_str2:
HITCBC 1077   13681 cs = parse_escaped(cs.begin(), total, stack_empty, is_key, allow_bad_utf16); 1082   13681 cs = parse_escaped(cs.begin(), total, stack_empty, is_key, allow_bad_utf16);
HITCBC 1078   12719 if(BOOST_JSON_UNLIKELY( incomplete(cs) )) 1083   12719 if(BOOST_JSON_UNLIKELY( incomplete(cs) ))
HITCBC 1079   5476 return suspend_or_fail(state::str2, total); 1084   5476 return suspend_or_fail(state::str2, total);
1080   1085  
HITCBC 1081   7243 goto do_str1; 1086   7243 goto do_str1;
1082   } 1087   }
1083   // illegal control 1088   // illegal control
1084   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 1089   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 1085   109 return fail(cs.begin(), error::syntax, &loc); 1090   109 return fail(cs.begin(), error::syntax, &loc);
1086   } 1091   }
1087   1092  
1088   { 1093   {
HITCBC 1089   119487 bool r = is_key? 1094   119487 bool r = is_key?
HITCBC 1090   84511 h_.on_key( {start, size}, total, ec_ ): 1095   84511 h_.on_key( {start, size}, total, ec_ ):
HITCBC 1091   41985 h_.on_string( {start, size}, total, ec_ ); 1096   41985 h_.on_string( {start, size}, total, ec_ );
1092   1097  
HITCBC 1093   115113 if(BOOST_JSON_UNLIKELY(!r)) 1098   115113 if(BOOST_JSON_UNLIKELY(!r))
1094   { 1099   {
HITCBC 1095   4318 return fail(cs.begin()); 1100   4318 return fail(cs.begin());
1096   } 1101   }
1097   } 1102   }
1098   1103  
HITCBC 1099   110795 ++cs; 1104   110795 ++cs;
HITCBC 1100   110795 return cs.begin(); 1105   110795 return cs.begin();
1101   1106  
HITCBC 1102   1868 do_str8: 1107   1868 do_str8:
HITCBC 1103   1868 uint8_t needed = seq_.needed(); 1108   1868 uint8_t needed = seq_.needed();
HITCBC 1104   1868 if(BOOST_JSON_UNLIKELY( !seq_.append(cs.begin(), cs.remain()) )) 1109   1868 if(BOOST_JSON_UNLIKELY( !seq_.append(cs.begin(), cs.remain()) ))
HITCBC 1105   4 return maybe_suspend(cs.end(), state::str8, total); 1110   4 return maybe_suspend(cs.end(), state::str8, total);
HITCBC 1106   1864 if(BOOST_JSON_UNLIKELY( !seq_.valid() )) 1111   1864 if(BOOST_JSON_UNLIKELY( !seq_.valid() ))
1107   { 1112   {
1108   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 1113   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 1109   210 return fail(cs.begin(), error::syntax, &loc); 1114   210 return fail(cs.begin(), error::syntax, &loc);
1110   } 1115   }
1111   { 1116   {
HITCBC 1112   1654 std::size_t const n = seq_.length(); 1117   1654 std::size_t const n = seq_.length();
1113   bool r; 1118   bool r;
HITCBC 1114   1654 if(is_key) 1119   1654 if(is_key)
1115   { 1120   {
HITCBC 1116   2 BOOST_ASSERT(total <= Handler::max_key_size); 1121   2 BOOST_ASSERT(total <= Handler::max_key_size);
HITCBC 1117   2 if(BOOST_JSON_UNLIKELY(n > 1122   2 if(BOOST_JSON_UNLIKELY(n >
1118   Handler::max_key_size - total)) 1123   Handler::max_key_size - total))
1119   { 1124   {
1120   BOOST_STATIC_CONSTEXPR source_location loc 1125   BOOST_STATIC_CONSTEXPR source_location loc
1121   = BOOST_CURRENT_LOCATION; 1126   = BOOST_CURRENT_LOCATION;
HITCBC 1122   1 return fail(cs.begin(), error::key_too_large, &loc); 1127   1 return fail(cs.begin(), error::key_too_large, &loc);
1123   } 1128   }
HITCBC 1124   1 total += n; 1129   1 total += n;
HITCBC 1125   1 r = h_.on_key_part( {seq_.data(), n}, total, ec_ ); 1130   1 r = h_.on_key_part( {seq_.data(), n}, total, ec_ );
1126   } 1131   }
1127   else 1132   else
1128   { 1133   {
HITCBC 1129   1 BOOST_ASSERT(total <= Handler::max_string_size); 1134   1 BOOST_ASSERT(total <= Handler::max_string_size);
HITCBC 1130   1652 if(BOOST_JSON_UNLIKELY(n > 1135   1652 if(BOOST_JSON_UNLIKELY(n >
1131   Handler::max_string_size - total)) 1136   Handler::max_string_size - total))
1132   { 1137   {
1133   BOOST_STATIC_CONSTEXPR source_location loc 1138   BOOST_STATIC_CONSTEXPR source_location loc
1134   = BOOST_CURRENT_LOCATION; 1139   = BOOST_CURRENT_LOCATION;
HITCBC 1135   1 return fail(cs.begin(), error::string_too_large, &loc); 1140   1 return fail(cs.begin(), error::string_too_large, &loc);
1136   } 1141   }
HITCBC 1137   1651 total += n; 1142   1651 total += n;
HITCBC 1138   1651 r = h_.on_string_part( {seq_.data(), n}, total, ec_ ); 1143   1651 r = h_.on_string_part( {seq_.data(), n}, total, ec_ );
1139   } 1144   }
HITCBC 1140   1451 if(BOOST_JSON_UNLIKELY( !r )) 1145   1451 if(BOOST_JSON_UNLIKELY( !r ))
HITCBC 1141   201 return fail( cs.begin() ); 1146   201 return fail( cs.begin() );
1142   } 1147   }
HITCBC 1143   1250 cs += needed; 1148   1250 cs += needed;
HITCBC 1144   1250 goto do_str1; 1149   1250 goto do_str1;
1145   } 1150   }
1146   1151  
1147   template<class Handler> 1152   template<class Handler>
1148   template<bool StackEmpty_> 1153   template<bool StackEmpty_>
1149   const char* 1154   const char*
HITCBC 1150   13681 basic_parser<Handler>:: 1155   13681 basic_parser<Handler>::
1151   parse_escaped( 1156   parse_escaped(
1152   const char* p, 1157   const char* p,
1153   std::size_t& total, 1158   std::size_t& total,
1154   std::integral_constant<bool, StackEmpty_> stack_empty, 1159   std::integral_constant<bool, StackEmpty_> stack_empty,
1155   bool is_key, 1160   bool is_key,
1156   bool allow_bad_utf16) 1161   bool allow_bad_utf16)
1157   { 1162   {
HITCBC 1158   13681 constexpr unsigned urc = 0xFFFD; // Unicode replacement character 1163   13681 constexpr unsigned urc = 0xFFFD; // Unicode replacement character
HITCBC 1159   13681 auto const ev_too_large = is_key? 1164   13681 auto const ev_too_large = is_key?
1160   error::key_too_large : error::string_too_large; 1165   error::key_too_large : error::string_too_large;
HITCBC 1161   13681 auto const max_size = is_key? 1166   13681 auto const max_size = is_key?
1162   Handler::max_key_size : Handler::max_string_size; 1167   Handler::max_key_size : Handler::max_string_size;
1163   int digit; 1168   int digit;
1164   1169  
1165   //--------------------------------------------------------------- 1170   //---------------------------------------------------------------
1166   // 1171   //
1167   // To handle escapes, a local temporary buffer accumulates 1172   // To handle escapes, a local temporary buffer accumulates
1168   // the unescaped result. The algorithm attempts to fill the 1173   // the unescaped result. The algorithm attempts to fill the
1169   // buffer to capacity before invoking the handler. 1174   // buffer to capacity before invoking the handler.
1170   // In some cases the temporary buffer needs to be flushed 1175   // In some cases the temporary buffer needs to be flushed
1171   // before it is full: 1176   // before it is full:
1172   // * When the closing double quote is seen 1177   // * When the closing double quote is seen
1173   // * When there in no more input (and more is expected later) 1178   // * When there in no more input (and more is expected later)
1174   // A goal of the algorithm is to call the handler as few times 1179   // A goal of the algorithm is to call the handler as few times
1175   // as possible. Thus, when the first escape is encountered, 1180   // as possible. Thus, when the first escape is encountered,
1176   // the algorithm attempts to fill the temporary buffer first. 1181   // the algorithm attempts to fill the temporary buffer first.
1177   // 1182   //
HITCBC 1178   13681 detail::buffer<BOOST_JSON_STACK_BUFFER_SIZE> temp; 1183   13681 detail::buffer<BOOST_JSON_STACK_BUFFER_SIZE> temp;
1179   1184  
1180   // Unescaped JSON is never larger than its escaped version. 1185   // Unescaped JSON is never larger than its escaped version.
1181   // To efficiently process only what will fit in the temporary buffer, 1186   // To efficiently process only what will fit in the temporary buffer,
1182   // the size of the input stream is temporarily "clipped" to the size 1187   // the size of the input stream is temporarily "clipped" to the size
1183   // of the temporary buffer. 1188   // of the temporary buffer.
1184   // handle escaped character 1189   // handle escaped character
HITCBC 1185   13681 detail::clipped_const_stream cs(p, end_); 1190   13681 detail::clipped_const_stream cs(p, end_);
HITCBC 1186   13681 cs.clip(temp.max_size()); 1191   13681 cs.clip(temp.max_size());
1187   1192  
HITCBC 1188   13681 if(! stack_empty && ! st_.empty()) 1193   13681 if(! stack_empty && ! st_.empty())
1189   { 1194   {
1190   state st; 1195   state st;
HITCBC 1191   3149 st_.pop(st); 1196   3149 st_.pop(st);
HITCBC 1192   3149 switch(st) 1197   3149 switch(st)
1193   { 1198   {
1194   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 1199   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 1195   528 case state::str3: goto do_str3; 1200   528 case state::str3: goto do_str3;
HITCBC 1196   392 case state::str4: goto do_str4; 1201   392 case state::str4: goto do_str4;
HITCBC 1197   390 case state::str5: goto do_str5; 1202   390 case state::str5: goto do_str5;
HITCBC 1198   389 case state::str6: goto do_str6; 1203   389 case state::str6: goto do_str6;
HITCBC 1199   386 case state::str7: goto do_str7; 1204   386 case state::str7: goto do_str7;
HITCBC 1200   232 case state::sur1: goto do_sur1; 1205   232 case state::sur1: goto do_sur1;
HITCBC 1201   188 case state::sur2: goto do_sur2; 1206   188 case state::sur2: goto do_sur2;
HITCBC 1202   164 case state::sur3: goto do_sur3; 1207   164 case state::sur3: goto do_sur3;
HITCBC 1203   162 case state::sur4: goto do_sur4; 1208   162 case state::sur4: goto do_sur4;
HITCBC 1204   160 case state::sur5: goto do_sur5; 1209   160 case state::sur5: goto do_sur5;
HITCBC 1205   158 case state::sur6: goto do_sur6; 1210   158 case state::sur6: goto do_sur6;
1206   } 1211   }
1207   } 1212   }
1208   1213  
HITCBC 1209   3783 while(true) 1214   3783 while(true)
1210   { 1215   {
HITCBC 1211   14315 BOOST_ASSERT( temp.capacity() ); 1216   14315 BOOST_ASSERT( temp.capacity() );
HITCBC 1212   14315 BOOST_ASSERT(*cs == '\\'); 1217   14315 BOOST_ASSERT(*cs == '\\');
HITCBC 1213   14315 ++cs; 1218   14315 ++cs;
HITCBC 1214   15174 do_str3: 1219   15174 do_str3:
HITCBC 1215   15379 if(BOOST_JSON_UNLIKELY(! cs)) 1220   15379 if(BOOST_JSON_UNLIKELY(! cs))
1216   { 1221   {
HITCBC 1217   562 if(BOOST_JSON_LIKELY(! temp.empty())) 1222   562 if(BOOST_JSON_LIKELY(! temp.empty()))
1218   { 1223   {
HITCBC 1219   1 BOOST_ASSERT(total <= max_size); 1224   1 BOOST_ASSERT(total <= max_size);
HITCBC 1220   101 if(BOOST_JSON_UNLIKELY( 1225   101 if(BOOST_JSON_UNLIKELY(
1221   temp.size() > max_size - total)) 1226   temp.size() > max_size - total))
1222   { 1227   {
1223   BOOST_STATIC_CONSTEXPR source_location loc 1228   BOOST_STATIC_CONSTEXPR source_location loc
1224   = BOOST_CURRENT_LOCATION; 1229   = BOOST_CURRENT_LOCATION;
HITCBC 1225   1 return fail(cs.begin(), ev_too_large, &loc); 1230   1 return fail(cs.begin(), ev_too_large, &loc);
1226   } 1231   }
HITCBC 1227   100 total += temp.size(); 1232   100 total += temp.size();
1228   { 1233   {
HITCBC 1229   91 bool r = is_key 1234   91 bool r = is_key
HITCBC 1230   100 ? h_.on_key_part(temp.get(), total, ec_) 1235   100 ? h_.on_key_part(temp.get(), total, ec_)
HITCBC 1231   100 : h_.on_string_part(temp.get(), total, ec_); 1236   100 : h_.on_string_part(temp.get(), total, ec_);
1232   1237  
HITCBC 1233   91 if(BOOST_JSON_UNLIKELY(!r)) 1238   91 if(BOOST_JSON_UNLIKELY(!r))
1234   { 1239   {
HITCBC 1235   9 return fail(cs.begin()); 1240   9 return fail(cs.begin());
1236   } 1241   }
1237   } 1242   }
HITCBC 1238   82 temp.clear(); 1243   82 temp.clear();
1239   } 1244   }
HITCBC 1240   543 cs.clip(temp.max_size()); 1245   543 cs.clip(temp.max_size());
HITCBC 1241   543 if(BOOST_JSON_UNLIKELY(! cs)) 1246   543 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1242   543 return maybe_suspend(cs.begin(), state::str3); 1247   543 return maybe_suspend(cs.begin(), state::str3);
1243   } 1248   }
HITCBC 1244   14817 switch(*cs) 1249   14817 switch(*cs)
1245   { 1250   {
HITCBC 1246   191 default: 1251   191 default:
1247   { 1252   {
1248   BOOST_STATIC_CONSTEXPR source_location loc 1253   BOOST_STATIC_CONSTEXPR source_location loc
1249   = BOOST_CURRENT_LOCATION; 1254   = BOOST_CURRENT_LOCATION;
HITCBC 1250   191 return fail(cs.begin(), error::syntax, &loc); 1255   191 return fail(cs.begin(), error::syntax, &loc);
1251   } 1256   }
HITCBC 1252   265 case '\x22': // '"' 1257   265 case '\x22': // '"'
HITCBC 1253   265 temp.push_back('\x22'); 1258   265 temp.push_back('\x22');
HITCBC 1254   265 ++cs; 1259   265 ++cs;
HITCBC 1255   265 break; 1260   265 break;
HITCBC 1256   178 case '\\': 1261   178 case '\\':
HITCBC 1257   178 temp.push_back('\\'); 1262   178 temp.push_back('\\');
HITCBC 1258   178 ++cs; 1263   178 ++cs;
HITCBC 1259   178 break; 1264   178 break;
HITCBC 1260   96 case '/': 1265   96 case '/':
HITCBC 1261   96 temp.push_back('/'); 1266   96 temp.push_back('/');
HITCBC 1262   96 ++cs; 1267   96 ++cs;
HITCBC 1263   96 break; 1268   96 break;
HITCBC 1264   112 case 'b': 1269   112 case 'b':
HITCBC 1265   112 temp.push_back('\x08'); 1270   112 temp.push_back('\x08');
HITCBC 1266   112 ++cs; 1271   112 ++cs;
HITCBC 1267   112 break; 1272   112 break;
HITCBC 1268   108 case 'f': 1273   108 case 'f':
HITCBC 1269   108 temp.push_back('\x0c'); 1274   108 temp.push_back('\x0c');
HITCBC 1270   108 ++cs; 1275   108 ++cs;
HITCBC 1271   108 break; 1276   108 break;
HITCBC 1272   1766 case 'n': 1277   1766 case 'n':
HITCBC 1273   1766 temp.push_back('\x0a'); 1278   1766 temp.push_back('\x0a');
HITCBC 1274   1766 ++cs; 1279   1766 ++cs;
HITCBC 1275   1766 break; 1280   1766 break;
HITCBC 1276   146 case 'r': 1281   146 case 'r':
HITCBC 1277   146 temp.push_back('\x0d'); 1282   146 temp.push_back('\x0d');
HITCBC 1278   146 ++cs; 1283   146 ++cs;
HITCBC 1279   146 break; 1284   146 break;
HITCBC 1280   266 case 't': 1285   266 case 't':
HITCBC 1281   266 temp.push_back('\x09'); 1286   266 temp.push_back('\x09');
HITCBC 1282   266 ++cs; 1287   266 ++cs;
HITCBC 1283   266 break; 1288   266 break;
HITCBC 1284   11689 case 'u': 1289   11689 case 'u':
1285   // utf16 escape 1290   // utf16 escape
1286   // 1291   //
1287   // fast path only when the buffer 1292   // fast path only when the buffer
1288   // is large enough for 2 surrogates 1293   // is large enough for 2 surrogates
HITCBC 1289   11689 if(BOOST_JSON_LIKELY(cs.remain() > 10)) 1294   11689 if(BOOST_JSON_LIKELY(cs.remain() > 10))
1290   { 1295   {
1291   // KRYSTIAN TODO: this could be done 1296   // KRYSTIAN TODO: this could be done
1292   // with fewer instructions 1297   // with fewer instructions
HITCBC 1293   11394 digit = detail::load_little_endian<4>( 1298   11394 digit = detail::load_little_endian<4>(
HITCBC 1294   5697 cs.begin() + 1); 1299   5697 cs.begin() + 1);
HITCBC 1295   5697 int d4 = detail::hex_digit(static_cast< 1300   5697 int d4 = detail::hex_digit(static_cast<
HITCBC 1296   5697 unsigned char>(digit >> 24)); 1301   5697 unsigned char>(digit >> 24));
HITCBC 1297   5697 int d3 = detail::hex_digit(static_cast< 1302   5697 int d3 = detail::hex_digit(static_cast<
HITCBC 1298   5697 unsigned char>(digit >> 16)); 1303   5697 unsigned char>(digit >> 16));
HITCBC 1299   5697 int d2 = detail::hex_digit(static_cast< 1304   5697 int d2 = detail::hex_digit(static_cast<
HITCBC 1300   5697 unsigned char>(digit >> 8)); 1305   5697 unsigned char>(digit >> 8));
HITCBC 1301   5697 int d1 = detail::hex_digit(static_cast< 1306   5697 int d1 = detail::hex_digit(static_cast<
1302   unsigned char>(digit)); 1307   unsigned char>(digit));
HITCBC 1303   5697 if(BOOST_JSON_UNLIKELY( 1308   5697 if(BOOST_JSON_UNLIKELY(
1304   (d1 | d2 | d3 | d4) == -1)) 1309   (d1 | d2 | d3 | d4) == -1))
1305   { 1310   {
HITCBC 1306   60 if(d1 != -1) 1311   60 if(d1 != -1)
HITCBC 1307   45 ++cs; 1312   45 ++cs;
HITCBC 1308   60 if(d2 != -1) 1313   60 if(d2 != -1)
HITCBC 1309   30 ++cs; 1314   30 ++cs;
HITCBC 1310   60 if(d3 != -1) 1315   60 if(d3 != -1)
HITCBC 1311   15 ++cs; 1316   15 ++cs;
1312   BOOST_STATIC_CONSTEXPR source_location loc 1317   BOOST_STATIC_CONSTEXPR source_location loc
1313   = BOOST_CURRENT_LOCATION; 1318   = BOOST_CURRENT_LOCATION;
HITCBC 1314   60 return fail(cs.begin(), error::expected_hex_digit, &loc); 1319   60 return fail(cs.begin(), error::expected_hex_digit, &loc);
1315   } 1320   }
1316   // 32 bit unicode scalar value 1321   // 32 bit unicode scalar value
HITCBC 1317   5637 unsigned u1 = 1322   5637 unsigned u1 =
HITCBC 1318   5637 (d1 << 12) + (d2 << 8) + 1323   5637 (d1 << 12) + (d2 << 8) +
HITCBC 1319   5637 (d3 << 4) + d4; 1324   5637 (d3 << 4) + d4;
1320   // valid unicode scalar values are 1325   // valid unicode scalar values are
1321   // [0, D7FF] and [E000, 10FFFF] 1326   // [0, D7FF] and [E000, 10FFFF]
1322   // values within this range are valid utf-8 1327   // values within this range are valid utf-8
1323   // code points and invalid leading surrogates. 1328   // code points and invalid leading surrogates.
HITCBC 1324   5637 if(BOOST_JSON_LIKELY( 1329   5637 if(BOOST_JSON_LIKELY(
1325   u1 < 0xd800 || u1 > 0xdfff)) 1330   u1 < 0xd800 || u1 > 0xdfff))
1326   { 1331   {
HITCBC 1327   1340 cs += 5; 1332   1340 cs += 5;
HITCBC 1328   1340 temp.append_utf8(u1); 1333   1340 temp.append_utf8(u1);
HITCBC 1329   1340 break; 1334   1340 break;
1330   } 1335   }
HITCBC 1331   4297 if(BOOST_JSON_UNLIKELY(u1 > 0xdbff)) 1336   4297 if(BOOST_JSON_UNLIKELY(u1 > 0xdbff))
1332   { 1337   {
1333   // If it's an illegal leading surrogate and 1338   // If it's an illegal leading surrogate and
1334   // the parser does not allow it, return an error. 1339   // the parser does not allow it, return an error.
HITCBC 1335   707 if(!allow_bad_utf16) 1340   707 if(!allow_bad_utf16)
1336   { 1341   {
1337   BOOST_STATIC_CONSTEXPR source_location loc 1342   BOOST_STATIC_CONSTEXPR source_location loc
1338   = BOOST_CURRENT_LOCATION; 1343   = BOOST_CURRENT_LOCATION;
HITCBC 1339   122 return fail(cs.begin(), error::illegal_leading_surrogate, 1344   122 return fail(cs.begin(), error::illegal_leading_surrogate,
HITCBC 1340   122 &loc); 1345   122 &loc);
1341   } 1346   }
1342   // Otherwise, append the Unicode replacement character 1347   // Otherwise, append the Unicode replacement character
1343   else 1348   else
1344   { 1349   {
HITCBC 1345   585 cs += 5; 1350   585 cs += 5;
HITCBC 1346   585 temp.append_utf8(urc); 1351   585 temp.append_utf8(urc);
HITCBC 1347   585 break; 1352   585 break;
1348   } 1353   }
1349   } 1354   }
HITCBC 1350   3590 cs += 5; 1355   3590 cs += 5;
1351   // KRYSTIAN TODO: this can be a two byte load 1356   // KRYSTIAN TODO: this can be a two byte load
1352   // and a single comparison. We lose error information, 1357   // and a single comparison. We lose error information,
1353   // but it's faster. 1358   // but it's faster.
HITCBC 1354   3590 if(BOOST_JSON_UNLIKELY(*cs != '\\')) 1359   3590 if(BOOST_JSON_UNLIKELY(*cs != '\\'))
1355   { 1360   {
1356   // If the next character is not a backslash and 1361   // If the next character is not a backslash and
1357   // the parser does not allow it, return a syntax error. 1362   // the parser does not allow it, return a syntax error.
HITCBC 1358   156 if(!allow_bad_utf16) 1363   156 if(!allow_bad_utf16)
1359   { 1364   {
1360   BOOST_STATIC_CONSTEXPR source_location loc 1365   BOOST_STATIC_CONSTEXPR source_location loc
1361   = BOOST_CURRENT_LOCATION; 1366   = BOOST_CURRENT_LOCATION;
HITCBC 1362   15 return fail(cs.begin(), error::syntax, &loc); 1367   15 return fail(cs.begin(), error::syntax, &loc);
1363   } 1368   }
1364   // Otherwise, append the Unicode replacement character since 1369   // Otherwise, append the Unicode replacement character since
1365   // the first code point is a valid leading surrogate 1370   // the first code point is a valid leading surrogate
1366   else 1371   else
1367   { 1372   {
HITCBC 1368   141 temp.append_utf8(urc); 1373   141 temp.append_utf8(urc);
HITCBC 1369   141 break; 1374   141 break;
1370   } 1375   }
1371   } 1376   }
HITCBC 1372   3434 ++cs; 1377   3434 ++cs;
HITCBC 1373   3434 if(BOOST_JSON_UNLIKELY(*cs != 'u')) 1378   3434 if(BOOST_JSON_UNLIKELY(*cs != 'u'))
1374   { 1379   {
HITCBC 1375   220 if (!allow_bad_utf16) 1380   220 if (!allow_bad_utf16)
1376   { 1381   {
1377   BOOST_STATIC_CONSTEXPR source_location loc 1382   BOOST_STATIC_CONSTEXPR source_location loc
1378   = BOOST_CURRENT_LOCATION; 1383   = BOOST_CURRENT_LOCATION;
HITCBC 1379   15 return fail(cs.begin(), error::syntax, &loc); 1384   15 return fail(cs.begin(), error::syntax, &loc);
1380   } 1385   }
1381   // Otherwise, append the Unicode replacement character since 1386   // Otherwise, append the Unicode replacement character since
1382   // the first code point is a valid leading surrogate 1387   // the first code point is a valid leading surrogate
1383   else 1388   else
1384   { 1389   {
HITCBC 1385   205 temp.append_utf8(urc); 1390   205 temp.append_utf8(urc);
HITCBC 1386   205 goto do_str3; 1391   205 goto do_str3;
1387   } 1392   }
1388   } 1393   }
HITCBC 1389   3214 ++cs; 1394   3214 ++cs;
HITCBC 1390   3214 digit = detail::load_little_endian<4>(cs.begin()); 1395   3214 digit = detail::load_little_endian<4>(cs.begin());
HITCBC 1391   3214 d4 = detail::hex_digit(static_cast< 1396   3214 d4 = detail::hex_digit(static_cast<
HITCBC 1392   3214 unsigned char>(digit >> 24)); 1397   3214 unsigned char>(digit >> 24));
HITCBC 1393   3214 d3 = detail::hex_digit(static_cast< 1398   3214 d3 = detail::hex_digit(static_cast<
HITCBC 1394   3214 unsigned char>(digit >> 16)); 1399   3214 unsigned char>(digit >> 16));
HITCBC 1395   3214 d2 = detail::hex_digit(static_cast< 1400   3214 d2 = detail::hex_digit(static_cast<
HITCBC 1396   3214 unsigned char>(digit >> 8)); 1401   3214 unsigned char>(digit >> 8));
HITCBC 1397   3214 d1 = detail::hex_digit(static_cast< 1402   3214 d1 = detail::hex_digit(static_cast<
1398   unsigned char>(digit)); 1403   unsigned char>(digit));
HITCBC 1399   3214 if(BOOST_JSON_UNLIKELY( 1404   3214 if(BOOST_JSON_UNLIKELY(
1400   (d1 | d2 | d3 | d4) == -1)) 1405   (d1 | d2 | d3 | d4) == -1))
1401   { 1406   {
HITCBC 1402   90 if(d1 != -1) 1407   90 if(d1 != -1)
HITCBC 1403   75 ++cs; 1408   75 ++cs;
HITCBC 1404   90 if(d2 != -1) 1409   90 if(d2 != -1)
HITCBC 1405   45 ++cs; 1410   45 ++cs;
HITCBC 1406   90 if(d3 != -1) 1411   90 if(d3 != -1)
HITCBC 1407   15 ++cs; 1412   15 ++cs;
1408   BOOST_STATIC_CONSTEXPR source_location loc 1413   BOOST_STATIC_CONSTEXPR source_location loc
1409   = BOOST_CURRENT_LOCATION; 1414   = BOOST_CURRENT_LOCATION;
HITCBC 1410   90 return fail(cs.begin(), error::expected_hex_digit, &loc); 1415   90 return fail(cs.begin(), error::expected_hex_digit, &loc);
1411   } 1416   }
HITCBC 1412   3124 unsigned u2 = 1417   3124 unsigned u2 =
HITCBC 1413   3124 (d1 << 12) + (d2 << 8) + 1418   3124 (d1 << 12) + (d2 << 8) +
HITCBC 1414   3124 (d3 << 4) + d4; 1419   3124 (d3 << 4) + d4;
1415   // Check if the second code point is a valid trailing surrogate. 1420   // Check if the second code point is a valid trailing surrogate.
1416   // Valid trailing surrogates are [DC00, DFFF] 1421   // Valid trailing surrogates are [DC00, DFFF]
HITCBC 1417   3124 if(BOOST_JSON_UNLIKELY( 1422   3124 if(BOOST_JSON_UNLIKELY(
1418   u2 < 0xdc00 || u2 > 0xdfff)) 1423   u2 < 0xdc00 || u2 > 0xdfff))
1419   { 1424   {
1420   // If not valid and the parser does not allow it, return an error. 1425   // If not valid and the parser does not allow it, return an error.
HITCBC 1421   1353 if(!allow_bad_utf16) 1426   1353 if(!allow_bad_utf16)
1422   { 1427   {
1423   BOOST_STATIC_CONSTEXPR source_location loc 1428   BOOST_STATIC_CONSTEXPR source_location loc
1424   = BOOST_CURRENT_LOCATION; 1429   = BOOST_CURRENT_LOCATION;
HITCBC 1425   136 return fail(cs.begin(), error::illegal_trailing_surrogate, 1430   136 return fail(cs.begin(), error::illegal_trailing_surrogate,
HITCBC 1426   136 &loc); 1431   136 &loc);
1427   } 1432   }
1428   // Append the replacement character for the 1433   // Append the replacement character for the
1429   // first leading surrogate. 1434   // first leading surrogate.
HITCBC 1430   1217 cs += 4; 1435   1217 cs += 4;
HITCBC 1431   1217 temp.append_utf8(urc); 1436   1217 temp.append_utf8(urc);
1432   // Check if the second code point is a 1437   // Check if the second code point is a
1433   // valid unicode scalar value (invalid leading 1438   // valid unicode scalar value (invalid leading
1434   // or trailing surrogate) 1439   // or trailing surrogate)
HITCBC 1435   1217 if (u2 < 0xd800 || u2 > 0xdbff) 1440   1217 if (u2 < 0xd800 || u2 > 0xdbff)
1436   { 1441   {
HITCBC 1437   524 temp.append_utf8(u2); 1442   524 temp.append_utf8(u2);
HITCBC 1438   524 break; 1443   524 break;
1439   } 1444   }
1440   // If it is a valid leading surrogate 1445   // If it is a valid leading surrogate
1441   else 1446   else
1442   { 1447   {
HITCBC 1443   693 u1_ = u2; 1448   693 u1_ = u2;
HITCBC 1444   693 goto do_sur1; 1449   693 goto do_sur1;
1445   } 1450   }
1446   } 1451   }
HITCBC 1447   1771 cs += 4; 1452   1771 cs += 4;
1448   // Calculate the Unicode code point from the surrogate pair and 1453   // Calculate the Unicode code point from the surrogate pair and
1449   // append the UTF-8 representation. 1454   // append the UTF-8 representation.
HITCBC 1450   1771 unsigned cp = 1455   1771 unsigned cp =
HITCBC 1451   1771 ((u1 - 0xd800) << 10) + 1456   1771 ((u1 - 0xd800) << 10) +
1452   ((u2 - 0xdc00)) + 1457   ((u2 - 0xdc00)) +
1453   0x10000; 1458   0x10000;
1454   // utf-16 surrogate pair 1459   // utf-16 surrogate pair
HITCBC 1455   1771 temp.append_utf8(cp); 1460   1771 temp.append_utf8(cp);
HITCBC 1456   1771 break; 1461   1771 break;
1457   } 1462   }
1458   // flush 1463   // flush
HITCBC 1459   5992 if(BOOST_JSON_LIKELY(! temp.empty())) 1464   5992 if(BOOST_JSON_LIKELY(! temp.empty()))
1460   { 1465   {
HITCBC 1461   4 BOOST_ASSERT(total <= max_size); 1466   4 BOOST_ASSERT(total <= max_size);
HITCBC 1462   1723 if(BOOST_JSON_UNLIKELY( 1467   1723 if(BOOST_JSON_UNLIKELY(
1463   temp.size() > max_size - total)) 1468   temp.size() > max_size - total))
1464   { 1469   {
1465   BOOST_STATIC_CONSTEXPR source_location loc 1470   BOOST_STATIC_CONSTEXPR source_location loc
1466   = BOOST_CURRENT_LOCATION; 1471   = BOOST_CURRENT_LOCATION;
HITCBC 1467   1 return fail(cs.begin(), ev_too_large, &loc); 1472   1 return fail(cs.begin(), ev_too_large, &loc);
1468   } 1473   }
HITCBC 1469   1722 total += temp.size(); 1474   1722 total += temp.size();
1470   { 1475   {
HITCBC 1471   1582 bool r = is_key 1476   1582 bool r = is_key
HITCBC 1472   1722 ? h_.on_key_part(temp.get(), total, ec_) 1477   1722 ? h_.on_key_part(temp.get(), total, ec_)
HITCBC 1473   1722 : h_.on_string_part(temp.get(), total, ec_); 1478   1722 : h_.on_string_part(temp.get(), total, ec_);
1474   1479  
HITCBC 1475   1582 if(BOOST_JSON_UNLIKELY(!r)) 1480   1582 if(BOOST_JSON_UNLIKELY(!r))
1476   { 1481   {
HITCBC 1477   140 return fail(cs.begin()); 1482   140 return fail(cs.begin());
1478   } 1483   }
1479   } 1484   }
HITCBC 1480   1442 temp.clear(); 1485   1442 temp.clear();
HITCBC 1481   1442 cs.clip(temp.max_size()); 1486   1442 cs.clip(temp.max_size());
1482   } 1487   }
HITCBC 1483   5711 ++cs; 1488   5711 ++cs;
1484   // utf-16 escape 1489   // utf-16 escape
HITCBC 1485   6103 do_str4: 1490   6103 do_str4:
HITCBC 1486   6103 if(BOOST_JSON_UNLIKELY(! cs)) 1491   6103 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1487   392 return maybe_suspend(cs.begin(), state::str4); 1492   392 return maybe_suspend(cs.begin(), state::str4);
HITCBC 1488   5711 digit = detail::hex_digit(*cs); 1493   5711 digit = detail::hex_digit(*cs);
HITCBC 1489   5711 if(BOOST_JSON_UNLIKELY(digit == -1)) 1494   5711 if(BOOST_JSON_UNLIKELY(digit == -1))
1490   { 1495   {
1491   BOOST_STATIC_CONSTEXPR source_location loc 1496   BOOST_STATIC_CONSTEXPR source_location loc
1492   = BOOST_CURRENT_LOCATION; 1497   = BOOST_CURRENT_LOCATION;
HITCBC 1493   50 return fail(cs.begin(), error::expected_hex_digit, &loc); 1498   50 return fail(cs.begin(), error::expected_hex_digit, &loc);
1494   } 1499   }
HITCBC 1495   5661 ++cs; 1500   5661 ++cs;
HITCBC 1496   5661 u1_ = digit << 12; 1501   5661 u1_ = digit << 12;
HITCBC 1497   6051 do_str5: 1502   6051 do_str5:
HITCBC 1498   6051 if(BOOST_JSON_UNLIKELY(! cs)) 1503   6051 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1499   390 return maybe_suspend(cs.begin(), state::str5); 1504   390 return maybe_suspend(cs.begin(), state::str5);
HITCBC 1500   5661 digit = detail::hex_digit(*cs); 1505   5661 digit = detail::hex_digit(*cs);
HITCBC 1501   5661 if(BOOST_JSON_UNLIKELY(digit == -1)) 1506   5661 if(BOOST_JSON_UNLIKELY(digit == -1))
1502   { 1507   {
1503   BOOST_STATIC_CONSTEXPR source_location loc 1508   BOOST_STATIC_CONSTEXPR source_location loc
1504   = BOOST_CURRENT_LOCATION; 1509   = BOOST_CURRENT_LOCATION;
HITCBC 1505   20 return fail(cs.begin(), error::expected_hex_digit, &loc); 1510   20 return fail(cs.begin(), error::expected_hex_digit, &loc);
1506   } 1511   }
HITCBC 1507   5641 ++cs; 1512   5641 ++cs;
HITCBC 1508   5641 u1_ += digit << 8; 1513   5641 u1_ += digit << 8;
HITCBC 1509   6030 do_str6: 1514   6030 do_str6:
HITCBC 1510   6030 if(BOOST_JSON_UNLIKELY(! cs)) 1515   6030 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1511   389 return maybe_suspend(cs.begin(), state::str6); 1516   389 return maybe_suspend(cs.begin(), state::str6);
HITCBC 1512   5641 digit = detail::hex_digit(*cs); 1517   5641 digit = detail::hex_digit(*cs);
HITCBC 1513   5641 if(BOOST_JSON_UNLIKELY(digit == -1)) 1518   5641 if(BOOST_JSON_UNLIKELY(digit == -1))
1514   { 1519   {
1515   BOOST_STATIC_CONSTEXPR source_location loc 1520   BOOST_STATIC_CONSTEXPR source_location loc
1516   = BOOST_CURRENT_LOCATION; 1521   = BOOST_CURRENT_LOCATION;
HITCBC 1517   20 return fail(cs.begin(), error::expected_hex_digit, &loc); 1522   20 return fail(cs.begin(), error::expected_hex_digit, &loc);
1518   } 1523   }
HITCBC 1519   5621 ++cs; 1524   5621 ++cs;
HITCBC 1520   5621 u1_ += digit << 4; 1525   5621 u1_ += digit << 4;
HITCBC 1521   6007 do_str7: 1526   6007 do_str7:
HITCBC 1522   6007 if(BOOST_JSON_UNLIKELY(! cs)) 1527   6007 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1523   386 return maybe_suspend(cs.begin(), state::str7); 1528   386 return maybe_suspend(cs.begin(), state::str7);
HITCBC 1524   5621 digit = detail::hex_digit(*cs); 1529   5621 digit = detail::hex_digit(*cs);
HITCBC 1525   5621 if(BOOST_JSON_UNLIKELY(digit == -1)) 1530   5621 if(BOOST_JSON_UNLIKELY(digit == -1))
1526   { 1531   {
1527   BOOST_STATIC_CONSTEXPR source_location loc 1532   BOOST_STATIC_CONSTEXPR source_location loc
1528   = BOOST_CURRENT_LOCATION; 1533   = BOOST_CURRENT_LOCATION;
HITCBC 1529   35 return fail(cs.begin(), error::expected_hex_digit, &loc); 1534   35 return fail(cs.begin(), error::expected_hex_digit, &loc);
1530   } 1535   }
HITCBC 1531   5586 ++cs; 1536   5586 ++cs;
HITCBC 1532   5586 u1_ += digit; 1537   5586 u1_ += digit;
HITCBC 1533   5586 if(BOOST_JSON_LIKELY( 1538   5586 if(BOOST_JSON_LIKELY(
1534   u1_ < 0xd800 || u1_ > 0xdfff)) 1539   u1_ < 0xd800 || u1_ > 0xdfff))
1535   { 1540   {
HITCBC 1536   1434 BOOST_ASSERT(temp.empty()); 1541   1434 BOOST_ASSERT(temp.empty());
1537   // utf-8 codepoint 1542   // utf-8 codepoint
HITCBC 1538   1434 temp.append_utf8(u1_); 1543   1434 temp.append_utf8(u1_);
HITCBC 1539   1434 break; 1544   1434 break;
1540   } 1545   }
HITCBC 1541   4152 if(BOOST_JSON_UNLIKELY(u1_ > 0xdbff)) 1546   4152 if(BOOST_JSON_UNLIKELY(u1_ > 0xdbff))
1542   { 1547   {
1543   // If it's an illegal leading surrogate and 1548   // If it's an illegal leading surrogate and
1544   // the parser does not allow it, return an error. 1549   // the parser does not allow it, return an error.
HITCBC 1545   1585 if(!allow_bad_utf16) 1550   1585 if(!allow_bad_utf16)
1546   { 1551   {
1547   BOOST_STATIC_CONSTEXPR source_location loc 1552   BOOST_STATIC_CONSTEXPR source_location loc
1548   = BOOST_CURRENT_LOCATION; 1553   = BOOST_CURRENT_LOCATION;
HITCBC 1549   209 return fail(cs.begin(), error::illegal_leading_surrogate, &loc); 1554   209 return fail(cs.begin(), error::illegal_leading_surrogate, &loc);
1550   } 1555   }
1551   // Otherwise, append the Unicode replacement character 1556   // Otherwise, append the Unicode replacement character
1552   else 1557   else
1553   { 1558   {
HITCBC 1554   1376 BOOST_ASSERT(temp.empty()); 1559   1376 BOOST_ASSERT(temp.empty());
HITCBC 1555   1376 temp.append_utf8(urc); 1560   1376 temp.append_utf8(urc);
HITCBC 1556   1376 break; 1561   1376 break;
1557   } 1562   }
1558   } 1563   }
HITCBC 1559   2567 do_sur1: 1564   2567 do_sur1:
HITCBC 1560   3792 if(BOOST_JSON_UNLIKELY(! cs)) 1565   3792 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1561   232 return maybe_suspend(cs.begin(), state::sur1); 1566   232 return maybe_suspend(cs.begin(), state::sur1);
HITCBC 1562   3560 if(BOOST_JSON_UNLIKELY(*cs != '\\')) 1567   3560 if(BOOST_JSON_UNLIKELY(*cs != '\\'))
1563   { 1568   {
1564   // If the next character is not a backslash and 1569   // If the next character is not a backslash and
1565   // the parser does not allow it, return a syntax error. 1570   // the parser does not allow it, return a syntax error.
HITCBC 1566   952 if(!allow_bad_utf16) 1571   952 if(!allow_bad_utf16)
1567   { 1572   {
1568   BOOST_STATIC_CONSTEXPR source_location loc 1573   BOOST_STATIC_CONSTEXPR source_location loc
1569   = BOOST_CURRENT_LOCATION; 1574   = BOOST_CURRENT_LOCATION;
HITCBC 1570   149 return fail(cs.begin(), error::syntax, &loc); 1575   149 return fail(cs.begin(), error::syntax, &loc);
1571   } 1576   }
1572   // Otherwise, append the Unicode replacement character since 1577   // Otherwise, append the Unicode replacement character since
1573   // the first code point is a valid leading surrogate 1578   // the first code point is a valid leading surrogate
1574   else 1579   else
1575   { 1580   {
HITCBC 1576   803 temp.append_utf8(urc); 1581   803 temp.append_utf8(urc);
HITCBC 1577   803 break; 1582   803 break;
1578   } 1583   }
1579   } 1584   }
HITCBC 1580   2608 ++cs; 1585   2608 ++cs;
HITCBC 1581   2796 do_sur2: 1586   2796 do_sur2:
HITCBC 1582   2796 if(BOOST_JSON_UNLIKELY(! cs)) 1587   2796 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1583   188 return maybe_suspend(cs.begin(), state::sur2); 1588   188 return maybe_suspend(cs.begin(), state::sur2);
HITCBC 1584   2608 if(BOOST_JSON_UNLIKELY(*cs != 'u')) 1589   2608 if(BOOST_JSON_UNLIKELY(*cs != 'u'))
1585   { 1590   {
HITCBC 1586   396 if (!allow_bad_utf16) 1591   396 if (!allow_bad_utf16)
1587   { 1592   {
1588   BOOST_STATIC_CONSTEXPR source_location loc 1593   BOOST_STATIC_CONSTEXPR source_location loc
1589   = BOOST_CURRENT_LOCATION; 1594   = BOOST_CURRENT_LOCATION;
HITCBC 1590   65 return fail(cs.begin(), error::syntax, &loc); 1595   65 return fail(cs.begin(), error::syntax, &loc);
1591   } 1596   }
1592   // Otherwise, append the Unicode replacement character since 1597   // Otherwise, append the Unicode replacement character since
1593   // the first code point is a valid leading surrogate 1598   // the first code point is a valid leading surrogate
1594   else 1599   else
1595   { 1600   {
HITCBC 1596   331 temp.append_utf8(urc); 1601   331 temp.append_utf8(urc);
HITCBC 1597   331 goto do_str3; 1602   331 goto do_str3;
1598   } 1603   }
1599   } 1604   }
HITCBC 1600   2212 ++cs; 1605   2212 ++cs;
HITCBC 1601   2376 do_sur3: 1606   2376 do_sur3:
HITCBC 1602   2376 if(BOOST_JSON_UNLIKELY(! cs)) 1607   2376 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1603   164 return maybe_suspend(cs.begin(), state::sur3); 1608   164 return maybe_suspend(cs.begin(), state::sur3);
HITCBC 1604   2212 digit = detail::hex_digit(*cs); 1609   2212 digit = detail::hex_digit(*cs);
HITCBC 1605   2212 if(BOOST_JSON_UNLIKELY(digit == -1)) 1610   2212 if(BOOST_JSON_UNLIKELY(digit == -1))
1606   { 1611   {
1607   BOOST_STATIC_CONSTEXPR source_location loc 1612   BOOST_STATIC_CONSTEXPR source_location loc
1608   = BOOST_CURRENT_LOCATION; 1613   = BOOST_CURRENT_LOCATION;
HITCBC 1609   35 return fail(cs.begin(), error::expected_hex_digit, &loc); 1614   35 return fail(cs.begin(), error::expected_hex_digit, &loc);
1610   } 1615   }
HITCBC 1611   2177 ++cs; 1616   2177 ++cs;
HITCBC 1612   2177 u2_ = digit << 12; 1617   2177 u2_ = digit << 12;
HITCBC 1613   2339 do_sur4: 1618   2339 do_sur4:
HITCBC 1614   2339 if(BOOST_JSON_UNLIKELY(! cs)) 1619   2339 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1615   162 return maybe_suspend(cs.begin(), state::sur4); 1620   162 return maybe_suspend(cs.begin(), state::sur4);
HITCBC 1616   2177 digit = detail::hex_digit(*cs); 1621   2177 digit = detail::hex_digit(*cs);
HITCBC 1617   2177 if(BOOST_JSON_UNLIKELY(digit == -1)) 1622   2177 if(BOOST_JSON_UNLIKELY(digit == -1))
1618   { 1623   {
1619   BOOST_STATIC_CONSTEXPR source_location loc 1624   BOOST_STATIC_CONSTEXPR source_location loc
1620   = BOOST_CURRENT_LOCATION; 1625   = BOOST_CURRENT_LOCATION;
HITCBC 1621   35 return fail(cs.begin(), error::expected_hex_digit, &loc); 1626   35 return fail(cs.begin(), error::expected_hex_digit, &loc);
1622   } 1627   }
HITCBC 1623   2142 ++cs; 1628   2142 ++cs;
HITCBC 1624   2142 u2_ += digit << 8; 1629   2142 u2_ += digit << 8;
HITCBC 1625   2302 do_sur5: 1630   2302 do_sur5:
HITCBC 1626   2302 if(BOOST_JSON_UNLIKELY(! cs)) 1631   2302 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1627   160 return maybe_suspend(cs.begin(), state::sur5); 1632   160 return maybe_suspend(cs.begin(), state::sur5);
HITCBC 1628   2142 digit = detail::hex_digit(*cs); 1633   2142 digit = detail::hex_digit(*cs);
HITCBC 1629   2142 if(BOOST_JSON_UNLIKELY(digit == -1)) 1634   2142 if(BOOST_JSON_UNLIKELY(digit == -1))
1630   { 1635   {
1631   BOOST_STATIC_CONSTEXPR source_location loc 1636   BOOST_STATIC_CONSTEXPR source_location loc
1632   = BOOST_CURRENT_LOCATION; 1637   = BOOST_CURRENT_LOCATION;
HITCBC 1633   20 return fail(cs.begin(), error::expected_hex_digit, &loc); 1638   20 return fail(cs.begin(), error::expected_hex_digit, &loc);
1634   } 1639   }
HITCBC 1635   2122 ++cs; 1640   2122 ++cs;
HITCBC 1636   2122 u2_ += digit << 4; 1641   2122 u2_ += digit << 4;
HITCBC 1637   2280 do_sur6: 1642   2280 do_sur6:
HITCBC 1638   2280 if(BOOST_JSON_UNLIKELY(! cs)) 1643   2280 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1639   158 return maybe_suspend(cs.begin(), state::sur6); 1644   158 return maybe_suspend(cs.begin(), state::sur6);
HITCBC 1640   2122 digit = detail::hex_digit(*cs); 1645   2122 digit = detail::hex_digit(*cs);
HITCBC 1641   2122 if(BOOST_JSON_UNLIKELY(digit == -1)) 1646   2122 if(BOOST_JSON_UNLIKELY(digit == -1))
1642   { 1647   {
1643   BOOST_STATIC_CONSTEXPR source_location loc 1648   BOOST_STATIC_CONSTEXPR source_location loc
1644   = BOOST_CURRENT_LOCATION; 1649   = BOOST_CURRENT_LOCATION;
HITCBC 1645   20 return fail(cs.begin(), error::expected_hex_digit, &loc); 1650   20 return fail(cs.begin(), error::expected_hex_digit, &loc);
1646   } 1651   }
HITCBC 1647   2102 ++cs; 1652   2102 ++cs;
HITCBC 1648   2102 u2_ += digit; 1653   2102 u2_ += digit;
1649   // Check if the second code point is a valid trailing surrogate. 1654   // Check if the second code point is a valid trailing surrogate.
1650   // Valid trailing surrogates are [DC00, DFFF] 1655   // Valid trailing surrogates are [DC00, DFFF]
HITCBC 1651   2102 if(BOOST_JSON_UNLIKELY( 1656   2102 if(BOOST_JSON_UNLIKELY(
1652   u2_ < 0xdc00 || u2_ > 0xdfff)) 1657   u2_ < 0xdc00 || u2_ > 0xdfff))
1653   { 1658   {
1654   // If not valid and the parser does not allow it, return an error. 1659   // If not valid and the parser does not allow it, return an error.
HITCBC 1655   580 if(!allow_bad_utf16) 1660   580 if(!allow_bad_utf16)
1656   { 1661   {
1657   BOOST_STATIC_CONSTEXPR source_location loc 1662   BOOST_STATIC_CONSTEXPR source_location loc
1658   = BOOST_CURRENT_LOCATION; 1663   = BOOST_CURRENT_LOCATION;
HITCBC 1659   60 return fail(cs.begin(), error::illegal_trailing_surrogate, &loc); 1664   60 return fail(cs.begin(), error::illegal_trailing_surrogate, &loc);
1660   } 1665   }
1661   // Append the replacement character for the 1666   // Append the replacement character for the
1662   // first leading surrogate. 1667   // first leading surrogate.
HITCBC 1663   520 temp.append_utf8(urc); 1668   520 temp.append_utf8(urc);
1664   // Check if the second code point is a 1669   // Check if the second code point is a
1665   // valid unicode scalar value (invalid leading 1670   // valid unicode scalar value (invalid leading
1666   // or trailing surrogate) 1671   // or trailing surrogate)
HITCBC 1667   520 if (u2_ < 0xd800 || u2_ > 0xdbff) 1672   520 if (u2_ < 0xd800 || u2_ > 0xdbff)
1668   { 1673   {
HITCBC 1669   220 temp.append_utf8(u2_); 1674   220 temp.append_utf8(u2_);
HITCBC 1670   220 break; 1675   220 break;
1671   } 1676   }
1672   // If it is a valid leading surrogate 1677   // If it is a valid leading surrogate
1673   else 1678   else
1674   { 1679   {
HITCBC 1675   300 u1_ = u2_; 1680   300 u1_ = u2_;
HITCBC 1676   300 goto do_sur1; 1681   300 goto do_sur1;
1677   } 1682   }
1678   } 1683   }
1679   // Calculate the Unicode code point from the surrogate pair and 1684   // Calculate the Unicode code point from the surrogate pair and
1680   // append the UTF-8 representation. 1685   // append the UTF-8 representation.
HITCBC 1681   1522 unsigned cp = 1686   1522 unsigned cp =
HITCBC 1682   1522 ((u1_ - 0xd800) << 10) + 1687   1522 ((u1_ - 0xd800) << 10) +
HITCBC 1683   1522 ((u2_ - 0xdc00)) + 1688   1522 ((u2_ - 0xdc00)) +
1684   0x10000; 1689   0x10000;
1685   // utf-16 surrogate pair 1690   // utf-16 surrogate pair
HITCBC 1686   1522 temp.append_utf8(cp); 1691   1522 temp.append_utf8(cp);
1687   } 1692   }
1688   1693  
1689   // flush 1694   // flush
HITCBC 1690   12653 if(BOOST_JSON_UNLIKELY( !cs ) || *cs != '\\') 1695   12653 if(BOOST_JSON_UNLIKELY( !cs ) || *cs != '\\')
HITCBC 1691   8870 break; 1696   8870 break;
1692   } 1697   }
1693   1698  
HITCBC 1694   8870 if(BOOST_JSON_LIKELY( temp.size() )) 1699   8870 if(BOOST_JSON_LIKELY( temp.size() ))
1695   { 1700   {
HITCBC 1696   434 BOOST_ASSERT(total <= max_size); 1701   434 BOOST_ASSERT(total <= max_size);
HITCBC 1697   8870 if(BOOST_JSON_UNLIKELY( temp.size() > max_size - total )) 1702   8870 if(BOOST_JSON_UNLIKELY( temp.size() > max_size - total ))
1698   { 1703   {
1699   BOOST_STATIC_CONSTEXPR source_location loc 1704   BOOST_STATIC_CONSTEXPR source_location loc
1700   = BOOST_CURRENT_LOCATION; 1705   = BOOST_CURRENT_LOCATION;
HITCBC 1701   1 return fail(cs.begin(), ev_too_large, &loc); 1706   1 return fail(cs.begin(), ev_too_large, &loc);
1702   } 1707   }
1703   1708  
HITCBC 1704   8869 total += temp.size(); 1709   8869 total += temp.size();
HITCBC 1705   8056 bool const r = is_key 1710   8056 bool const r = is_key
HITCBC 1706   8869 ? h_.on_key_part(temp.get(), total, ec_) 1711   8869 ? h_.on_key_part(temp.get(), total, ec_)
HITCBC 1707   8152 : h_.on_string_part(temp.get(), total, ec_); 1712   8152 : h_.on_string_part(temp.get(), total, ec_);
HITCBC 1708   8056 if(BOOST_JSON_UNLIKELY( !r )) 1713   8056 if(BOOST_JSON_UNLIKELY( !r ))
HITCBC 1709   813 return fail( cs.begin() ); 1714   813 return fail( cs.begin() );
1710   } 1715   }
1711   1716  
HITCBC 1712   7243 return cs.begin(); 1717   7243 return cs.begin();
1713   } 1718   }
1714   1719  
1715   //---------------------------------------------------------- 1720   //----------------------------------------------------------
1716   1721  
1717   template<class Handler> 1722   template<class Handler>
1718   template< 1723   template<
1719   bool StackEmpty_, 1724   bool StackEmpty_,
1720   bool AllowComments_/*, 1725   bool AllowComments_/*,
1721   bool AllowTrailing_, 1726   bool AllowTrailing_,
1722   bool AllowBadUTF8_*/> 1727   bool AllowBadUTF8_*/>
1723   const char* 1728   const char*
HITCBC 1724   109189 basic_parser<Handler>:: 1729   109189 basic_parser<Handler>::
1725   parse_object(const char* p, 1730   parse_object(const char* p,
1726   std::integral_constant<bool, StackEmpty_> stack_empty, 1731   std::integral_constant<bool, StackEmpty_> stack_empty,
1727   std::integral_constant<bool, AllowComments_> allow_comments, 1732   std::integral_constant<bool, AllowComments_> allow_comments,
1728   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing, 1733   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
1729   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8, 1734   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
1730   bool allow_bad_utf16) 1735   bool allow_bad_utf16)
1731   { 1736   {
HITCBC 1732   109189 detail::const_stream_wrapper cs(p, end_); 1737   109189 detail::const_stream_wrapper cs(p, end_);
1733   std::size_t size; 1738   std::size_t size;
HITCBC 1734   109189 if(! stack_empty && ! st_.empty()) 1739   109189 if(! stack_empty && ! st_.empty())
1735   { 1740   {
1736   // resume 1741   // resume
1737   state st; 1742   state st;
HITCBC 1738   35058 st_.pop(st); 1743   35058 st_.pop(st);
HITCBC 1739   35058 st_.pop(size); 1744   35058 st_.pop(size);
HITCBC 1740   35058 switch(st) 1745   35058 switch(st)
1741   { 1746   {
1742   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 1747   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 1743   1595 case state::obj1: goto do_obj1; 1748   1595 case state::obj1: goto do_obj1;
HITCBC 1744   235 case state::obj2: goto do_obj2; 1749   235 case state::obj2: goto do_obj2;
HITCBC 1745   12647 case state::obj3: goto do_obj3; 1750   12647 case state::obj3: goto do_obj3;
HITCBC 1746   1690 case state::obj4: goto do_obj4; 1751   1690 case state::obj4: goto do_obj4;
HITCBC 1747   251 case state::obj5: goto do_obj5; 1752   251 case state::obj5: goto do_obj5;
HITCBC 1748   1591 case state::obj6: goto do_obj6; 1753   1591 case state::obj6: goto do_obj6;
HITCBC 1749   15448 case state::obj7: goto do_obj7; 1754   15448 case state::obj7: goto do_obj7;
HITCBC 1750   426 case state::obj8: goto do_obj8; 1755   426 case state::obj8: goto do_obj8;
HITCBC 1751   660 case state::obj9: goto do_obj9; 1756   660 case state::obj9: goto do_obj9;
HITCBC 1752   181 case state::obj10: goto do_obj10; 1757   181 case state::obj10: goto do_obj10;
HITCBC 1753   334 case state::obj11: goto do_obj11; 1758   334 case state::obj11: goto do_obj11;
1754   } 1759   }
1755   } 1760   }
HITCBC 1756   74131 BOOST_ASSERT(*cs == '{'); 1761   74131 BOOST_ASSERT(*cs == '{');
HITCBC 1757   74131 size = 0; 1762   74131 size = 0;
HITCBC 1758   74131 if(BOOST_JSON_UNLIKELY(! depth_)) 1763   74131 if(BOOST_JSON_UNLIKELY(! depth_))
1759   { 1764   {
1760   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 1765   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 1761   3 return fail(cs.begin(), error::too_deep, &loc); 1766   3 return fail(cs.begin(), error::too_deep, &loc);
1762   } 1767   }
HITCBC 1763   74128 --depth_; 1768   74128 --depth_;
HITCBC 1764   74128 if(BOOST_JSON_UNLIKELY( 1769   74128 if(BOOST_JSON_UNLIKELY(
1765   ! h_.on_object_begin(ec_))) 1770   ! h_.on_object_begin(ec_)))
HITCBC 1766   2040 return fail(cs.begin()); 1771   2040 return fail(cs.begin());
HITCBC 1767   70050 ++cs; 1772   70050 ++cs;
1768   // object: 1773   // object:
1769   // '{' *ws '}' 1774   // '{' *ws '}'
1770   // '{' *ws string *ws ':' *ws value *ws *[ ',' *ws string *ws ':' *ws value *ws ] '}' 1775   // '{' *ws string *ws ':' *ws value *ws *[ ',' *ws string *ws ':' *ws value *ws ] '}'
HITCBC 1771   73616 do_obj1: 1776   73616 do_obj1:
HITCBC 1772   73616 cs = detail::count_whitespace(cs.begin(), cs.end()); 1777   73616 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1773   73616 if(BOOST_JSON_UNLIKELY(! cs)) 1778   73616 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1774   1629 return maybe_suspend(cs.begin(), state::obj1, size); 1779   1629 return maybe_suspend(cs.begin(), state::obj1, size);
HITCBC 1775   71987 if(BOOST_JSON_LIKELY(*cs != '}')) 1780   71987 if(BOOST_JSON_LIKELY(*cs != '}'))
1776   { 1781   {
HITCBC 1777   69088 if(BOOST_JSON_UNLIKELY(*cs != '\x22')) 1782   69088 if(BOOST_JSON_UNLIKELY(*cs != '\x22'))
1778   { 1783   {
HITCBC 1779   2411 if(allow_comments && *cs == '/') 1784   2411 if(allow_comments && *cs == '/')
1780   { 1785   {
HITCBC 1781   2139 do_obj2: 1786   2139 do_obj2:
HITCBC 1782   2374 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1787   2374 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1783   2290 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1788   2290 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1784   319 return suspend_or_fail(state::obj2, size); 1789   319 return suspend_or_fail(state::obj2, size);
HITCBC 1785   1971 goto do_obj1; 1790   1971 goto do_obj1;
1786   } 1791   }
1787   BOOST_STATIC_CONSTEXPR source_location loc 1792   BOOST_STATIC_CONSTEXPR source_location loc
1788   = BOOST_CURRENT_LOCATION; 1793   = BOOST_CURRENT_LOCATION;
HITCBC 1789   272 return fail(cs.begin(), error::syntax, &loc); 1794   272 return fail(cs.begin(), error::syntax, &loc);
1790   } 1795   }
HITCBC 1791   66677 loop: 1796   66677 loop:
HITCBC 1792   80829 if(BOOST_JSON_UNLIKELY(++size > 1797   80829 if(BOOST_JSON_UNLIKELY(++size >
1793   Handler::max_object_size)) 1798   Handler::max_object_size))
1794   { 1799   {
1795   BOOST_STATIC_CONSTEXPR source_location loc 1800   BOOST_STATIC_CONSTEXPR source_location loc
1796   = BOOST_CURRENT_LOCATION; 1801   = BOOST_CURRENT_LOCATION;
HITCBC 1797   1 return fail(cs.begin(), error::object_too_large, &loc); 1802   1 return fail(cs.begin(), error::object_too_large, &loc);
1798   } 1803   }
HITCBC 1799   80828 do_obj3: 1804   80828 do_obj3:
HITCBC 1800   93475 cs = parse_string(cs.begin(), stack_empty, std::true_type(), allow_bad_utf8, allow_bad_utf16); 1805   93475 cs = parse_string(cs.begin(), stack_empty, std::true_type(), allow_bad_utf8, allow_bad_utf16);
HITCBC 1801   90519 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1806   90519 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1802   15592 return suspend_or_fail(state::obj3, size); 1807   15592 return suspend_or_fail(state::obj3, size);
HITCBC 1803   74927 do_obj4: 1808   74927 do_obj4:
HITCBC 1804   79088 cs = detail::count_whitespace(cs.begin(), cs.end()); 1809   79088 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1805   79088 if(BOOST_JSON_UNLIKELY(! cs)) 1810   79088 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1806   1705 return maybe_suspend(cs.begin(), state::obj4, size); 1811   1705 return maybe_suspend(cs.begin(), state::obj4, size);
HITCBC 1807   77383 if(BOOST_JSON_UNLIKELY(*cs != ':')) 1812   77383 if(BOOST_JSON_UNLIKELY(*cs != ':'))
1808   { 1813   {
HITCBC 1809   2925 if(allow_comments && *cs == '/') 1814   2925 if(allow_comments && *cs == '/')
1810   { 1815   {
HITCBC 1811   2779 do_obj5: 1816   2779 do_obj5:
HITCBC 1812   3030 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1817   3030 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1813   2876 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1818   2876 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1814   405 return suspend_or_fail(state::obj5, size); 1819   405 return suspend_or_fail(state::obj5, size);
HITCBC 1815   2471 goto do_obj4; 1820   2471 goto do_obj4;
1816   } 1821   }
1817   BOOST_STATIC_CONSTEXPR source_location loc 1822   BOOST_STATIC_CONSTEXPR source_location loc
1818   = BOOST_CURRENT_LOCATION; 1823   = BOOST_CURRENT_LOCATION;
HITCBC 1819   146 return fail(cs.begin(), error::syntax, &loc); 1824   146 return fail(cs.begin(), error::syntax, &loc);
1820   } 1825   }
HITCBC 1821   74458 ++cs; 1826   74458 ++cs;
HITCBC 1822   76049 do_obj6: 1827   76049 do_obj6:
HITCBC 1823   76049 cs = detail::count_whitespace(cs.begin(), cs.end()); 1828   76049 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1824   76049 if(BOOST_JSON_UNLIKELY(! cs)) 1829   76049 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1825   1622 return maybe_suspend(cs.begin(), state::obj6, size); 1830   1622 return maybe_suspend(cs.begin(), state::obj6, size);
HITCBC 1826   74427 do_obj7: 1831   74427 do_obj7:
HITCBC 1827   89875 cs = parse_value(cs.begin(), stack_empty, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 1832   89875 cs = parse_value(cs.begin(), stack_empty, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
HITCBC 1828   82526 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1833   82526 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1829   23593 return suspend_or_fail(state::obj7, size); 1834   23593 return suspend_or_fail(state::obj7, size);
HITCBC 1830   58933 do_obj8: 1835   58933 do_obj8:
HITCBC 1831   61195 cs = detail::count_whitespace(cs.begin(), cs.end()); 1836   61195 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1832   61195 if(BOOST_JSON_UNLIKELY(! cs)) 1837   61195 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1833   441 return maybe_suspend(cs.begin(), state::obj8, size); 1838   441 return maybe_suspend(cs.begin(), state::obj8, size);
HITCBC 1834   60754 if(BOOST_JSON_LIKELY(*cs == ',')) 1839   60754 if(BOOST_JSON_LIKELY(*cs == ','))
1835   { 1840   {
HITCBC 1836   17792 ++cs; 1841   17792 ++cs;
HITCBC 1837   19707 do_obj9: 1842   19707 do_obj9:
HITCBC 1838   19707 cs = detail::count_whitespace(cs.begin(), cs.end()); 1843   19707 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1839   19707 if(BOOST_JSON_UNLIKELY(! cs)) 1844   19707 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1840   690 return maybe_suspend(cs.begin(), state::obj9, size); 1845   690 return maybe_suspend(cs.begin(), state::obj9, size);
1841   1846  
1842   // loop for next element 1847   // loop for next element
HITCBC 1843   19017 if(BOOST_JSON_LIKELY(*cs == '\x22')) 1848   19017 if(BOOST_JSON_LIKELY(*cs == '\x22'))
HITCBC 1844   14152 goto loop; 1849   14152 goto loop;
HITCBC 1845   4865 if(! allow_trailing || *cs != '}') 1850   4865 if(! allow_trailing || *cs != '}')
1846   { 1851   {
HITCBC 1847   1644 if(allow_comments && *cs == '/') 1852   1644 if(allow_comments && *cs == '/')
1848   { 1853   {
HITCBC 1849   1433 do_obj10: 1854   1433 do_obj10:
HITCBC 1850   1614 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1855   1614 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1851   1525 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1856   1525 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1852   270 return suspend_or_fail(state::obj10, size); 1857   270 return suspend_or_fail(state::obj10, size);
HITCBC 1853   1255 goto do_obj9; 1858   1255 goto do_obj9;
1854   } 1859   }
1855   BOOST_STATIC_CONSTEXPR source_location loc 1860   BOOST_STATIC_CONSTEXPR source_location loc
1856   = BOOST_CURRENT_LOCATION; 1861   = BOOST_CURRENT_LOCATION;
HITCBC 1857   211 return fail(cs.begin(), error::syntax, &loc); 1862   211 return fail(cs.begin(), error::syntax, &loc);
1858   } 1863   }
1859   } 1864   }
HITCBC 1860   42962 else if(BOOST_JSON_UNLIKELY(*cs != '}')) 1865   42962 else if(BOOST_JSON_UNLIKELY(*cs != '}'))
1861   { 1866   {
HITCBC 1862   2325 if(allow_comments && *cs == '/') 1867   2325 if(allow_comments && *cs == '/')
1863   { 1868   {
HITCBC 1864   2172 do_obj11: 1869   2172 do_obj11:
HITCBC 1865   2506 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1870   2506 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1866   2338 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1871   2338 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1867   502 return suspend_or_fail(state::obj11, size); 1872   502 return suspend_or_fail(state::obj11, size);
HITCBC 1868   1836 goto do_obj8; 1873   1836 goto do_obj8;
1869   } 1874   }
1870   BOOST_STATIC_CONSTEXPR source_location loc 1875   BOOST_STATIC_CONSTEXPR source_location loc
1871   = BOOST_CURRENT_LOCATION; 1876   = BOOST_CURRENT_LOCATION;
HITCBC 1872   153 return fail(cs.begin(), error::syntax, &loc); 1877   153 return fail(cs.begin(), error::syntax, &loc);
1873   } 1878   }
1874   // got closing brace, fall through 1879   // got closing brace, fall through
1875   } 1880   }
HITCBC 1876   46757 if(BOOST_JSON_UNLIKELY( 1881   46757 if(BOOST_JSON_UNLIKELY(
1877   ! h_.on_object_end(size, ec_))) 1882   ! h_.on_object_end(size, ec_)))
HITCBC 1878   1502 return fail(cs.begin()); 1883   1502 return fail(cs.begin());
HITCBC 1879   43714 ++depth_; 1884   43714 ++depth_;
HITCBC 1880   43714 ++cs; 1885   43714 ++cs;
HITCBC 1881   43714 return cs.begin(); 1886   43714 return cs.begin();
1882   } 1887   }
1883   1888  
1884   //---------------------------------------------------------- 1889   //----------------------------------------------------------
1885   1890  
1886   template<class Handler> 1891   template<class Handler>
1887   template< 1892   template<
1888   bool StackEmpty_, 1893   bool StackEmpty_,
1889   bool AllowComments_/*, 1894   bool AllowComments_/*,
1890   bool AllowTrailing_, 1895   bool AllowTrailing_,
1891   bool AllowBadUTF8_*/> 1896   bool AllowBadUTF8_*/>
1892   const char* 1897   const char*
HITCBC 1893   26348 basic_parser<Handler>:: 1898   26348 basic_parser<Handler>::
1894   parse_array(const char* p, 1899   parse_array(const char* p,
1895   std::integral_constant<bool, StackEmpty_> stack_empty, 1900   std::integral_constant<bool, StackEmpty_> stack_empty,
1896   std::integral_constant<bool, AllowComments_> allow_comments, 1901   std::integral_constant<bool, AllowComments_> allow_comments,
1897   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing, 1902   /*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
1898   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8, 1903   /*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
1899   bool allow_bad_utf16) 1904   bool allow_bad_utf16)
1900   { 1905   {
HITCBC 1901   26348 detail::const_stream_wrapper cs(p, end_); 1906   26348 detail::const_stream_wrapper cs(p, end_);
1902   std::size_t size; 1907   std::size_t size;
HITCBC 1903   26348 if(! stack_empty && ! st_.empty()) 1908   26348 if(! stack_empty && ! st_.empty())
1904   { 1909   {
1905   // resume 1910   // resume
1906   state st; 1911   state st;
HITCBC 1907   5730 st_.pop(st); 1912   5730 st_.pop(st);
HITCBC 1908   5730 st_.pop(size); 1913   5730 st_.pop(size);
HITCBC 1909   5730 switch(st) 1914   5730 switch(st)
1910   { 1915   {
1911   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 1916   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 1912   1052 case state::arr1: goto do_arr1; 1917   1052 case state::arr1: goto do_arr1;
HITCBC 1913   384 case state::arr2: goto do_arr2; 1918   384 case state::arr2: goto do_arr2;
HITCBC 1914   2938 case state::arr3: goto do_arr3; 1919   2938 case state::arr3: goto do_arr3;
HITCBC 1915   391 case state::arr4: goto do_arr4; 1920   391 case state::arr4: goto do_arr4;
HITCBC 1916   671 case state::arr5: goto do_arr5; 1921   671 case state::arr5: goto do_arr5;
HITCBC 1917   294 case state::arr6: goto do_arr6; 1922   294 case state::arr6: goto do_arr6;
1918   } 1923   }
1919   } 1924   }
HITCBC 1920   20618 BOOST_ASSERT(*cs == '['); 1925   20618 BOOST_ASSERT(*cs == '[');
HITCBC 1921   20618 size = 0; 1926   20618 size = 0;
HITCBC 1922   20618 if(BOOST_JSON_UNLIKELY(! depth_)) 1927   20618 if(BOOST_JSON_UNLIKELY(! depth_))
1923   { 1928   {
1924   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION; 1929   BOOST_STATIC_CONSTEXPR source_location loc = BOOST_CURRENT_LOCATION;
HITCBC 1925   34 return fail(cs.begin(), error::too_deep, &loc); 1930   34 return fail(cs.begin(), error::too_deep, &loc);
1926   } 1931   }
HITCBC 1927   20584 --depth_; 1932   20584 --depth_;
HITCBC 1928   20584 if(BOOST_JSON_UNLIKELY( 1933   20584 if(BOOST_JSON_UNLIKELY(
1929   ! h_.on_array_begin(ec_))) 1934   ! h_.on_array_begin(ec_)))
HITCBC 1930   812 return fail(cs.begin()); 1935   812 return fail(cs.begin());
HITCBC 1931   18966 ++cs; 1936   18966 ++cs;
1932   // array: 1937   // array:
1933   // '[' *ws ']' 1938   // '[' *ws ']'
1934   // '[' *ws value *ws *[ ',' *ws value *ws ] ']' 1939   // '[' *ws value *ws *[ ',' *ws value *ws ] ']'
HITCBC 1935   21551 do_arr1: 1940   21551 do_arr1:
HITCBC 1936   21551 cs = detail::count_whitespace(cs.begin(), cs.end()); 1941   21551 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1937   21551 if(BOOST_JSON_UNLIKELY(! cs)) 1942   21551 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1938   1073 return maybe_suspend(cs.begin(), state::arr1, size); 1943   1073 return maybe_suspend(cs.begin(), state::arr1, size);
HITCBC 1939   20478 if(BOOST_JSON_LIKELY(*cs != ']')) 1944   20478 if(BOOST_JSON_LIKELY(*cs != ']'))
1940   { 1945   {
HITCBC 1941   18730 loop: 1946   18730 loop:
HITCBC 1942   26193 if(allow_comments && *cs == '/') 1947   26193 if(allow_comments && *cs == '/')
1943   { 1948   {
HITCBC 1944   1789 do_arr2: 1949   1789 do_arr2:
HITCBC 1945   2173 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1950   2173 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1946   2045 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1951   2045 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1947   512 return suspend_or_fail(state::arr2, size); 1952   512 return suspend_or_fail(state::arr2, size);
HITCBC 1948   1533 goto do_arr1; 1953   1533 goto do_arr1;
1949   } 1954   }
HITCBC 1950   24404 if(BOOST_JSON_UNLIKELY(++size > 1955   24404 if(BOOST_JSON_UNLIKELY(++size >
1951   Handler::max_array_size)) 1956   Handler::max_array_size))
1952   { 1957   {
1953   BOOST_STATIC_CONSTEXPR source_location loc 1958   BOOST_STATIC_CONSTEXPR source_location loc
1954   = BOOST_CURRENT_LOCATION; 1959   = BOOST_CURRENT_LOCATION;
HITCBC 1955   1 return fail(cs.begin(), error::array_too_large, &loc); 1960   1 return fail(cs.begin(), error::array_too_large, &loc);
1956   } 1961   }
HITCBC 1957   24403 do_arr3: 1962   24403 do_arr3:
1958   // array is not empty, value required 1963   // array is not empty, value required
HITCBC 1959   27341 cs = parse_value(cs.begin(), stack_empty, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16); 1964   27341 cs = parse_value(cs.begin(), stack_empty, allow_comments, allow_trailing, allow_bad_utf8, allow_bad_utf16);
HITCBC 1960   24710 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1965   24710 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1961   9052 return suspend_or_fail(state::arr3, size); 1966   9052 return suspend_or_fail(state::arr3, size);
HITCBC 1962   15658 do_arr4: 1967   15658 do_arr4:
HITCBC 1963   17279 cs = detail::count_whitespace(cs.begin(), cs.end()); 1968   17279 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1964   17279 if(BOOST_JSON_UNLIKELY(! cs)) 1969   17279 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1965   500 return maybe_suspend(cs.begin(), state::arr4, size); 1970   500 return maybe_suspend(cs.begin(), state::arr4, size);
HITCBC 1966   16779 if(BOOST_JSON_LIKELY(*cs == ',')) 1971   16779 if(BOOST_JSON_LIKELY(*cs == ','))
1967   { 1972   {
HITCBC 1968   9176 ++cs; 1973   9176 ++cs;
HITCBC 1969   9847 do_arr5: 1974   9847 do_arr5:
HITCBC 1970   9847 cs = detail::count_whitespace(cs.begin(), cs.end()); 1975   9847 cs = detail::count_whitespace(cs.begin(), cs.end());
HITCBC 1971   9847 if(BOOST_JSON_UNLIKELY(! cs)) 1976   9847 if(BOOST_JSON_UNLIKELY(! cs))
HITCBC 1972   701 return maybe_suspend(cs.begin(), state::arr5, size); 1977   701 return maybe_suspend(cs.begin(), state::arr5, size);
1973   // loop for next element 1978   // loop for next element
HITCBC 1974   9146 if(! allow_trailing || *cs != ']') 1979   9146 if(! allow_trailing || *cs != ']')
HITCBC 1975   7463 goto loop; 1980   7463 goto loop;
1976   } 1981   }
HITCBC 1977   7603 else if(BOOST_JSON_UNLIKELY(*cs != ']')) 1982   7603 else if(BOOST_JSON_UNLIKELY(*cs != ']'))
1978   { 1983   {
HITCBC 1979   1969 if(allow_comments && *cs == '/') 1984   1969 if(allow_comments && *cs == '/')
1980   { 1985   {
HITCBC 1981   1541 do_arr6: 1986   1541 do_arr6:
HITCBC 1982   1835 cs = parse_comment(cs.begin(), stack_empty, std::false_type()); 1987   1835 cs = parse_comment(cs.begin(), stack_empty, std::false_type());
HITCBC 1983   1688 if(BOOST_JSON_UNLIKELY(incomplete(cs))) 1988   1688 if(BOOST_JSON_UNLIKELY(incomplete(cs)))
HITCBC 1984   458 return suspend_or_fail(state::arr6, size); 1989   458 return suspend_or_fail(state::arr6, size);
HITCBC 1985   1230 goto do_arr4; 1990   1230 goto do_arr4;
1986   } 1991   }
1987   BOOST_STATIC_CONSTEXPR source_location loc 1992   BOOST_STATIC_CONSTEXPR source_location loc
1988   = BOOST_CURRENT_LOCATION; 1993   = BOOST_CURRENT_LOCATION;
HITCBC 1989   428 return fail(cs.begin(), error::syntax, &loc); 1994   428 return fail(cs.begin(), error::syntax, &loc);
1990   } 1995   }
1991   // got closing bracket; fall through 1996   // got closing bracket; fall through
1992   } 1997   }
HITCBC 1993   9065 if(BOOST_JSON_UNLIKELY( 1998   9065 if(BOOST_JSON_UNLIKELY(
1994   ! h_.on_array_end(size, ec_))) 1999   ! h_.on_array_end(size, ec_)))
HITCBC 1995   547 return fail(cs.begin()); 2000   547 return fail(cs.begin());
HITCBC 1996   7939 ++depth_; 2001   7939 ++depth_;
HITCBC 1997   7939 ++cs; 2002   7939 ++cs;
HITCBC 1998   7939 return cs.begin(); 2003   7939 return cs.begin();
1999   } 2004   }
2000   2005  
2001   //---------------------------------------------------------- 2006   //----------------------------------------------------------
2002   2007  
2003   template<class Handler> 2008   template<class Handler>
2004   template<bool StackEmpty_, char First_, number_precision Numbers_> 2009   template<bool StackEmpty_, char First_, number_precision Numbers_>
2005   const char* 2010   const char*
HITCBC 2006   10515955 basic_parser<Handler>:: 2011   10515990 basic_parser<Handler>::
2007   parse_number(const char* p, 2012   parse_number(const char* p,
2008   std::integral_constant<bool, StackEmpty_> stack_empty, 2013   std::integral_constant<bool, StackEmpty_> stack_empty,
2009   std::integral_constant<char, First_> first, 2014   std::integral_constant<char, First_> first,
2010   std::integral_constant<number_precision, Numbers_> mode) 2015   std::integral_constant<number_precision, Numbers_> mode)
2011   { 2016   {
HITCBC 2012   10515955 constexpr bool precise_parsing = mode == number_precision::precise; 2017   10515990 constexpr bool precise_parsing = mode == number_precision::precise;
HITCBC 2013   10515955 constexpr bool no_parsing = mode == number_precision::none; 2018   10515990 constexpr bool no_parsing = mode == number_precision::none;
2014   2019  
2015   // only one of these will be true if we are not resuming 2020   // only one of these will be true if we are not resuming
2016   // if negative then !zero_first && !nonzero_first 2021   // if negative then !zero_first && !nonzero_first
2017   // if zero_first then !nonzero_first && !negative 2022   // if zero_first then !nonzero_first && !negative
2018   // if nonzero_first then !zero_first && !negative 2023   // if nonzero_first then !zero_first && !negative
HITCBC 2019   10515955 bool const negative = first == '-'; 2024   10515990 bool const negative = first == '-';
HITCBC 2020   10515955 bool const zero_first = first == '0'; 2025   10515990 bool const zero_first = first == '0';
HITCBC 2021   10515955 bool const nonzero_first = first == '+'; 2026   10515990 bool const nonzero_first = first == '+';
HITCBC 2022   10515955 detail::const_stream_wrapper cs(p, end_); 2027   10515990 detail::const_stream_wrapper cs(p, end_);
2023   number num; 2028   number num;
HITCBC 2024   10515955 const char* begin = cs.begin(); 2029   10515990 const char* begin = cs.begin();
HITCBC 2025   10515955 if(stack_empty || st_.empty()) 2030   10515990 if(stack_empty || st_.empty())
2026   { 2031   {
HITCBC 2027   2089958 num.bias = 0; 2032   2089971 num.bias = 0;
HITCBC 2028   2089958 num.exp = 0; 2033   2089971 num.exp = 0;
HITCBC 2029   2089958 num.frac = false; 2034   2089971 num.frac = false;
HITCBC 2030   2089958 num_buf_.clear(); 2035   2089971 num_buf_.clear();
2031   2036  
2032   //---------------------------------- 2037   //----------------------------------
2033   // 2038   //
2034   // '-' 2039   // '-'
2035   // leading minus sign 2040   // leading minus sign
2036   // 2041   //
HITCBC 2037   2089958 BOOST_ASSERT(cs); 2042   2089971 BOOST_ASSERT(cs);
2038   if(negative) 2043   if(negative)
HITCBC 2039   25178 ++cs; 2044   25185 ++cs;
2040   2045  
HITCBC 2041   2089958 num.neg = negative; 2046   2089971 num.neg = negative;
HITCBC 2042   2089958 num.frac = false; 2047   2089971 num.frac = false;
HITCBC 2043   2089958 num.exp = 0; 2048   2089971 num.exp = 0;
HITCBC 2044   2089958 num.bias = 0; 2049   2089971 num.bias = 0;
2045   2050  
2046   // fast path 2051   // fast path
HITCBC 2047   2089958 if( cs.remain() >= 16 + 1 + 16 ) // digits . digits 2052   2089971 if( cs.remain() >= 16 + 1 + 16 ) // digits . digits
2048   { 2053   {
2049   int n1; 2054   int n1;
2050   2055  
HITCBC 2051   9989 if( nonzero_first || 2056   9989 if( nonzero_first ||
HITCBC 2052   9989 (negative && *cs != '0') ) 2057   9989 (negative && *cs != '0') )
2053   { 2058   {
HITCBC 2054   2007319 n1 = detail::count_digits( cs.begin() ); 2059   2007319 n1 = detail::count_digits( cs.begin() );
HITCBC 2055   2007319 BOOST_ASSERT(n1 >= 0 && n1 <= 16); 2060   2007319 BOOST_ASSERT(n1 >= 0 && n1 <= 16);
2056   2061  
HITCBC 2057   1837 if( negative && n1 == 0 && opt_.allow_infinity_and_nan ) 2062   1837 if( negative && n1 == 0 && opt_.allow_infinity_and_nan )
2058   { 2063   {
HITCBC 2059   9 return parse_literal( 2064   9 return parse_literal(
2060   p - 1, 2065   p - 1,
HITCBC 2061   8 detail::literals_c<detail::literals::neg_infinity>()); 2066   8 detail::literals_c<detail::literals::neg_infinity>());
2062   } 2067   }
2063   2068  
HITCBC 2064   1828 if( ! nonzero_first && n1 == 0 ) 2069   1828 if( ! nonzero_first && n1 == 0 )
2065   { 2070   {
2066   // digit required 2071   // digit required
2067   BOOST_STATIC_CONSTEXPR source_location loc 2072   BOOST_STATIC_CONSTEXPR source_location loc
2068   = BOOST_CURRENT_LOCATION; 2073   = BOOST_CURRENT_LOCATION;
HITCBC 2069   2 return fail(cs.begin(), error::syntax, &loc); 2074   2 return fail(cs.begin(), error::syntax, &loc);
2070   } 2075   }
2071   2076  
2072   BOOST_IF_CONSTEXPR( !no_parsing ) 2077   BOOST_IF_CONSTEXPR( !no_parsing )
HITCBC 2073   2006460 num.mant = detail::parse_unsigned( 0, cs.begin(), n1 ); 2078   2006460 num.mant = detail::parse_unsigned( 0, cs.begin(), n1 );
2074   else 2079   else
HITCBC 2075   848 num.mant = 0; 2080   848 num.mant = 0;
2076   2081  
HITCBC 2077   2007308 cs += n1; 2082   2007308 cs += n1;
2078   2083  
2079   // integer or floating-point with 2084   // integer or floating-point with
2080   // >= 16 leading digits 2085   // >= 16 leading digits
HITCBC 2081   2007308 if( n1 == 16 ) 2086   2007308 if( n1 == 16 )
2082   { 2087   {
HITCBC 2083   2001425 goto do_num2; 2088   2001425 goto do_num2;
2084   } 2089   }
2085   } 2090   }
2086   else 2091   else
2087   { 2092   {
2088   // 0. floating-point or 0e integer 2093   // 0. floating-point or 0e integer
HITCBC 2089   21187 num.mant = 0; 2094   21187 num.mant = 0;
HITCBC 2090   21187 n1 = 0; 2095   21187 n1 = 0;
HITCBC 2091   21187 ++cs; 2096   21187 ++cs;
2092   } 2097   }
2093   2098  
2094   { 2099   {
HITCBC 2095   27070 const char c = *cs; 2100   27070 const char c = *cs;
HITCBC 2096   27070 if(c != '.') 2101   27070 if(c != '.')
2097   { 2102   {
HITCBC 2098   9871 if((c | 32) == 'e') 2103   9871 if((c | 32) == 'e')
2099   { 2104   {
HITCBC 2100   6576 ++cs; 2105   6576 ++cs;
HITCBC 2101   6576 goto do_exp1; 2106   6576 goto do_exp1;
2102   } 2107   }
2103   BOOST_IF_CONSTEXPR( negative && !no_parsing ) 2108   BOOST_IF_CONSTEXPR( negative && !no_parsing )
HITCBC 2104   20 num.mant = ~num.mant + 1; 2109   20 num.mant = ~num.mant + 1;
HITCBC 2105   3295 goto finish_signed; 2110   3295 goto finish_signed;
2106   } 2111   }
2107   } 2112   }
2108   2113  
2109   // floating-point number 2114   // floating-point number
2110   2115  
HITCBC 2111   17199 ++cs; 2116   17199 ++cs;
2112   2117  
HITCBC 2113   17199 int n2 = detail::count_digits( cs.begin() ); 2118   17199 int n2 = detail::count_digits( cs.begin() );
HITCBC 2114   17199 BOOST_ASSERT(n2 >= 0 && n2 <= 16); 2119   17199 BOOST_ASSERT(n2 >= 0 && n2 <= 16);
2115   2120  
HITCBC 2116   17199 if( n2 == 0 ) 2121   17199 if( n2 == 0 )
2117   { 2122   {
2118   // digit required 2123   // digit required
2119   BOOST_STATIC_CONSTEXPR source_location loc 2124   BOOST_STATIC_CONSTEXPR source_location loc
2120   = BOOST_CURRENT_LOCATION; 2125   = BOOST_CURRENT_LOCATION;
HITCBC 2121   3 return fail(cs.begin(), error::syntax, &loc); 2126   3 return fail(cs.begin(), error::syntax, &loc);
2122   } 2127   }
2123   2128  
2124   // floating-point mantissa overflow 2129   // floating-point mantissa overflow
HITCBC 2125   17196 if( n1 + n2 >= 19 ) 2130   17196 if( n1 + n2 >= 19 )
2126   { 2131   {
HITCBC 2127   122 goto do_num7; 2132   122 goto do_num7;
2128   } 2133   }
2129   2134  
2130   BOOST_IF_CONSTEXPR( !no_parsing ) 2135   BOOST_IF_CONSTEXPR( !no_parsing )
HITCBC 2131   12855 num.mant = detail::parse_unsigned( num.mant, cs.begin(), n2 ); 2136   12855 num.mant = detail::parse_unsigned( num.mant, cs.begin(), n2 );
2132   2137  
HITCBC 2133   17074 BOOST_ASSERT(num.bias == 0); 2138   17074 BOOST_ASSERT(num.bias == 0);
2134   2139  
HITCBC 2135   17074 num.bias -= n2; 2140   17074 num.bias -= n2;
2136   2141  
HITCBC 2137   17074 cs += n2; 2142   17074 cs += n2;
2138   2143  
HITCBC 2139   17074 char ch = *cs; 2144   17074 char ch = *cs;
2140   2145  
HITCBC 2141   17074 if( (ch | 32) == 'e' ) 2146   17074 if( (ch | 32) == 'e' )
2142   { 2147   {
HITCBC 2143   110 ++cs; 2148   110 ++cs;
HITCBC 2144   110 goto do_exp1; 2149   110 goto do_exp1;
2145   } 2150   }
HITCBC 2146   16964 else if( ch >= '0' && ch <= '9' ) 2151   16964 else if( ch >= '0' && ch <= '9' )
2147   { 2152   {
HITCBC 2148   10017 goto do_num8; 2153   10017 goto do_num8;
2149   } 2154   }
2150   2155  
HITCBC 2151   6947 goto finish_dub; 2156   6947 goto finish_dub;
2152   } 2157   }
2153   } 2158   }
2154   else 2159   else
2155   { 2160   {
HITCBC 2156   8425997 num = num_; 2161   8426019 num = num_;
2157   state st; 2162   state st;
HITCBC 2158   8425997 st_.pop(st); 2163   8426019 st_.pop(st);
HITCBC 2159   8425997 switch(st) 2164   8426019 switch(st)
2160   { 2165   {
2161   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE 2166   default: BOOST_JSON_UNREACHABLE(); // LCOV_EXCL_LINE
HITCBC 2162   602 case state::num1: goto do_num1; 2167   603 case state::num1: goto do_num1;
HITCBC 2163   6460 case state::num2: goto do_num2; 2168   6460 case state::num2: goto do_num2;
HITCBC 2164   4195112 case state::num3: goto do_num3; 2169   4195112 case state::num3: goto do_num3;
HITCBC 2165   52 case state::num4: goto do_num4; 2170   52 case state::num4: goto do_num4;
HITCBC 2166   4537 case state::num5: goto do_num5; 2171   4537 case state::num5: goto do_num5;
HITCBC 2167   666 case state::num6: goto do_num6; 2172   668 case state::num6: goto do_num6;
HITCBC 2168   618 case state::num7: goto do_num7; 2173   618 case state::num7: goto do_num7;
HITCBC 2169   4205248 case state::num8: goto do_num8; 2174   4205248 case state::num8: goto do_num8;
HITCBC 2170   475 case state::exp1: goto do_exp1; 2175   477 case state::exp1: goto do_exp1;
HITCBC 2171   139 case state::exp2: goto do_exp2; 2176   139 case state::exp2: goto do_exp2;
HITCBC 2172   12088 case state::exp3: goto do_exp3; 2177   12105 case state::exp3: goto do_exp3;
2173   } 2178   }
2174   } 2179   }
2175   2180  
2176   //---------------------------------- 2181   //----------------------------------
2177   // 2182   //
2178   // DIGIT 2183   // DIGIT
2179   // first digit 2184   // first digit
2180   // 2185   //
HITCBC 2181   62054 do_num1: 2186   62068 do_num1:
HITCBC 2182   15791 if(zero_first || nonzero_first || 2187   15799 if(zero_first || nonzero_first ||
HITCBC 2183   15791 BOOST_JSON_LIKELY(cs)) 2188   15799 BOOST_JSON_LIKELY(cs))
2184   { 2189   {
HITCBC 2185   61332 char const c = *cs; 2190   61345 char const c = *cs;
2186   if(zero_first) 2191   if(zero_first)
2187   { 2192   {
HITCBC 2188   9720 ++cs; 2193   9726 ++cs;
HITCBC 2189   9720 num.mant = 0; 2194   9726 num.mant = 0;
HITCBC 2190   9720 goto do_num6; 2195   9726 goto do_num6;
2191   } 2196   }
HITCBC 2192   15069 else if(nonzero_first || BOOST_JSON_LIKELY( 2197   15076 else if(nonzero_first || BOOST_JSON_LIKELY(
2193   c >= '1' && c <= '9')) 2198   c >= '1' && c <= '9'))
2194   { 2199   {
HITCBC 2195   42790 ++cs; 2200   42790 ++cs;
HITCBC 2196   42790 num.mant = c - '0'; 2201   42790 num.mant = c - '0';
2197   } 2202   }
HITCBC 2198   8822 else if(BOOST_JSON_UNLIKELY( 2203   8829 else if(BOOST_JSON_UNLIKELY(
2199   c == '0')) 2204   c == '0'))
2200   { 2205   {
HITCBC 2201   7627 ++cs; 2206   7634 ++cs;
HITCBC 2202   7627 num.mant = 0; 2207   7634 num.mant = 0;
HITCBC 2203   7627 goto do_num6; 2208   7634 goto do_num6;
2204   } 2209   }
HITCBC 2205   1195 else if( (negative || num.neg) && opt_.allow_infinity_and_nan ) 2210   1195 else if( (negative || num.neg) && opt_.allow_infinity_and_nan )
2206   { 2211   {
HITCBC 2207   1007 st_.push(state::lit1); 2212   1007 st_.push(state::lit1);
HITCBC 2208   1007 cur_lit_ = literal_index(detail::literals::neg_infinity); 2213   1007 cur_lit_ = literal_index(detail::literals::neg_infinity);
HITCBC 2209   1007 lit_offset_ = 1; 2214   1007 lit_offset_ = 1;
HITCBC 2210   1007 return parse_literal( 2215   1007 return parse_literal(
HITCBC 2211   961 cs.begin(), detail::literals_c<detail::literals::resume>() ); 2216   961 cs.begin(), detail::literals_c<detail::literals::resume>() );
2212   } 2217   }
2213   else 2218   else
2214   { 2219   {
2215   BOOST_STATIC_CONSTEXPR source_location loc 2220   BOOST_STATIC_CONSTEXPR source_location loc
2216   = BOOST_CURRENT_LOCATION; 2221   = BOOST_CURRENT_LOCATION;
HITCBC 2217   188 return fail(cs.begin(), error::syntax, &loc); 2222   188 return fail(cs.begin(), error::syntax, &loc);
2218   } 2223   }
2219   } 2224   }
2220   else 2225   else
2221   { 2226   {
HITCBC 2222   722 if(BOOST_JSON_UNLIKELY( 2227   723 if(BOOST_JSON_UNLIKELY(
2223   ! h_.on_number_part( 2228   ! h_.on_number_part(
2224   {begin, cs.used(begin)}, ec_))) 2229   {begin, cs.used(begin)}, ec_)))
HITCBC 2225   60 return fail(cs.begin()); 2230   60 return fail(cs.begin());
2226   2231  
2227   BOOST_IF_CONSTEXPR( precise_parsing ) 2232   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2228   ✗ num_buf_.append( begin, cs.used(begin) ); 2233   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2229   602 return maybe_suspend( 2234   603 return maybe_suspend(
HITCBC 2230   602 cs.begin(), state::num1, num); 2235   603 cs.begin(), state::num1, num);
2231   } 2236   }
2232   2237  
2233   //---------------------------------- 2238   //----------------------------------
2234   // 2239   //
2235   // 1*DIGIT 2240   // 1*DIGIT
2236   // significant digits left of decimal 2241   // significant digits left of decimal
2237   // 2242   //
HITCBC 2238   2050675 do_num2: 2243   2050675 do_num2:
HITCBC 2239   2044417 if(negative || (!stack_empty && num.neg)) 2244   2044417 if(negative || (!stack_empty && num.neg))
2240   { 2245   {
HITCBC 2241   22400 for(;;) 2246   22400 for(;;)
2242   { 2247   {
HITCBC 2243   30225 if(BOOST_JSON_UNLIKELY(! cs)) 2248   30225 if(BOOST_JSON_UNLIKELY(! cs))
2244   { 2249   {
HITCBC 2245   1921 if(BOOST_JSON_UNLIKELY(more_)) 2250   1921 if(BOOST_JSON_UNLIKELY(more_))
2246   { 2251   {
HITCBC 2247   1469 if(BOOST_JSON_UNLIKELY( 2252   1469 if(BOOST_JSON_UNLIKELY(
2248   ! h_.on_number_part( 2253   ! h_.on_number_part(
2249   {begin, cs.used(begin)}, ec_))) 2254   {begin, cs.used(begin)}, ec_)))
HITCBC 2250   69 return fail(cs.begin()); 2255   69 return fail(cs.begin());
2251   2256  
2252   BOOST_IF_CONSTEXPR( precise_parsing ) 2257   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2253   ✗ num_buf_.append( begin, cs.used(begin) ); 2258   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2254   1331 return suspend(cs.begin(), state::num2, num); 2259   1331 return suspend(cs.begin(), state::num2, num);
2255   } 2260   }
HITCBC 2256   452 goto finish_int; 2261   452 goto finish_int;
2257   } 2262   }
HITCBC 2258   28304 char const c = *cs; 2263   28304 char const c = *cs;
HITCBC 2259   28304 if(BOOST_JSON_LIKELY( 2264   28304 if(BOOST_JSON_LIKELY(
2260   c >= '0' && c <= '9')) 2265   c >= '0' && c <= '9'))
2261   { 2266   {
HITCBC 2262   23223 ++cs; 2267   23223 ++cs;
2263   // 9223372036854775808 INT64_MIN 2268   // 9223372036854775808 INT64_MIN
HITCBC 2264   23223 if( num.mant > 922337203685477580 || ( 2269   23223 if( num.mant > 922337203685477580 || (
HITCBC 2265   22508 num.mant == 922337203685477580 && c > '8')) 2270   22508 num.mant == 922337203685477580 && c > '8'))
2266   break; 2271   break;
2267   BOOST_IF_CONSTEXPR( !no_parsing ) 2272   BOOST_IF_CONSTEXPR( !no_parsing )
HITCBC 2268   22141 num.mant = 10 * num.mant + ( c - '0' ); 2273   22141 num.mant = 10 * num.mant + ( c - '0' );
HITCBC 2269   22400 continue; 2274   22400 continue;
2270   } 2275   }
HITCBC 2271   5081 goto do_num6; // [.eE] 2276   5081 goto do_num6; // [.eE]
2272   } 2277   }
2273   } 2278   }
2274   else 2279   else
2275   { 2280   {
HITCBC 2276   6889563 for(;;) 2281   6889563 for(;;)
2277   { 2282   {
HITCBC 2278   8932413 if(BOOST_JSON_UNLIKELY(! cs)) 2283   8932413 if(BOOST_JSON_UNLIKELY(! cs))
2279   { 2284   {
HITCBC 2280   6588 if(BOOST_JSON_UNLIKELY(more_)) 2285   6588 if(BOOST_JSON_UNLIKELY(more_))
2281   { 2286   {
HITCBC 2282   5975 if(BOOST_JSON_UNLIKELY( 2287   5975 if(BOOST_JSON_UNLIKELY(
2283   ! h_.on_number_part( 2288   ! h_.on_number_part(
2284   {begin, cs.used(begin)}, ec_))) 2289   {begin, cs.used(begin)}, ec_)))
HITCBC 2285   426 return fail(cs.begin()); 2290   426 return fail(cs.begin());
2286   2291  
2287   BOOST_IF_CONSTEXPR( precise_parsing ) 2292   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2288   ✗ num_buf_.append( begin, cs.used(begin) ); 2293   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2289   5129 return suspend(cs.begin(), state::num2, num); 2294   5129 return suspend(cs.begin(), state::num2, num);
2290   } 2295   }
HITCBC 2291   613 goto finish_int; 2296   613 goto finish_int;
2292   } 2297   }
HITCBC 2293   8925825 char const c = *cs; 2298   8925825 char const c = *cs;
HITCBC 2294   8925825 if(BOOST_JSON_LIKELY( 2299   8925825 if(BOOST_JSON_LIKELY(
2295   c >= '0' && c <= '9')) 2300   c >= '0' && c <= '9'))
2296   { 2301   {
HITCBC 2297   6893607 ++cs; 2302   6893607 ++cs;
2298   // 18446744073709551615 UINT64_MAX 2303   // 18446744073709551615 UINT64_MAX
HITCBC 2299   6893607 if( num.mant > 1844674407370955161 || ( 2304   6893607 if( num.mant > 1844674407370955161 || (
HITCBC 2300   6889985 num.mant == 1844674407370955161 && c > '5')) 2305   6889985 num.mant == 1844674407370955161 && c > '5'))
2301   break; 2306   break;
2302   BOOST_IF_CONSTEXPR( !no_parsing ) 2307   BOOST_IF_CONSTEXPR( !no_parsing )
HITCBC 2303   6883965 num.mant = 10 * num.mant + ( c - '0' ); 2308   6883965 num.mant = 10 * num.mant + ( c - '0' );
2304   } 2309   }
2305   else 2310   else
2306   { 2311   {
HITCBC 2307   2032218 goto do_num6; // [.eE] 2312   2032218 goto do_num6; // [.eE]
2308   } 2313   }
2309   } 2314   }
2310   } 2315   }
HITCBC 2311   4867 ++num.bias; 2316   4867 ++num.bias;
2312   2317  
2313   //---------------------------------- 2318   //----------------------------------
2314   // 2319   //
2315   // 1*DIGIT 2320   // 1*DIGIT
2316   // non-significant digits left of decimal 2321   // non-significant digits left of decimal
2317   // 2322   //
HITCBC 2318   4199979 do_num3: 2323   4199979 do_num3:
HITCBC 2319   4294978560 for(;;) 2324   4294978560 for(;;)
2320   { 2325   {
HITCBC 2321   4299178539 if(BOOST_JSON_UNLIKELY(! cs)) 2326   4299178539 if(BOOST_JSON_UNLIKELY(! cs))
2322   { 2327   {
HITCBC 2323   4195839 if(BOOST_JSON_UNLIKELY(more_)) 2328   4195839 if(BOOST_JSON_UNLIKELY(more_))
2324   { 2329   {
HITCBC 2325   4195206 if(BOOST_JSON_UNLIKELY( 2330   4195206 if(BOOST_JSON_UNLIKELY(
2326   ! h_.on_number_part( 2331   ! h_.on_number_part(
2327   {begin, cs.used(begin)}, ec_))) 2332   {begin, cs.used(begin)}, ec_)))
HITCBC 2328   47 return fail(cs.begin()); 2333   47 return fail(cs.begin());
2329   2334  
2330   BOOST_IF_CONSTEXPR( precise_parsing ) 2335   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2331   ✗ num_buf_.append( begin, cs.used(begin) ); 2336   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2332   4195112 return suspend(cs.begin(), state::num3, num); 2337   4195112 return suspend(cs.begin(), state::num3, num);
2333   } 2338   }
HITCBC 2334   633 goto finish_dub; 2339   633 goto finish_dub;
2335   } 2340   }
HITCBC 2336   4294982700 char const c = *cs; 2341   4294982700 char const c = *cs;
HITCBC 2337   4294982700 if(BOOST_JSON_UNLIKELY( 2342   4294982700 if(BOOST_JSON_UNLIKELY(
2338   c >= '0' && c <= '9')) 2343   c >= '0' && c <= '9'))
2339   { 2344   {
HITCBC 2340   4294978561 if(BOOST_JSON_UNLIKELY( num.bias + 1 == INT_MAX )) 2345   4294978561 if(BOOST_JSON_UNLIKELY( num.bias + 1 == INT_MAX ))
2341   { 2346   {
2342   BOOST_STATIC_CONSTEXPR source_location loc 2347   BOOST_STATIC_CONSTEXPR source_location loc
2343   = BOOST_CURRENT_LOCATION; 2348   = BOOST_CURRENT_LOCATION;
HITCBC 2344   1 return fail(cs.begin(), error::exponent_overflow, &loc); 2349   1 return fail(cs.begin(), error::exponent_overflow, &loc);
2345   } 2350   }
HITCBC 2346   4294978560 ++cs; 2351   4294978560 ++cs;
HITCBC 2347   4294978560 ++num.bias; 2352   4294978560 ++num.bias;
2348   } 2353   }
HITCBC 2349   4139 else if(BOOST_JSON_LIKELY( 2354   4139 else if(BOOST_JSON_LIKELY(
2350   c == '.')) 2355   c == '.'))
2351   { 2356   {
HITCBC 2352   2028 ++cs; 2357   2028 ++cs;
HITCBC 2353   2028 break; 2358   2028 break;
2354   } 2359   }
HITCBC 2355   2111 else if((c | 32) == 'e') 2360   2111 else if((c | 32) == 'e')
2356   { 2361   {
HITCBC 2357   762 ++cs; 2362   762 ++cs;
HITCBC 2358   762 goto do_exp1; 2363   762 goto do_exp1;
2359   } 2364   }
2360   else 2365   else
2361   { 2366   {
HITCBC 2362   1349 goto finish_dub; 2367   1349 goto finish_dub;
2363   } 2368   }
2364   } 2369   }
2365   2370  
2366   //---------------------------------- 2371   //----------------------------------
2367   // 2372   //
2368   // DIGIT 2373   // DIGIT
2369   // first non-significant digit 2374   // first non-significant digit
2370   // to the right of decimal 2375   // to the right of decimal
2371   // 2376   //
HITCBC 2372   2080 do_num4: 2377   2080 do_num4:
2373   { 2378   {
HITCBC 2374   2080 if(BOOST_JSON_UNLIKELY(! cs)) 2379   2080 if(BOOST_JSON_UNLIKELY(! cs))
2375   { 2380   {
HITCBC 2376   64 if(BOOST_JSON_UNLIKELY( 2381   64 if(BOOST_JSON_UNLIKELY(
2377   ! h_.on_number_part( 2382   ! h_.on_number_part(
2378   {begin, cs.used(begin)}, ec_))) 2383   {begin, cs.used(begin)}, ec_)))
HITCBC 2379   6 return fail(cs.begin()); 2384   6 return fail(cs.begin());
2380   2385  
2381   BOOST_IF_CONSTEXPR( precise_parsing ) 2386   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2382   ✗ num_buf_.append( begin, cs.used(begin) ); 2387   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2383   52 return maybe_suspend( 2388   52 return maybe_suspend(
HITCBC 2384   52 cs.begin(), state::num4, num); 2389   52 cs.begin(), state::num4, num);
2385   } 2390   }
HITCBC 2386   2016 char const c = *cs; 2391   2016 char const c = *cs;
HITCBC 2387   2016 if(BOOST_JSON_LIKELY( 2392   2016 if(BOOST_JSON_LIKELY(
2388   //static_cast<unsigned char>(c - '0') < 10)) 2393   //static_cast<unsigned char>(c - '0') < 10))
2389   c >= '0' && c <= '9')) 2394   c >= '0' && c <= '9'))
2390   { 2395   {
HITCBC 2391   1949 ++cs; 2396   1949 ++cs;
2392   } 2397   }
2393   else 2398   else
2394   { 2399   {
2395   // digit required 2400   // digit required
2396   BOOST_STATIC_CONSTEXPR source_location loc 2401   BOOST_STATIC_CONSTEXPR source_location loc
2397   = BOOST_CURRENT_LOCATION; 2402   = BOOST_CURRENT_LOCATION;
HITCBC 2398   67 return fail(cs.begin(), error::syntax, &loc); 2403   67 return fail(cs.begin(), error::syntax, &loc);
2399   } 2404   }
2400   } 2405   }
2401   2406  
2402   //---------------------------------- 2407   //----------------------------------
2403   // 2408   //
2404   // 1*DIGIT 2409   // 1*DIGIT
2405   // non-significant digits 2410   // non-significant digits
2406   // to the right of decimal 2411   // to the right of decimal
2407   // 2412   //
HITCBC 2408   2013470 do_num5: 2413   2013470 do_num5:
HITCBC 2409   37889832 for(;;) 2414   37889832 for(;;)
2410   { 2415   {
HITCBC 2411   39903302 if(BOOST_JSON_UNLIKELY(! cs)) 2416   39903302 if(BOOST_JSON_UNLIKELY(! cs))
2412   { 2417   {
HITCBC 2413   6112 if(BOOST_JSON_UNLIKELY(more_)) 2418   6112 if(BOOST_JSON_UNLIKELY(more_))
2414   { 2419   {
HITCBC 2415   4577 if(BOOST_JSON_UNLIKELY( 2420   4577 if(BOOST_JSON_UNLIKELY(
2416   ! h_.on_number_part( 2421   ! h_.on_number_part(
2417   {begin, cs.used(begin)}, ec_))) 2422   {begin, cs.used(begin)}, ec_)))
HITCBC 2418   20 return fail(cs.begin()); 2423   20 return fail(cs.begin());
2419   2424  
2420   BOOST_IF_CONSTEXPR( precise_parsing ) 2425   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2421   ✗ num_buf_.append( begin, cs.used(begin) ); 2426   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2422   4537 return suspend(cs.begin(), state::num5, num); 2427   4537 return suspend(cs.begin(), state::num5, num);
2423   } 2428   }
HITCBC 2424   1535 goto finish_dub; 2429   1535 goto finish_dub;
2425   } 2430   }
HITCBC 2426   39897190 char const c = *cs; 2431   39897190 char const c = *cs;
HITCBC 2427   39897190 if(BOOST_JSON_LIKELY( 2432   39897190 if(BOOST_JSON_LIKELY(
2428   c >= '0' && c <= '9')) 2433   c >= '0' && c <= '9'))
2429   { 2434   {
HITCBC 2430   37889832 ++cs; 2435   37889832 ++cs;
2431   } 2436   }
HITCBC 2432   2007358 else if((c | 32) == 'e') 2437   2007358 else if((c | 32) == 'e')
2433   { 2438   {
HITCBC 2434   2003236 ++cs; 2439   2003236 ++cs;
HITCBC 2435   2003236 goto do_exp1; 2440   2003236 goto do_exp1;
2436   } 2441   }
2437   else 2442   else
2438   { 2443   {
HITCBC 2439   4122 goto finish_dub; 2444   4122 goto finish_dub;
2440   } 2445   }
2441   } 2446   }
2442   2447  
2443   //---------------------------------- 2448   //----------------------------------
2444   // 2449   //
2445   // [.eE] 2450   // [.eE]
2446   // 2451   //
HITCBC 2447   2055312 do_num6: 2452   2055327 do_num6:
2448   { 2453   {
HITCBC 2449   2055312 if(BOOST_JSON_UNLIKELY(! cs)) 2454   2055327 if(BOOST_JSON_UNLIKELY(! cs))
2450   { 2455   {
HITCBC 2451   798 if(BOOST_JSON_UNLIKELY(more_)) 2456   800 if(BOOST_JSON_UNLIKELY(more_))
2452   { 2457   {
HITCBC 2453   751 if(BOOST_JSON_UNLIKELY( 2458   753 if(BOOST_JSON_UNLIKELY(
2454   ! h_.on_number_part( 2459   ! h_.on_number_part(
2455   {begin, cs.used(begin)}, ec_))) 2460   {begin, cs.used(begin)}, ec_)))
HITCBC 2456   42 return fail(cs.begin()); 2461   42 return fail(cs.begin());
2457   2462  
2458   BOOST_IF_CONSTEXPR( precise_parsing ) 2463   BOOST_IF_CONSTEXPR( precise_parsing )
HITCBC 2459   2 num_buf_.append( begin, cs.used(begin) ); 2464   2 num_buf_.append( begin, cs.used(begin) );
HITCBC 2460   667 return suspend(cs.begin(), state::num6, num); 2465   669 return suspend(cs.begin(), state::num6, num);
2461   } 2466   }
HITCBC 2462   47 goto finish_int; 2467   47 goto finish_int;
2463   } 2468   }
HITCBC 2464   2054514 char const c = *cs; 2469   2054527 char const c = *cs;
HITCBC 2465   2054514 if(BOOST_JSON_LIKELY( 2470   2054527 if(BOOST_JSON_LIKELY(
2466   c == '.')) 2471   c == '.'))
2467   { 2472   {
HITCBC 2468   2016099 ++cs; 2473   2016099 ++cs;
2469   } 2474   }
HITCBC 2470   38415 else if((c | 32) == 'e') 2475   38428 else if((c | 32) == 'e')
2471   { 2476   {
HITCBC 2472   9140 ++cs; 2477   9153 ++cs;
HITCBC 2473   9140 goto do_exp1; 2478   9153 goto do_exp1;
2474   } 2479   }
2475   else 2480   else
2476   { 2481   {
HITCBC 2477   29275 goto finish_int; 2482   29275 goto finish_int;
2478   } 2483   }
2479   } 2484   }
2480   2485  
2481   //---------------------------------- 2486   //----------------------------------
2482   // 2487   //
2483   // DIGIT 2488   // DIGIT
2484   // first significant digit 2489   // first significant digit
2485   // to the right of decimal 2490   // to the right of decimal
2486   // 2491   //
HITCBC 2487   2016839 do_num7: 2492   2016839 do_num7:
2488   { 2493   {
HITCBC 2489   2016839 if(BOOST_JSON_UNLIKELY(! cs)) 2494   2016839 if(BOOST_JSON_UNLIKELY(! cs))
2490   { 2495   {
HITCBC 2491   693 if(BOOST_JSON_UNLIKELY(more_)) 2496   693 if(BOOST_JSON_UNLIKELY(more_))
2492   { 2497   {
HITCBC 2493   689 if(BOOST_JSON_UNLIKELY( 2498   689 if(BOOST_JSON_UNLIKELY(
2494   ! h_.on_number_part( 2499   ! h_.on_number_part(
2495   {begin, cs.used(begin)}, ec_))) 2500   {begin, cs.used(begin)}, ec_)))
HITCBC 2496   35 return fail(cs.begin()); 2501   35 return fail(cs.begin());
2497   2502  
2498   BOOST_IF_CONSTEXPR( precise_parsing ) 2503   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2499   ✗ num_buf_.append( begin, cs.used(begin) ); 2504   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2500   619 return suspend(cs.begin(), state::num7, num); 2505   619 return suspend(cs.begin(), state::num7, num);
2501   } 2506   }
2502   // digit required 2507   // digit required
2503   BOOST_STATIC_CONSTEXPR source_location loc 2508   BOOST_STATIC_CONSTEXPR source_location loc
2504   = BOOST_CURRENT_LOCATION; 2509   = BOOST_CURRENT_LOCATION;
HITCBC 2505   4 return fail(cs.begin(), error::syntax, &loc); 2510   4 return fail(cs.begin(), error::syntax, &loc);
2506   } 2511   }
HITCBC 2507   2016146 char const c = *cs; 2512   2016146 char const c = *cs;
HITCBC 2508   2016146 if(BOOST_JSON_UNLIKELY( 2513   2016146 if(BOOST_JSON_UNLIKELY(
2509   c < '0' || c > '9')) 2514   c < '0' || c > '9'))
2510   { 2515   {
2511   // digit required 2516   // digit required
2512   BOOST_STATIC_CONSTEXPR source_location loc 2517   BOOST_STATIC_CONSTEXPR source_location loc
2513   = BOOST_CURRENT_LOCATION; 2518   = BOOST_CURRENT_LOCATION;
HITCBC 2514   169 return fail(cs.begin(), error::syntax, &loc); 2519   169 return fail(cs.begin(), error::syntax, &loc);
2515   } 2520   }
2516   } 2521   }
2517   2522  
2518   //---------------------------------- 2523   //----------------------------------
2519   // 2524   //
2520   // 1*DIGIT 2525   // 1*DIGIT
2521   // significant digits 2526   // significant digits
2522   // to the right of decimal 2527   // to the right of decimal
2523   // 2528   //
HITCBC 2524   6228742 do_num8: 2529   6228742 do_num8:
HITCBC 2525   4298245220 for(;;) 2530   4298245220 for(;;)
2526   { 2531   {
HITCBC 2527   4304476462 if(BOOST_JSON_UNLIKELY(! cs)) 2532   4304476462 if(BOOST_JSON_UNLIKELY(! cs))
2528   { 2533   {
HITCBC 2529   4207120 if(BOOST_JSON_UNLIKELY(more_)) 2534   4207120 if(BOOST_JSON_UNLIKELY(more_))
2530   { 2535   {
HITCBC 2531   4205384 if(BOOST_JSON_UNLIKELY( 2536   4205384 if(BOOST_JSON_UNLIKELY(
2532   ! h_.on_number_part( 2537   ! h_.on_number_part(
2533   {begin, cs.used(begin)}, ec_))) 2538   {begin, cs.used(begin)}, ec_)))
HITCBC 2534   67 return fail(cs.begin()); 2539   67 return fail(cs.begin());
2535   2540  
2536   BOOST_IF_CONSTEXPR( precise_parsing ) 2541   BOOST_IF_CONSTEXPR( precise_parsing )
HITCBC 2537   2 num_buf_.append( begin, cs.used(begin) ); 2542   2 num_buf_.append( begin, cs.used(begin) );
HITCBC 2538   4205249 return suspend(cs.begin(), state::num8, num); 2543   4205249 return suspend(cs.begin(), state::num8, num);
2539   } 2544   }
HITCBC 2540   1736 goto finish_dub; 2545   1736 goto finish_dub;
2541   } 2546   }
HITCBC 2542   4300269342 char const c = *cs; 2547   4300269342 char const c = *cs;
HITCBC 2543   4300269342 if(BOOST_JSON_LIKELY( 2548   4300269342 if(BOOST_JSON_LIKELY(
2544   c >= '0' && c <= '9')) 2549   c >= '0' && c <= '9'))
2545   { 2550   {
HITCBC 2546   4300252205 ++cs; 2551   4300252205 ++cs;
HITCBC 2547   4300247112 if(!no_parsing && BOOST_JSON_LIKELY( 2552   4300247112 if(!no_parsing && BOOST_JSON_LIKELY(
2548   num.mant <= 9007199254740991)) // 2^53-1 2553   num.mant <= 9007199254740991)) // 2^53-1
2549   { 2554   {
HITCBC 2550   4298245221 if(BOOST_JSON_UNLIKELY( num.bias - 1 == INT_MIN )) 2555   4298245221 if(BOOST_JSON_UNLIKELY( num.bias - 1 == INT_MIN ))
2551   { 2556   {
2552   BOOST_STATIC_CONSTEXPR source_location loc 2557   BOOST_STATIC_CONSTEXPR source_location loc
2553   = BOOST_CURRENT_LOCATION; 2558   = BOOST_CURRENT_LOCATION;
HITCBC 2554   1 return fail(cs.begin(), error::exponent_overflow, &loc); 2559   1 return fail(cs.begin(), error::exponent_overflow, &loc);
2555   } 2560   }
HITCBC 2556   4298245220 --num.bias; 2561   4298245220 --num.bias;
HITCBC 2557   4298245220 num.mant = 10 * num.mant + ( c - '0' ); 2562   4298245220 num.mant = 10 * num.mant + ( c - '0' );
2558   } 2563   }
2559   else 2564   else
2560   { 2565   {
HITCBC 2561   2006984 goto do_num5; 2566   2006984 goto do_num5;
2562   } 2567   }
2563   } 2568   }
HITCBC 2564   17137 else if((c | 32) == 'e') 2569   17137 else if((c | 32) == 'e')
2565   { 2570   {
HITCBC 2566   11134 ++cs; 2571   11134 ++cs;
HITCBC 2567   11134 goto do_exp1; 2572   11134 goto do_exp1;
2568   } 2573   }
2569   else 2574   else
2570   { 2575   {
HITCBC 2571   6003 goto finish_dub; 2576   6003 goto finish_dub;
2572   } 2577   }
2573   } 2578   }
2574   2579  
2575   //---------------------------------- 2580   //----------------------------------
2576   // 2581   //
2577   // *[+-] 2582   // *[+-]
2578   // 2583   //
HITCBC 2579   2031433 do_exp1: 2584   2031448 do_exp1:
HITCBC 2580   2031433 if(BOOST_JSON_UNLIKELY(! cs)) 2585   2031448 if(BOOST_JSON_UNLIKELY(! cs))
2581   { 2586   {
HITCBC 2582   573 if(BOOST_JSON_UNLIKELY( 2587   575 if(BOOST_JSON_UNLIKELY(
2583   ! h_.on_number_part( 2588   ! h_.on_number_part(
2584   {begin, cs.used(begin)}, ec_))) 2589   {begin, cs.used(begin)}, ec_)))
HITCBC 2585   49 return fail(cs.begin()); 2590   49 return fail(cs.begin());
2586   2591  
2587   BOOST_IF_CONSTEXPR( precise_parsing ) 2592   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2588   ✗ num_buf_.append( begin, cs.used(begin) ); 2593   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2589   475 return maybe_suspend( 2594   477 return maybe_suspend(
HITCBC 2590   475 cs.begin(), state::exp1, num); 2595   477 cs.begin(), state::exp1, num);
2591   } 2596   }
HITCBC 2592   2030860 if(*cs == '+') 2597   2030873 if(*cs == '+')
2593   { 2598   {
HITCBC 2594   2364 ++cs; 2599   2364 ++cs;
2595   } 2600   }
HITCBC 2596   2028496 else if(*cs == '-') 2601   2028509 else if(*cs == '-')
2597   { 2602   {
HITCBC 2598   1001936 ++cs; 2603   1001936 ++cs;
HITCBC 2599   1001936 num.frac = true; 2604   1001936 num.frac = true;
2600   } 2605   }
2601   2606  
2602   //---------------------------------- 2607   //----------------------------------
2603   // 2608   //
2604   // DIGIT 2609   // DIGIT
2605   // first digit of the exponent 2610   // first digit of the exponent
2606   // 2611   //
HITCBC 2607   1026560 do_exp2: 2612   1026573 do_exp2:
2608   { 2613   {
HITCBC 2609   2030999 if(BOOST_JSON_UNLIKELY(! cs)) 2614   2031012 if(BOOST_JSON_UNLIKELY(! cs))
2610   { 2615   {
HITCBC 2611   188 if(BOOST_JSON_UNLIKELY(more_)) 2616   188 if(BOOST_JSON_UNLIKELY(more_))
2612   { 2617   {
HITCBC 2613   179 if(BOOST_JSON_UNLIKELY( 2618   179 if(BOOST_JSON_UNLIKELY(
2614   ! h_.on_number_part( 2619   ! h_.on_number_part(
2615   {begin, cs.used(begin)}, ec_))) 2620   {begin, cs.used(begin)}, ec_)))
HITCBC 2616   20 return fail(cs.begin()); 2621   20 return fail(cs.begin());
2617   2622  
2618   BOOST_IF_CONSTEXPR( precise_parsing ) 2623   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2619   ✗ num_buf_.append( begin, cs.used(begin) ); 2624   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2620   139 return suspend(cs.begin(), state::exp2, num); 2625   139 return suspend(cs.begin(), state::exp2, num);
2621   } 2626   }
2622   // digit required 2627   // digit required
2623   BOOST_STATIC_CONSTEXPR source_location loc 2628   BOOST_STATIC_CONSTEXPR source_location loc
2624   = BOOST_CURRENT_LOCATION; 2629   = BOOST_CURRENT_LOCATION;
HITCBC 2625   9 return fail(cs.begin(), error::syntax, &loc); 2630   9 return fail(cs.begin(), error::syntax, &loc);
2626   } 2631   }
HITCBC 2627   2030811 char const c = *cs; 2632   2030824 char const c = *cs;
HITCBC 2628   2030811 if(BOOST_JSON_UNLIKELY( 2633   2030824 if(BOOST_JSON_UNLIKELY(
2629   c < '0' || c > '9')) 2634   c < '0' || c > '9'))
2630   { 2635   {
2631   // digit required 2636   // digit required
2632   BOOST_STATIC_CONSTEXPR source_location loc 2637   BOOST_STATIC_CONSTEXPR source_location loc
2633   = BOOST_CURRENT_LOCATION; 2638   = BOOST_CURRENT_LOCATION;
HITCBC 2634   508 return fail(cs.begin(), error::syntax, &loc); 2639   508 return fail(cs.begin(), error::syntax, &loc);
2635   } 2640   }
HITCBC 2636   2030303 ++cs; 2641   2030316 ++cs;
HITCBC 2637   2030303 num.exp = c - '0'; 2642   2030316 num.exp = c - '0';
2638   } 2643   }
2639   2644  
2640   //---------------------------------- 2645   //----------------------------------
2641   // 2646   //
2642   // 1*DIGIT 2647   // 1*DIGIT
2643   // subsequent digits in the exponent 2648   // subsequent digits in the exponent
2644   // 2649   //
HITCBC 2645   2042391 do_exp3: 2650   2042421 do_exp3:
HITCBC 2646   5468137 for(;;) 2651   5468163 for(;;)
2647   { 2652   {
HITCBC 2648   7510528 if(BOOST_JSON_UNLIKELY(! cs)) 2653   7510584 if(BOOST_JSON_UNLIKELY(! cs))
2649   { 2654   {
HITCBC 2650   2020808 if(BOOST_JSON_UNLIKELY(more_)) 2655   2020838 if(BOOST_JSON_UNLIKELY(more_))
2651   { 2656   {
HITCBC 2652   12260 if(BOOST_JSON_UNLIKELY( 2657   12277 if(BOOST_JSON_UNLIKELY(
2653   ! h_.on_number_part( 2658   ! h_.on_number_part(
2654   {begin, cs.used(begin)}, ec_))) 2659   {begin, cs.used(begin)}, ec_)))
HITCBC 2655   86 return fail(cs.begin()); 2660   86 return fail(cs.begin());
2656   2661  
2657   BOOST_IF_CONSTEXPR( precise_parsing ) 2662   BOOST_IF_CONSTEXPR( precise_parsing )
MISUBC 2658   ✗ num_buf_.append( begin, cs.used(begin) ); 2663   ✗ num_buf_.append( begin, cs.used(begin) );
HITCBC 2659   12088 return suspend(cs.begin(), state::exp3, num); 2664   12105 return suspend(cs.begin(), state::exp3, num);
2660   } 2665   }
2661   } 2666   }
2662   else 2667   else
2663   { 2668   {
HITCBC 2664   5489720 char const c = *cs; 2669   5489746 char const c = *cs;
HITCBC 2665   5489720 if(BOOST_JSON_LIKELY( c >= '0' && c <= '9' )) 2670   5489746 if(BOOST_JSON_LIKELY( c >= '0' && c <= '9' ))
2666   { 2671   {
HITCBC 2667   5468137 if(BOOST_JSON_UNLIKELY( 2672   5468163 if(BOOST_JSON_UNLIKELY(
2668   // 2147483647 INT_MAX 2673   // 2147483647 INT_MAX
2669   num.exp > 214748364 || 2674   num.exp > 214748364 ||
2670   (num.exp == 214748364 && c > '7') 2675   (num.exp == 214748364 && c > '7')
2671   )) 2676   ))
HITCBC 2672   3855 num.exp = INT_MAX; 2677   3855 num.exp = INT_MAX;
2673   else BOOST_IF_CONSTEXPR( !no_parsing ) 2678   else BOOST_IF_CONSTEXPR( !no_parsing )
HITCBC 2674   4923430 num.exp = 10 * num.exp + ( c - '0' ); 2679   4923456 num.exp = 10 * num.exp + ( c - '0' );
2675   2680  
HITCBC 2676   5468137 ++cs; 2681   5468163 ++cs;
HITCBC 2677   5468137 continue; 2682   5468163 continue;
2678   } 2683   }
2679   } 2684   }
HITCBC 2680   2030131 BOOST_ASSERT(num.exp >= 0); 2685   2030144 BOOST_ASSERT(num.exp >= 0);
HITCBC 2681   2030131 if ( num.frac ) 2686   2030144 if ( num.frac )
2682   { 2687   {
HITCBC 2683   1001800 if(BOOST_JSON_UNLIKELY( num.bias < (INT_MIN + num.exp) )) 2688   1001800 if(BOOST_JSON_UNLIKELY( num.bias < (INT_MIN + num.exp) ))
2684   { 2689   {
2685   // if exponent overflowed, bias is a very large negative 2690   // if exponent overflowed, bias is a very large negative
2686   // number, and mantissa isn't zero, then we cannot parse the 2691   // number, and mantissa isn't zero, then we cannot parse the
2687   // number correctly 2692   // number correctly
HITCBC 2688   92 if(BOOST_JSON_UNLIKELY( 2693   92 if(BOOST_JSON_UNLIKELY(
2689   (num.exp == INT_MAX) && 2694   (num.exp == INT_MAX) &&
2690   (num.bias < 0) && 2695   (num.bias < 0) &&
2691   (num.exp + num.bias < 308) && 2696   (num.exp + num.bias < 308) &&
2692   num.mant )) 2697   num.mant ))
2693   { 2698   {
2694   BOOST_STATIC_CONSTEXPR source_location loc 2699   BOOST_STATIC_CONSTEXPR source_location loc
2695   = BOOST_CURRENT_LOCATION; 2700   = BOOST_CURRENT_LOCATION;
HITCBC 2696   1 return fail(cs.begin(), error::exponent_overflow, &loc); 2701   1 return fail(cs.begin(), error::exponent_overflow, &loc);
2697   } 2702   }
2698   2703  
HITCBC 2699   91 num.bias = 0; 2704   91 num.bias = 0;
HITCBC 2700   91 num.exp = INT_MAX; 2705   91 num.exp = INT_MAX;
2701   } 2706   }
2702   } 2707   }
HITCBC 2703   1028331 else if (BOOST_JSON_UNLIKELY( num.bias > (INT_MAX - num.exp) )) 2708   1028344 else if (BOOST_JSON_UNLIKELY( num.bias > (INT_MAX - num.exp) ))
2704   { 2709   {
2705   // if exponent overflowed, bias is a very large positive number, 2710   // if exponent overflowed, bias is a very large positive number,
2706   // and mantissa isn't zero, then we cannot parse the 2711   // and mantissa isn't zero, then we cannot parse the
2707   // number correctly 2712   // number correctly
HITCBC 2708   194 if(BOOST_JSON_UNLIKELY( 2713   194 if(BOOST_JSON_UNLIKELY(
2709   (num.exp == INT_MAX) && 2714   (num.exp == INT_MAX) &&
2710   (num.bias > 0) && 2715   (num.bias > 0) &&
2711   (num.exp - num.bias < 308) && 2716   (num.exp - num.bias < 308) &&
2712   num.mant )) 2717   num.mant ))
2713   { 2718   {
2714   BOOST_STATIC_CONSTEXPR source_location loc 2719   BOOST_STATIC_CONSTEXPR source_location loc
2715   = BOOST_CURRENT_LOCATION; 2720   = BOOST_CURRENT_LOCATION;
HITCBC 2716   1 return fail(cs.begin(), error::exponent_overflow, &loc); 2721   1 return fail(cs.begin(), error::exponent_overflow, &loc);
2717   } 2722   }
2718   2723  
HITCBC 2719   193 num.bias = 0; 2724   193 num.bias = 0;
HITCBC 2720   193 num.exp = INT_MAX; 2725   193 num.exp = INT_MAX;
2721   } 2726   }
HITCBC 2722   2030129 goto finish_dub; 2727   2030142 goto finish_dub;
2723   } 2728   }
2724   2729  
HITCBC 2725   30387 finish_int: 2730   30387 finish_int:
HITCBC 2726   28458 if(negative || (!stack_empty && num.neg)) 2731   28458 if(negative || (!stack_empty && num.neg))
2727   { 2732   {
HITCBC 2728   2531 if(BOOST_JSON_UNLIKELY( 2733   2531 if(BOOST_JSON_UNLIKELY(
2729   ! h_.on_int64(static_cast< 2734   ! h_.on_int64(static_cast<
2730   int64_t>(~num.mant + 1), {begin, cs.used(begin)}, ec_))) 2735   int64_t>(~num.mant + 1), {begin, cs.used(begin)}, ec_)))
HITCBC 2731   310 return fail(cs.begin()); 2736   310 return fail(cs.begin());
HITCBC 2732   1913 return cs.begin(); 2737   1913 return cs.begin();
2733   } 2738   }
HITCBC 2734   27856 if(num.mant <= INT64_MAX) 2739   27856 if(num.mant <= INT64_MAX)
2735   { 2740   {
HITCBC 2736   27555 finish_signed: 2741   27555 finish_signed:
HITCBC 2737   30830 if(BOOST_JSON_UNLIKELY( 2742   30830 if(BOOST_JSON_UNLIKELY(
2738   ! h_.on_int64(static_cast< 2743   ! h_.on_int64(static_cast<
2739   int64_t>(num.mant), {begin, cs.used(begin)}, ec_))) 2744   int64_t>(num.mant), {begin, cs.used(begin)}, ec_)))
HITCBC 2740   2267 return fail(cs.begin()); 2745   2267 return fail(cs.begin());
HITCBC 2741   26303 return cs.begin(); 2746   26303 return cs.begin();
2742   } 2747   }
HITCBC 2743   321 if(BOOST_JSON_UNLIKELY( 2748   321 if(BOOST_JSON_UNLIKELY(
2744   ! h_.on_uint64(num.mant, {begin, cs.used(begin)}, ec_))) 2749   ! h_.on_uint64(num.mant, {begin, cs.used(begin)}, ec_)))
HITCBC 2745   35 return fail(cs.begin()); 2750   35 return fail(cs.begin());
HITCBC 2746   254 return cs.begin(); 2751   254 return cs.begin();
HITCBC 2747   2052454 finish_dub: 2752   2052467 finish_dub:
2748   double d; 2753   double d;
HITCBC 2749   2052454 std::size_t const size = cs.used(begin); 2754   2052467 std::size_t const size = cs.used(begin);
HITCBC 2750   2052454 BOOST_ASSERT( !num_buf_.size() || precise_parsing ); 2755   2052467 BOOST_ASSERT( !num_buf_.size() || precise_parsing );
2751   BOOST_IF_CONSTEXPR( precise_parsing ) 2756   BOOST_IF_CONSTEXPR( precise_parsing )
2752   { 2757   {
HITCBC 2753   1000052 char const* data = begin; 2758   1000052 char const* data = begin;
HITCBC 2754   1000052 std::size_t full_size = size; 2759   1000052 std::size_t full_size = size;
2755   // if we previously suspended or if the current input ends with the 2760   // if we previously suspended or if the current input ends with the
2756   // number, we need to copy the current part of the number to the 2761   // number, we need to copy the current part of the number to the
2757   // temporary buffer 2762   // temporary buffer
HITCBC 2758   1000052 if(BOOST_JSON_UNLIKELY( num_buf_.size() )) 2763   1000052 if(BOOST_JSON_UNLIKELY( num_buf_.size() ))
2759   { 2764   {
HITCBC 2760   1 data = num_buf_.append( begin, size ); 2765   1 data = num_buf_.append( begin, size );
HITCBC 2761   1 full_size = num_buf_.size(); 2766   1 full_size = num_buf_.size();
2762   } 2767   }
HITCBC 2763   1000052 auto const err = detail::charconv::from_chars( 2768   1000052 auto const err = detail::charconv::from_chars(
2764   data, data + full_size, d ); 2769   data, data + full_size, d );
HITCBC 2765   1000052 BOOST_ASSERT( err.ec != std::errc::invalid_argument ); 2770   1000052 BOOST_ASSERT( err.ec != std::errc::invalid_argument );
HITCBC 2766   1000052 BOOST_ASSERT( err.ptr == data + full_size ); 2771   1000052 BOOST_ASSERT( err.ptr == data + full_size );
2767   (void)err; 2772   (void)err;
2768   } 2773   }
2769   else BOOST_IF_CONSTEXPR( no_parsing ) 2774   else BOOST_IF_CONSTEXPR( no_parsing )
HITCBC 2770   9258 d = 0; 2775   9258 d = 0;
2771   else 2776   else
HITCBC 2772   1043144 d = detail::dec_to_float( 2777   1043157 d = detail::dec_to_float(
2773   num.mant, 2778   num.mant,
HITCBC 2774   541032 num.bias + (num.frac ? 2779   541045 num.bias + (num.frac ?
HITCBC 2775   502112 -num.exp : num.exp), 2780   502112 -num.exp : num.exp),
HITCBC 2776   1043144 num.neg); 2781   1043157 num.neg);
HITCBC 2777   2052454 if(BOOST_JSON_UNLIKELY( 2782   2052467 if(BOOST_JSON_UNLIKELY(
2778   ! h_.on_double(d, {begin, size}, ec_))) 2783   ! h_.on_double(d, {begin, size}, ec_)))
HITCBC 2779   1935 return fail(cs.begin()); 2784   1935 return fail(cs.begin());
HITCBC 2780   2048584 return cs.begin(); 2785   2048597 return cs.begin();
2781   } 2786   }
2782   2787  
2783   //---------------------------------------------------------- 2788   //----------------------------------------------------------
2784   2789  
2785   template<class Handler> 2790   template<class Handler>
2786   template<class... Args> 2791   template<class... Args>
HITCBC 2787   2164974 basic_parser<Handler>:: 2792   2164987 basic_parser<Handler>::
2788   basic_parser( 2793   basic_parser(
2789   parse_options const& opt, 2794   parse_options const& opt,
2790   Args&&... args) 2795   Args&&... args)
HITCBC 2791   2164965 : h_(std::forward<Args>(args)...) 2796   2164978 : h_(std::forward<Args>(args)...)
HITCBC 2792   2164974 , opt_(opt) 2797   2164987 , opt_(opt)
2793   { 2798   {
HITCBC 2794   2164974 } 2799   2164987 }
2795   2800  
2796   //---------------------------------------------------------- 2801   //----------------------------------------------------------
2797   2802  
2798   template<class Handler> 2803   template<class Handler>
2799   void 2804   void
HITCBC 2800   4153140 basic_parser<Handler>:: 2805   4153166 basic_parser<Handler>::
2801   reset() noexcept 2806   reset() noexcept
2802   { 2807   {
HITCBC 2803   4153140 ec_ = {}; 2808   4153166 ec_ = {};
HITCBC 2804   4153140 st_.clear(); 2809   4153166 st_.clear();
HITCBC 2805   4153140 more_ = true; 2810   4153166 more_ = true;
HITCBC 2806   4153140 done_ = false; 2811   4153166 done_ = false;
HITCBC 2807   4153140 clean_ = true; 2812   4153166 clean_ = true;
HITCBC 2808   4153140 num_buf_.clear(); 2813   4153166 num_buf_.clear();
HITCBC 2809   4153140 } 2814   4153166 }
2810   2815  
2811   template<class Handler> 2816   template<class Handler>
2812   void 2817   void
HITCBC 2813   18 basic_parser<Handler>:: 2818   18 basic_parser<Handler>::
2814   fail(system::error_code ec) noexcept 2819   fail(system::error_code ec) noexcept
2815   { 2820   {
HITCBC 2816   18 if(! ec) 2821   18 if(! ec)
2817   { 2822   {
2818   // assign an arbitrary 2823   // assign an arbitrary
2819   // error code to prevent UB 2824   // error code to prevent UB
HITCBC 2820   1 BOOST_JSON_FAIL(ec_, error::incomplete); 2825   1 BOOST_JSON_FAIL(ec_, error::incomplete);
2821   } 2826   }
2822   else 2827   else
2823   { 2828   {
HITCBC 2824   17 ec_ = ec; 2829   17 ec_ = ec;
2825   } 2830   }
HITCBC 2826   18 done_ = false; 2831   18 done_ = false;
HITCBC 2827   18 } 2832   18 }
2828   2833  
2829   //---------------------------------------------------------- 2834   //----------------------------------------------------------
2830   2835  
2831   template<class Handler> 2836   template<class Handler>
2832   std::size_t 2837   std::size_t
HITCBC 2833   10726419 basic_parser<Handler>:: 2838   10726454 basic_parser<Handler>::
2834   write_some( 2839   write_some(
2835   bool more, 2840   bool more,
2836   char const* data, 2841   char const* data,
2837   std::size_t size, 2842   std::size_t size,
2838   system::error_code& ec) 2843   system::error_code& ec)
2839   { 2844   {
2840   // see if we exited via exception 2845   // see if we exited via exception
2841   // on the last call to write_some 2846   // on the last call to write_some
HITCBC 2842   10726419 if(! clean_) 2847   10726454 if(! clean_)
2843   { 2848   {
2844   // prevent UB 2849   // prevent UB
HITCBC 2845   1 if(! ec_) 2850   1 if(! ec_)
2846   { 2851   {
HITCBC 2847   1 BOOST_JSON_FAIL(ec_, error::exception); 2852   1 BOOST_JSON_FAIL(ec_, error::exception);
2848   } 2853   }
2849   } 2854   }
HITCBC 2850   10726419 if(ec_) 2855   10726454 if(ec_)
2851   { 2856   {
2852   // error is sticky 2857   // error is sticky
HITCBC 2853   5 ec = ec_; 2858   5 ec = ec_;
HITCBC 2854   5 return 0; 2859   5 return 0;
2855   } 2860   }
HITCBC 2856   10726414 clean_ = false; 2861   10726449 clean_ = false;
HITCBC 2857   10726414 more_ = more; 2862   10726449 more_ = more;
HITCBC 2858   10726414 end_ = data + size; 2863   10726449 end_ = data + size;
2859   const char* p; 2864   const char* p;
HITCBC 2860   10726414 if(BOOST_JSON_LIKELY(st_.empty())) 2865   10726449 if(BOOST_JSON_LIKELY(st_.empty()))
2861   { 2866   {
2862   // first time 2867   // first time
HITCBC 2863   2164963 depth_ = opt_.max_depth; 2868   2164976 depth_ = opt_.max_depth;
HITCBC 2864   2164963 if(BOOST_JSON_UNLIKELY( 2869   2164976 if(BOOST_JSON_UNLIKELY(
2865   ! h_.on_document_begin(ec_))) 2870   ! h_.on_document_begin(ec_)))
2866   { 2871   {
HITCBC 2867   7928 ec = ec_; 2872   7928 ec = ec_;
HITCBC 2868   7928 return 0; 2873   7928 return 0;
2869   } 2874   }
HITCBC 2870   2149106 p = parse_document(data, std::true_type()); 2875   2149119 p = parse_document(data, std::true_type());
2871   } 2876   }
2872   else 2877   else
2873   { 2878   {
HITCBC 2874   8561451 p = parse_document(data, std::false_type()); 2879   8561473 p = parse_document(data, std::false_type());
2875   } 2880   }
2876   2881  
HITCBC 2877   10691389 if(BOOST_JSON_LIKELY(p != sentinel())) 2882   10691424 if(BOOST_JSON_LIKELY(p != sentinel()))
2878   { 2883   {
HITCBC 2879   2099182 BOOST_ASSERT(! ec_); 2884   2099195 BOOST_ASSERT(! ec_);
HITCBC 2880   2099182 if(! done_) 2885   2099195 if(! done_)
2881   { 2886   {
HITCBC 2882   2031767 done_ = true; 2887   2031780 done_ = true;
HITCBC 2883   2031767 h_.on_document_end(ec_); 2888   2031780 h_.on_document_end(ec_);
2884   } 2889   }
2885   } 2890   }
2886   else 2891   else
2887   { 2892   {
HITCBC 2888   8592207 if(! ec_) 2893   8592229 if(! ec_)
2889   { 2894   {
HITCBC 2890   8565352 if(! more_) 2895   8565374 if(! more_)
2891   { 2896   {
HITCBC 2892   589 BOOST_JSON_FAIL(ec_, error::incomplete); 2897   589 BOOST_JSON_FAIL(ec_, error::incomplete);
2893   } 2898   }
HITCBC 2894   8564763 else if(! st_.empty()) 2899   8564785 else if(! st_.empty())
2895   { 2900   {
2896   // consume as much trailing whitespace in 2901   // consume as much trailing whitespace in
2897   // the JSON document as possible, but still 2902   // the JSON document as possible, but still
2898   // consider the parse complete 2903   // consider the parse complete
2899   state st; 2904   state st;
HITCBC 2900   8564763 st_.peek(st); 2905   8564785 st_.peek(st);
HITCBC 2901   8564763 if( st == state::doc3 && 2906   8564785 if( st == state::doc3 &&
HITCBC 2902   88551 ! done_) 2907   88551 ! done_)
2903   { 2908   {
HITCBC 2904   70724 done_ = true; 2909   70724 done_ = true;
HITCBC 2905   70724 h_.on_document_end(ec_); 2910   70724 h_.on_document_end(ec_);
2906   } 2911   }
2907   } 2912   }
2908   } 2913   }
HITCBC 2909   8590563 p = end_; 2914   8590585 p = end_;
2910   } 2915   }
HITCBC 2911   10685753 ec = ec_; 2916   10685788 ec = ec_;
HITCBC 2912   10685753 clean_ = true; 2917   10685788 clean_ = true;
HITCBC 2913   10685753 return p - data; 2918   10685788 return p - data;
2914   } 2919   }
2915   2920  
2916   template<class Handler> 2921   template<class Handler>
2917   std::size_t 2922   std::size_t
HITCBC 2918   1 basic_parser<Handler>:: 2923   1 basic_parser<Handler>::
2919   write_some( 2924   write_some(
2920   bool more, 2925   bool more,
2921   char const* data, 2926   char const* data,
2922   std::size_t size, 2927   std::size_t size,
2923   std::error_code& ec) 2928   std::error_code& ec)
2924   { 2929   {
HITCBC 2925   1 system::error_code jec; 2930   1 system::error_code jec;
HITCBC 2926   1 std::size_t const result = write_some(more, data, size, jec); 2931   1 std::size_t const result = write_some(more, data, size, jec);
HITCBC 2927   1 ec = jec; 2932   1 ec = jec;
HITCBC 2928   1 return result; 2933   1 return result;
2929   } 2934   }
2930   2935  
2931   #endif 2936   #endif
2932   2937  
2933   } // namespace json 2938   } // namespace json
2934   } // namespace boost 2939   } // namespace boost
2935   2940  
2936   #ifdef _MSC_VER 2941   #ifdef _MSC_VER
2937   #pragma warning(pop) 2942   #pragma warning(pop)
2938   #endif 2943   #endif
2939   2944  
2940   #endif 2945   #endif