Coverage Report

Created: 2026-10-14 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/jsoncons/include/jsoncons_ext/msgpack/msgpack_parser.hpp
Line
Count
Source
1
// Copyright 2013-2026 Daniel Parker
2
// Distributed under the Boost license, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5
// See https://github.com/danielaparker/jsoncons for latest version
6
7
#ifndef JSONCONS_EXT_MSGPACK_MSGPACK_PARSER_HPP
8
#define JSONCONS_EXT_MSGPACK_MSGPACK_PARSER_HPP
9
10
#include <cstddef>
11
#include <cstdint>
12
#include <memory>
13
#include <string>
14
#include <system_error>
15
#include <utility> // std::move
16
#include <vector>
17
18
#include <jsoncons/nonstd/compiler_support.hpp>
19
#include <jsoncons/config/jsoncons_config.hpp>
20
#include <jsoncons/generic_visitor.hpp>
21
#include <jsoncons/json_type.hpp>
22
#include <jsoncons/semantic_tag.hpp>
23
#include <jsoncons/ser_common.hpp>
24
#include <jsoncons/source.hpp>
25
#include <jsoncons/utility/bigint.hpp>
26
#include <jsoncons/utility/binary.hpp>
27
#include <jsoncons/utility/byte_string.hpp>
28
#include <jsoncons/utility/unicode_traits.hpp>
29
30
#include <jsoncons_ext/msgpack/msgpack_error.hpp>
31
#include <jsoncons_ext/msgpack/msgpack_options.hpp>
32
#include <jsoncons_ext/msgpack/msgpack_type.hpp>
33
34
namespace jsoncons { 
35
namespace msgpack {
36
37
enum class parse_mode {root,accept,array,map_key,map_value};
38
39
struct parse_state 
40
{
41
    parse_mode mode; 
42
    std::size_t length{0};
43
    std::size_t index{0};
44
45
    parse_state(parse_mode mode, std::size_t length) noexcept
46
19.8M
        : mode(mode), length(length)
47
19.8M
    {
48
19.8M
    }
49
50
    parse_state(const parse_state&) = default;
51
    parse_state(parse_state&&) = default;
52
    
53
    ~parse_state() = default;
54
};
55
56
template <typename Source,typename Allocator=std::allocator<char>>
57
class basic_msgpack_parser : public ser_context
58
{
59
    using char_type = char;
60
    using char_traits_type = std::char_traits<char>;
61
    using temp_allocator_type = Allocator;
62
    using char_allocator_type = typename std::allocator_traits<temp_allocator_type>:: template rebind_alloc<char_type>;                  
63
    using byte_allocator_type = typename std::allocator_traits<temp_allocator_type>:: template rebind_alloc<uint8_t>;                  
64
    using int64_allocator_type = typename std::allocator_traits<temp_allocator_type>:: template rebind_alloc<int64_t>;                  
65
    using parse_state_allocator_type = typename std::allocator_traits<temp_allocator_type>:: template rebind_alloc<parse_state>;                         
66
67
    static constexpr int64_t nanos_in_second = 1000000000;
68
69
    bool more_{true};
70
    bool done_{false};
71
    int nesting_depth_{0};
72
    bool cursor_mode_{false};
73
    int mark_level_{0};
74
75
    Source source_;
76
    int max_nesting_depth_;
77
    std::basic_string<char,std::char_traits<char>,char_allocator_type> text_buffer_;
78
    std::vector<uint8_t,byte_allocator_type> bytes_buffer_;
79
    std::vector<parse_state,parse_state_allocator_type> state_stack_;
80
81
public:
82
    template <typename Sourceable>
83
    basic_msgpack_parser(Sourceable&& source,
84
                         const msgpack_decode_options& options = msgpack_decode_options(),
85
                         const Allocator& alloc = Allocator())
86
32.1k
       : source_(std::forward<Sourceable>(source)),
87
32.1k
         max_nesting_depth_(options.max_nesting_depth()),
88
32.1k
         text_buffer_(alloc),
89
32.1k
         bytes_buffer_(alloc),
90
32.1k
         state_stack_(alloc)
91
32.1k
    {
92
32.1k
        state_stack_.emplace_back(parse_mode::root,0);
93
32.1k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> > >(jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >&&, jsoncons::msgpack::msgpack_decode_options const&, std::__1::allocator<char> const&)
Line
Count
Source
86
6.92k
       : source_(std::forward<Sourceable>(source)),
87
6.92k
         max_nesting_depth_(options.max_nesting_depth()),
88
6.92k
         text_buffer_(alloc),
89
6.92k
         bytes_buffer_(alloc),
90
6.92k
         state_stack_(alloc)
91
6.92k
    {
92
6.92k
        state_stack_.emplace_back(parse_mode::root,0);
93
6.92k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::basic_msgpack_parser<std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&>(std::__1::basic_istringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, jsoncons::msgpack::msgpack_decode_options const&, std::__1::allocator<char> const&)
Line
Count
Source
86
11.2k
       : source_(std::forward<Sourceable>(source)),
87
11.2k
         max_nesting_depth_(options.max_nesting_depth()),
88
11.2k
         text_buffer_(alloc),
89
11.2k
         bytes_buffer_(alloc),
90
11.2k
         state_stack_(alloc)
91
11.2k
    {
92
11.2k
        state_stack_.emplace_back(parse_mode::root,0);
93
11.2k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::basic_msgpack_parser<jsoncons::nonstd::span<unsigned char const, 18446744073709551615ul> const&>(jsoncons::nonstd::span<unsigned char const, 18446744073709551615ul> const&, jsoncons::msgpack::msgpack_decode_options const&, std::__1::allocator<char> const&)
Line
Count
Source
86
6.95k
       : source_(std::forward<Sourceable>(source)),
87
6.95k
         max_nesting_depth_(options.max_nesting_depth()),
88
6.95k
         text_buffer_(alloc),
89
6.95k
         bytes_buffer_(alloc),
90
6.95k
         state_stack_(alloc)
91
6.95k
    {
92
6.95k
        state_stack_.emplace_back(parse_mode::root,0);
93
6.95k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::basic_msgpack_parser<std::__1::basic_istream<char, std::__1::char_traits<char> >&>(std::__1::basic_istream<char, std::__1::char_traits<char> >&, jsoncons::msgpack::msgpack_decode_options const&, std::__1::allocator<char> const&)
Line
Count
Source
86
6.97k
       : source_(std::forward<Sourceable>(source)),
87
6.97k
         max_nesting_depth_(options.max_nesting_depth()),
88
6.97k
         text_buffer_(alloc),
89
6.97k
         bytes_buffer_(alloc),
90
6.97k
         state_stack_(alloc)
91
6.97k
    {
92
6.97k
        state_stack_.emplace_back(parse_mode::root,0);
93
6.97k
    }
94
95
    void restart()
96
    {
97
        more_ = true;
98
    }
99
100
    void reset()
101
32.1k
    {
102
32.1k
        more_ = true;
103
32.1k
        done_ = false;
104
32.1k
        text_buffer_.clear();
105
32.1k
        bytes_buffer_.clear();
106
32.1k
        state_stack_.clear();
107
32.1k
        state_stack_.emplace_back(parse_mode::root,0);
108
32.1k
        nesting_depth_ = 0;
109
32.1k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::reset()
Line
Count
Source
101
6.92k
    {
102
6.92k
        more_ = true;
103
6.92k
        done_ = false;
104
6.92k
        text_buffer_.clear();
105
6.92k
        bytes_buffer_.clear();
106
6.92k
        state_stack_.clear();
107
6.92k
        state_stack_.emplace_back(parse_mode::root,0);
108
6.92k
        nesting_depth_ = 0;
109
6.92k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::reset()
Line
Count
Source
101
18.2k
    {
102
18.2k
        more_ = true;
103
18.2k
        done_ = false;
104
18.2k
        text_buffer_.clear();
105
18.2k
        bytes_buffer_.clear();
106
18.2k
        state_stack_.clear();
107
18.2k
        state_stack_.emplace_back(parse_mode::root,0);
108
18.2k
        nesting_depth_ = 0;
109
18.2k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::reset()
Line
Count
Source
101
6.95k
    {
102
6.95k
        more_ = true;
103
6.95k
        done_ = false;
104
6.95k
        text_buffer_.clear();
105
6.95k
        bytes_buffer_.clear();
106
6.95k
        state_stack_.clear();
107
6.95k
        state_stack_.emplace_back(parse_mode::root,0);
108
6.95k
        nesting_depth_ = 0;
109
6.95k
    }
110
111
    template <typename Sourceable>
112
    void reset(Sourceable&& source)
113
    {
114
        source_ = std::forward<Sourceable>(source);
115
        reset();
116
    }
117
118
    void cursor_mode(bool value)
119
    {
120
        cursor_mode_ = value;
121
    }
122
123
    int level() const
124
    {
125
        return static_cast<int>(state_stack_.size());
126
    }
127
128
    int mark_level() const 
129
    {
130
        return mark_level_;
131
    }
132
133
    void mark_level(int value)
134
    {
135
        mark_level_ = value;
136
    }
137
138
    bool done() const
139
    {
140
        return done_;
141
    }
142
143
    bool stopped() const
144
    {
145
        return !more_;
146
    }
147
148
    std::size_t line() const final
149
14.2k
    {
150
14.2k
        return 0;
151
14.2k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::line() const
Line
Count
Source
149
4.81k
    {
150
4.81k
        return 0;
151
4.81k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::line() const
Line
Count
Source
149
4.64k
    {
150
4.64k
        return 0;
151
4.64k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::line() const
Line
Count
Source
149
4.77k
    {
150
4.77k
        return 0;
151
4.77k
    }
152
153
    std::size_t column() const final
154
14.2k
    {
155
14.2k
        return source_.position();
156
14.2k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::column() const
Line
Count
Source
154
4.81k
    {
155
4.81k
        return source_.position();
156
4.81k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::column() const
Line
Count
Source
154
4.64k
    {
155
4.64k
        return source_.position();
156
4.64k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::column() const
Line
Count
Source
154
4.77k
    {
155
4.77k
        return source_.position();
156
4.77k
    }
157
158
    void parse(generic_visitor& visitor, std::error_code& ec)
159
32.1k
    {
160
337M
        while (!done_ && more_)
161
337M
        {
162
337M
            switch (state_stack_.back().mode)
163
337M
            {
164
197M
                case parse_mode::array:
165
197M
                {
166
197M
                    if (state_stack_.back().index < state_stack_.back().length)
167
186M
                    {
168
186M
                        ++state_stack_.back().index;
169
186M
                        read_item(visitor, ec);
170
186M
                        if (JSONCONS_UNLIKELY(ec))
171
6.54k
                        {
172
6.54k
                            return;
173
6.54k
                        }
174
186M
                    }
175
10.9M
                    else
176
10.9M
                    {
177
10.9M
                        end_array(visitor, ec);
178
10.9M
                    }
179
197M
                    break;
180
197M
                }
181
197M
                case parse_mode::map_key:
182
74.1M
                {
183
74.1M
                    if (state_stack_.back().index < state_stack_.back().length)
184
65.5M
                    {
185
65.5M
                        ++state_stack_.back().index;
186
65.5M
                        state_stack_.back().mode = parse_mode::map_value;
187
65.5M
                        read_item(visitor, ec);
188
65.5M
                        if (JSONCONS_UNLIKELY(ec))
189
4.70k
                        {
190
4.70k
                            return;
191
4.70k
                        }
192
65.5M
                    }
193
8.59M
                    else
194
8.59M
                    {
195
8.59M
                        end_object(visitor, ec);
196
8.59M
                    }
197
74.1M
                    break;
198
74.1M
                }
199
74.1M
                case parse_mode::map_value:
200
65.4M
                {
201
65.4M
                    state_stack_.back().mode = parse_mode::map_key;
202
65.4M
                    read_item(visitor, ec);
203
65.4M
                    if (JSONCONS_UNLIKELY(ec))
204
9.54k
                    {
205
9.54k
                        return;
206
9.54k
                    }
207
65.4M
                    break;
208
65.4M
                }
209
65.4M
                case parse_mode::root:
210
32.1k
                {
211
32.1k
                    state_stack_.back().mode = parse_mode::accept;
212
32.1k
                    read_item(visitor, ec);
213
32.1k
                    if (JSONCONS_UNLIKELY(ec))
214
2.08k
                    {
215
2.08k
                        return;
216
2.08k
                    }
217
30.0k
                    break;
218
32.1k
                }
219
30.0k
                case parse_mode::accept:
220
9.26k
                {
221
9.26k
                    JSONCONS_ASSERT(state_stack_.size() == 1);
222
9.26k
                    state_stack_.clear();
223
9.26k
                    more_ = false;
224
9.26k
                    done_ = true;
225
9.26k
                    visitor.flush();
226
9.26k
                    break;
227
9.26k
                }
228
337M
            }
229
337M
        }
230
32.1k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::parse(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
159
6.92k
    {
160
80.0M
        while (!done_ && more_)
161
80.0M
        {
162
80.0M
            switch (state_stack_.back().mode)
163
80.0M
            {
164
44.3M
                case parse_mode::array:
165
44.3M
                {
166
44.3M
                    if (state_stack_.back().index < state_stack_.back().length)
167
42.3M
                    {
168
42.3M
                        ++state_stack_.back().index;
169
42.3M
                        read_item(visitor, ec);
170
42.3M
                        if (JSONCONS_UNLIKELY(ec))
171
1.32k
                        {
172
1.32k
                            return;
173
1.32k
                        }
174
42.3M
                    }
175
2.01M
                    else
176
2.01M
                    {
177
2.01M
                        end_array(visitor, ec);
178
2.01M
                    }
179
44.3M
                    break;
180
44.3M
                }
181
44.3M
                case parse_mode::map_key:
182
18.7M
                {
183
18.7M
                    if (state_stack_.back().index < state_stack_.back().length)
184
16.9M
                    {
185
16.9M
                        ++state_stack_.back().index;
186
16.9M
                        state_stack_.back().mode = parse_mode::map_value;
187
16.9M
                        read_item(visitor, ec);
188
16.9M
                        if (JSONCONS_UNLIKELY(ec))
189
1.10k
                        {
190
1.10k
                            return;
191
1.10k
                        }
192
16.9M
                    }
193
1.81M
                    else
194
1.81M
                    {
195
1.81M
                        end_object(visitor, ec);
196
1.81M
                    }
197
18.7M
                    break;
198
18.7M
                }
199
18.7M
                case parse_mode::map_value:
200
16.9M
                {
201
16.9M
                    state_stack_.back().mode = parse_mode::map_key;
202
16.9M
                    read_item(visitor, ec);
203
16.9M
                    if (JSONCONS_UNLIKELY(ec))
204
1.93k
                    {
205
1.93k
                        return;
206
1.93k
                    }
207
16.9M
                    break;
208
16.9M
                }
209
16.9M
                case parse_mode::root:
210
6.92k
                {
211
6.92k
                    state_stack_.back().mode = parse_mode::accept;
212
6.92k
                    read_item(visitor, ec);
213
6.92k
                    if (JSONCONS_UNLIKELY(ec))
214
441
                    {
215
441
                        return;
216
441
                    }
217
6.48k
                    break;
218
6.92k
                }
219
6.48k
                case parse_mode::accept:
220
2.11k
                {
221
2.11k
                    JSONCONS_ASSERT(state_stack_.size() == 1);
222
2.11k
                    state_stack_.clear();
223
2.11k
                    more_ = false;
224
2.11k
                    done_ = true;
225
2.11k
                    visitor.flush();
226
2.11k
                    break;
227
2.11k
                }
228
80.0M
            }
229
80.0M
        }
230
6.92k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::parse(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
159
18.2k
    {
160
167M
        while (!done_ && more_)
161
167M
        {
162
167M
            switch (state_stack_.back().mode)
163
167M
            {
164
112M
                case parse_mode::array:
165
112M
                {
166
112M
                    if (state_stack_.back().index < state_stack_.back().length)
167
105M
                    {
168
105M
                        ++state_stack_.back().index;
169
105M
                        read_item(visitor, ec);
170
105M
                        if (JSONCONS_UNLIKELY(ec))
171
3.82k
                        {
172
3.82k
                            return;
173
3.82k
                        }
174
105M
                    }
175
7.18M
                    else
176
7.18M
                    {
177
7.18M
                        end_array(visitor, ec);
178
7.18M
                    }
179
112M
                    break;
180
112M
                }
181
112M
                case parse_mode::map_key:
182
28.4M
                {
183
28.4M
                    if (state_stack_.back().index < state_stack_.back().length)
184
26.4M
                    {
185
26.4M
                        ++state_stack_.back().index;
186
26.4M
                        state_stack_.back().mode = parse_mode::map_value;
187
26.4M
                        read_item(visitor, ec);
188
26.4M
                        if (JSONCONS_UNLIKELY(ec))
189
2.48k
                        {
190
2.48k
                            return;
191
2.48k
                        }
192
26.4M
                    }
193
2.01M
                    else
194
2.01M
                    {
195
2.01M
                        end_object(visitor, ec);
196
2.01M
                    }
197
28.4M
                    break;
198
28.4M
                }
199
28.4M
                case parse_mode::map_value:
200
26.4M
                {
201
26.4M
                    state_stack_.back().mode = parse_mode::map_key;
202
26.4M
                    read_item(visitor, ec);
203
26.4M
                    if (JSONCONS_UNLIKELY(ec))
204
5.66k
                    {
205
5.66k
                        return;
206
5.66k
                    }
207
26.4M
                    break;
208
26.4M
                }
209
26.4M
                case parse_mode::root:
210
18.2k
                {
211
18.2k
                    state_stack_.back().mode = parse_mode::accept;
212
18.2k
                    read_item(visitor, ec);
213
18.2k
                    if (JSONCONS_UNLIKELY(ec))
214
1.30k
                    {
215
1.30k
                        return;
216
1.30k
                    }
217
16.9k
                    break;
218
18.2k
                }
219
16.9k
                case parse_mode::accept:
220
4.97k
                {
221
4.97k
                    JSONCONS_ASSERT(state_stack_.size() == 1);
222
4.97k
                    state_stack_.clear();
223
4.97k
                    more_ = false;
224
4.97k
                    done_ = true;
225
4.97k
                    visitor.flush();
226
4.97k
                    break;
227
4.97k
                }
228
167M
            }
229
167M
        }
230
18.2k
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::parse(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
159
6.95k
    {
160
89.6M
        while (!done_ && more_)
161
89.6M
        {
162
89.6M
            switch (state_stack_.back().mode)
163
89.6M
            {
164
40.6M
                case parse_mode::array:
165
40.6M
                {
166
40.6M
                    if (state_stack_.back().index < state_stack_.back().length)
167
38.8M
                    {
168
38.8M
                        ++state_stack_.back().index;
169
38.8M
                        read_item(visitor, ec);
170
38.8M
                        if (JSONCONS_UNLIKELY(ec))
171
1.38k
                        {
172
1.38k
                            return;
173
1.38k
                        }
174
38.8M
                    }
175
1.77M
                    else
176
1.77M
                    {
177
1.77M
                        end_array(visitor, ec);
178
1.77M
                    }
179
40.6M
                    break;
180
40.6M
                }
181
40.6M
                case parse_mode::map_key:
182
26.9M
                {
183
26.9M
                    if (state_stack_.back().index < state_stack_.back().length)
184
22.1M
                    {
185
22.1M
                        ++state_stack_.back().index;
186
22.1M
                        state_stack_.back().mode = parse_mode::map_value;
187
22.1M
                        read_item(visitor, ec);
188
22.1M
                        if (JSONCONS_UNLIKELY(ec))
189
1.11k
                        {
190
1.11k
                            return;
191
1.11k
                        }
192
22.1M
                    }
193
4.75M
                    else
194
4.75M
                    {
195
4.75M
                        end_object(visitor, ec);
196
4.75M
                    }
197
26.9M
                    break;
198
26.9M
                }
199
26.9M
                case parse_mode::map_value:
200
22.1M
                {
201
22.1M
                    state_stack_.back().mode = parse_mode::map_key;
202
22.1M
                    read_item(visitor, ec);
203
22.1M
                    if (JSONCONS_UNLIKELY(ec))
204
1.93k
                    {
205
1.93k
                        return;
206
1.93k
                    }
207
22.1M
                    break;
208
22.1M
                }
209
22.1M
                case parse_mode::root:
210
6.95k
                {
211
6.95k
                    state_stack_.back().mode = parse_mode::accept;
212
6.95k
                    read_item(visitor, ec);
213
6.95k
                    if (JSONCONS_UNLIKELY(ec))
214
343
                    {
215
343
                        return;
216
343
                    }
217
6.60k
                    break;
218
6.95k
                }
219
6.60k
                case parse_mode::accept:
220
2.17k
                {
221
2.17k
                    JSONCONS_ASSERT(state_stack_.size() == 1);
222
2.17k
                    state_stack_.clear();
223
2.17k
                    more_ = false;
224
2.17k
                    done_ = true;
225
2.17k
                    visitor.flush();
226
2.17k
                    break;
227
2.17k
                }
228
89.6M
            }
229
89.6M
        }
230
6.95k
    }
231
private:
232
233
    void read_item(generic_visitor& visitor, std::error_code& ec)
234
317M
    {
235
317M
        if (source_.is_error())
236
0
        {
237
0
            ec = msgpack_errc::source_error;
238
0
            more_ = false;
239
0
            return;
240
0
        }   
241
242
317M
        uint8_t type;
243
317M
        if (source_.read(&type, 1) == 0)
244
17.7k
        {
245
17.7k
            ec = msgpack_errc::unexpected_eof;
246
17.7k
            more_ = false;
247
17.7k
            return;
248
17.7k
        }
249
250
317M
        if (type <= 0xbf)
251
184M
        {
252
184M
            if (type <= 0x7f) 
253
137M
            {
254
                // positive fixint
255
137M
                visitor.uint64_value(type, semantic_tag::none, *this, ec);
256
137M
                more_ = !cursor_mode_;
257
137M
            }
258
46.3M
            else if (type <= 0x8f) 
259
8.64M
            {
260
8.64M
                begin_object(visitor,type,ec); // fixmap
261
8.64M
            }
262
37.6M
            else if (type <= 0x9f) 
263
11.0M
            {
264
11.0M
                begin_array(visitor,type,ec); // fixarray
265
11.0M
            }
266
26.6M
            else 
267
26.6M
            {
268
                // fixstr
269
26.6M
                const size_t len = type & 0x1f;
270
271
26.6M
                auto data = source_.read_span(len, bytes_buffer_);
272
26.6M
                if (data.size() != static_cast<std::size_t>(len))
273
244
                {
274
244
                    ec = msgpack_errc::unexpected_eof;
275
244
                    more_ = false;
276
244
                    return;
277
244
                }
278
279
26.6M
                auto result = unicode_traits::validate(data.data(), data.size());
280
26.6M
                if (result.ec != unicode_traits::unicode_errc())
281
1.01k
                {
282
1.01k
                    ec = msgpack_errc::invalid_utf8_text_string;
283
1.01k
                    more_ = false;
284
1.01k
                    return;
285
1.01k
                }
286
26.6M
                visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
287
26.6M
                    semantic_tag::none, *this, ec);
288
26.6M
                more_ = !cursor_mode_;
289
26.6M
            }
290
184M
        }
291
133M
        else if (type >= 0xe0) 
292
54.2M
        {
293
            // negative fixint
294
54.2M
            visitor.int64_value(static_cast<int8_t>(type), semantic_tag::none, *this, ec);
295
54.2M
            more_ = !cursor_mode_;
296
54.2M
        }
297
79.6M
        else
298
79.6M
        {
299
79.6M
            switch (type)
300
79.6M
            {
301
3.48M
                case jsoncons::msgpack::msgpack_type::nil_type: 
302
3.48M
                {
303
3.48M
                    visitor.null_value(semantic_tag::none, *this, ec);
304
3.48M
                    more_ = !cursor_mode_;
305
3.48M
                    break;
306
0
                }
307
15.9M
                case jsoncons::msgpack::msgpack_type::true_type:
308
15.9M
                {
309
15.9M
                    visitor.bool_value(true, semantic_tag::none, *this, ec);
310
15.9M
                    more_ = !cursor_mode_;
311
15.9M
                    break;
312
0
                }
313
51.9M
                case jsoncons::msgpack::msgpack_type::false_type:
314
51.9M
                {
315
51.9M
                    visitor.bool_value(false, semantic_tag::none, *this, ec);
316
51.9M
                    more_ = !cursor_mode_;
317
51.9M
                    break;
318
0
                }
319
699k
                case jsoncons::msgpack::msgpack_type::float32_type: 
320
699k
                {
321
699k
                    uint8_t buf[sizeof(float)];
322
699k
                    if (source_.read(buf, sizeof(float)) != sizeof(float))
323
153
                    {
324
153
                        ec = msgpack_errc::unexpected_eof;
325
153
                        more_ = false;
326
153
                        return;
327
153
                    }
328
699k
                    float val = binary::big_to_native<float>(buf, sizeof(buf));
329
699k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
330
699k
                    more_ = !cursor_mode_;
331
699k
                    break;
332
699k
                }
333
334
179k
                case jsoncons::msgpack::msgpack_type::float64_type: 
335
179k
                {
336
179k
                    uint8_t buf[sizeof(double)];
337
179k
                    if (source_.read(buf, sizeof(double)) != sizeof(double))
338
101
                    {
339
101
                        ec = msgpack_errc::unexpected_eof;
340
101
                        more_ = false;
341
101
                        return;
342
101
                    }
343
179k
                    double val = binary::big_to_native<double>(buf, sizeof(buf));
344
179k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
345
179k
                    more_ = !cursor_mode_;
346
179k
                    break;
347
179k
                }
348
349
50.6k
                case jsoncons::msgpack::msgpack_type::uint8_type: 
350
50.6k
                {
351
50.6k
                    uint8_t b;
352
50.6k
                    if (source_.read(&b, 1) == 0)
353
13
                    {
354
13
                        ec = msgpack_errc::unexpected_eof;
355
13
                        more_ = false;
356
13
                        return;
357
13
                    }
358
50.6k
                    visitor.uint64_value(b, semantic_tag::none, *this, ec);
359
50.6k
                    more_ = !cursor_mode_;
360
50.6k
                    break;
361
50.6k
                }
362
363
415k
                case jsoncons::msgpack::msgpack_type::uint16_type: 
364
415k
                {
365
415k
                    uint8_t buf[sizeof(uint16_t)];
366
415k
                    if (source_.read(buf, sizeof(uint16_t)) !=sizeof(uint16_t)) 
367
18
                    {
368
18
                        ec = msgpack_errc::unexpected_eof;
369
18
                        more_ = false;
370
18
                        return;
371
18
                    }
372
415k
                    uint16_t val = binary::big_to_native<uint16_t>(buf, sizeof(buf));
373
415k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
374
415k
                    more_ = !cursor_mode_;
375
415k
                    break;
376
415k
                }
377
378
83.1k
                case jsoncons::msgpack::msgpack_type::uint32_type: 
379
83.1k
                {
380
83.1k
                    uint8_t buf[sizeof(uint32_t)];
381
83.1k
                    if (source_.read(buf, sizeof(uint32_t)) != sizeof(uint32_t))
382
24
                    {
383
24
                        ec = msgpack_errc::unexpected_eof;
384
24
                        more_ = false;
385
24
                        return;
386
24
                    }
387
83.0k
                    uint32_t val = binary::big_to_native<uint32_t>(buf, sizeof(buf));
388
83.0k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
389
83.0k
                    more_ = !cursor_mode_;
390
83.0k
                    break;
391
83.1k
                }
392
393
42.0k
                case jsoncons::msgpack::msgpack_type::uint64_type: 
394
42.0k
                {
395
42.0k
                    uint8_t buf[sizeof(uint64_t)];
396
42.0k
                    if (source_.read(buf, sizeof(uint64_t)) != sizeof(uint64_t))
397
39
                    {
398
39
                        ec = msgpack_errc::unexpected_eof;
399
39
                        more_ = false;
400
39
                        return;
401
39
                    }
402
42.0k
                    uint64_t val = binary::big_to_native<uint64_t>(buf, sizeof(buf));
403
42.0k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
404
42.0k
                    more_ = !cursor_mode_;
405
42.0k
                    break;
406
42.0k
                }
407
408
420k
                case jsoncons::msgpack::msgpack_type::int8_type: 
409
420k
                {
410
420k
                    uint8_t buf[sizeof(int8_t)];
411
420k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
412
7
                    {
413
7
                        ec = msgpack_errc::unexpected_eof;
414
7
                        more_ = false;
415
7
                        return;
416
7
                    }
417
420k
                    int8_t val = binary::big_to_native<int8_t>(buf, sizeof(buf));
418
420k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
419
420k
                    more_ = !cursor_mode_;
420
420k
                    break;
421
420k
                }
422
423
121k
                case jsoncons::msgpack::msgpack_type::int16_type: 
424
121k
                {
425
121k
                    uint8_t buf[sizeof(int16_t)];
426
121k
                    if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
427
21
                    {
428
21
                        ec = msgpack_errc::unexpected_eof;
429
21
                        more_ = false;
430
21
                        return;
431
21
                    }
432
121k
                    int16_t val = binary::big_to_native<int16_t>(buf, sizeof(buf));
433
121k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
434
121k
                    more_ = !cursor_mode_;
435
121k
                    break;
436
121k
                }
437
438
59.3k
                case jsoncons::msgpack::msgpack_type::int32_type: 
439
59.3k
                {
440
59.3k
                    uint8_t buf[sizeof(int32_t)];
441
59.3k
                    if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
442
30
                    {
443
30
                        ec = msgpack_errc::unexpected_eof;
444
30
                        more_ = false;
445
30
                        return;
446
30
                    }
447
59.3k
                    int32_t val = binary::big_to_native<int32_t>(buf, sizeof(buf));
448
59.3k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
449
59.3k
                    more_ = !cursor_mode_;
450
59.3k
                    break;
451
59.3k
                }
452
453
35.3k
                case jsoncons::msgpack::msgpack_type::int64_type: 
454
35.3k
                {
455
35.3k
                    uint8_t buf[sizeof(int64_t)];
456
35.3k
                    if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t))
457
43
                    {
458
43
                        ec = msgpack_errc::unexpected_eof;
459
43
                        more_ = false;
460
43
                        return;
461
43
                    }
462
35.3k
                    int64_t val = binary::big_to_native<int64_t>(buf, sizeof(buf));
463
35.3k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
464
35.3k
                    more_ = !cursor_mode_;
465
35.3k
                    break;
466
35.3k
                }
467
468
3.71k
                case jsoncons::msgpack::msgpack_type::str8_type: 
469
5.94k
                case jsoncons::msgpack::msgpack_type::str16_type: 
470
17.1k
                case jsoncons::msgpack::msgpack_type::str32_type: 
471
17.1k
                {
472
17.1k
                    std::size_t len = get_size(type, ec);
473
17.1k
                    if (!more_)
474
110
                    {
475
110
                        return;
476
110
                    }
477
478
17.0k
                    auto data = source_.read_span(len, bytes_buffer_);
479
17.0k
                    if (data.size() != static_cast<std::size_t>(len))
480
469
                    {
481
469
                        ec = msgpack_errc::unexpected_eof;
482
469
                        more_ = false;
483
469
                        return;
484
469
                    }
485
486
16.5k
                    auto result = unicode_traits::validate(data.data(), data.size());
487
16.5k
                    if (result.ec != unicode_traits::unicode_errc())
488
218
                    {
489
218
                        ec = msgpack_errc::invalid_utf8_text_string;
490
218
                        more_ = false;
491
218
                        return;
492
218
                    }
493
16.3k
                    visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
494
16.3k
                        semantic_tag::none, *this, ec);
495
16.3k
                    more_ = !cursor_mode_;
496
16.3k
                    break;
497
16.5k
                }
498
499
1.12M
                case jsoncons::msgpack::msgpack_type::bin8_type: 
500
1.15M
                case jsoncons::msgpack::msgpack_type::bin16_type: 
501
1.16M
                case jsoncons::msgpack::msgpack_type::bin32_type: 
502
1.16M
                {
503
1.16M
                    std::size_t len = get_size(type,ec);
504
1.16M
                    if (!more_)
505
174
                    {
506
174
                        return;
507
174
                    }
508
1.15M
                    auto data = source_.read_span(len, bytes_buffer_);
509
1.15M
                    if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
510
615
                    {
511
615
                        ec = msgpack_errc::unexpected_eof;
512
615
                        more_ = false;
513
615
                        return;
514
615
                    }
515
516
1.15M
                    visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
517
1.15M
                        semantic_tag::none, 
518
1.15M
                        *this,
519
1.15M
                        ec);
520
1.15M
                    more_ = !cursor_mode_;
521
1.15M
                    break;
522
1.15M
                }
523
1.85M
                case jsoncons::msgpack::msgpack_type::fixext1_type: 
524
4.26M
                case jsoncons::msgpack::msgpack_type::fixext2_type: 
525
4.38M
                case jsoncons::msgpack::msgpack_type::fixext4_type: 
526
4.54M
                case jsoncons::msgpack::msgpack_type::fixext8_type: 
527
4.66M
                case jsoncons::msgpack::msgpack_type::fixext16_type: 
528
4.89M
                case jsoncons::msgpack::msgpack_type::ext8_type: 
529
4.89M
                case jsoncons::msgpack::msgpack_type::ext16_type: 
530
4.93M
                case jsoncons::msgpack::msgpack_type::ext32_type: 
531
4.93M
                {
532
4.93M
                    std::size_t len = get_size(type,ec);
533
4.93M
                    if (!more_)
534
149
                    {
535
149
                        return;
536
149
                    }
537
538
                    // type
539
4.93M
                    uint8_t buf[sizeof(int8_t)];
540
4.93M
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
541
262
                    {
542
262
                        ec = msgpack_errc::unexpected_eof;
543
262
                        more_ = false;
544
262
                        return;
545
262
                    }
546
547
4.93M
                    int8_t ext_type = binary::big_to_native<int8_t>(buf, sizeof(buf));
548
549
4.93M
                    bool is_timestamp = false; 
550
4.93M
                    if (ext_type == -1)
551
379k
                    {
552
379k
                        is_timestamp = true;;
553
379k
                    }
554
555
                    // payload
556
4.93M
                    if (is_timestamp && len == 4)
557
9.67k
                    {
558
9.67k
                        uint8_t buf32[sizeof(uint32_t)];
559
9.67k
                        if (source_.read(buf32, sizeof(uint32_t)) != sizeof(uint32_t))
560
21
                        {
561
21
                            ec = msgpack_errc::unexpected_eof;
562
21
                            more_ = false;
563
21
                            return;
564
21
                        }
565
9.65k
                        uint32_t val = binary::big_to_native<uint32_t>(buf32, sizeof(buf32));
566
9.65k
                        visitor.uint64_value(val, semantic_tag::epoch_second, *this, ec);
567
9.65k
                        more_ = !cursor_mode_;
568
9.65k
                    }
569
4.92M
                    else if (is_timestamp && len == 8)
570
141k
                    {
571
141k
                        uint8_t buf64[sizeof(uint64_t)];
572
141k
                        if (source_.read(buf64, sizeof(uint64_t)) != sizeof(uint64_t))
573
71
                        {
574
71
                            ec = msgpack_errc::unexpected_eof;
575
71
                            more_ = false;
576
71
                            return;
577
71
                        }
578
141k
                        uint64_t data64 = binary::big_to_native<uint64_t>(buf64, sizeof(buf64));
579
141k
                        uint64_t sec = data64 & 0x00000003ffffffffL;
580
141k
                        uint64_t nsec = data64 >> 34;
581
582
141k
                        bigint nano(sec);
583
141k
                        nano *= uint64_t(nanos_in_second);
584
141k
                        nano += nsec;
585
141k
                        text_buffer_.clear();
586
141k
                        nano.append_to_buffer(text_buffer_);
587
141k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
588
141k
                        more_ = !cursor_mode_;
589
141k
                        if (!more_) return;
590
141k
                    }
591
4.78M
                    else if (is_timestamp && len == 12)
592
220k
                    {
593
220k
                        uint8_t buf1[sizeof(uint32_t)];
594
220k
                        if (source_.read(buf1, sizeof(uint32_t)) != sizeof(uint32_t))
595
36
                        {
596
36
                            ec = msgpack_errc::unexpected_eof;
597
36
                            more_ = false;
598
36
                            return;
599
36
                        }
600
220k
                        uint32_t nsec = binary::big_to_native<uint32_t>(buf1, sizeof(buf1));
601
602
220k
                        uint8_t buf2[sizeof(int64_t)];
603
220k
                        if (source_.read(buf2, sizeof(int64_t)) != sizeof(int64_t))
604
61
                        {
605
61
                            ec = msgpack_errc::unexpected_eof;
606
61
                            more_ = false;
607
61
                            return;
608
61
                        }
609
220k
                        int64_t sec = binary::big_to_native<int64_t>(buf2, sizeof(buf2));
610
611
220k
                        bigint nano(sec);
612
613
220k
                        nano *= uint64_t(nanos_in_second);
614
615
220k
                        if (nano < 0)
616
124k
                        {
617
124k
                            nano -= nsec;
618
124k
                        }
619
95.7k
                        else
620
95.7k
                        {
621
95.7k
                            nano += nsec;
622
95.7k
                        }
623
624
220k
                        text_buffer_.clear();
625
220k
                        nano.append_to_buffer(text_buffer_);
626
220k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
627
220k
                        more_ = !cursor_mode_;
628
220k
                        if (!more_) return;
629
220k
                    }
630
4.55M
                    else
631
4.55M
                    {
632
4.55M
                        auto data = source_.read_span(len, bytes_buffer_);
633
4.55M
                        if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
634
918
                        {
635
918
                            ec = msgpack_errc::unexpected_eof;
636
918
                            more_ = false;
637
918
                            return;
638
918
                        }
639
640
4.55M
                        visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
641
4.55M
                                                          static_cast<uint8_t>(ext_type), 
642
4.55M
                                                          *this,
643
4.55M
                                                          ec);
644
4.55M
                        more_ = !cursor_mode_;
645
4.55M
                    }
646
4.93M
                    break;
647
4.93M
                }
648
649
4.93M
                case jsoncons::msgpack::msgpack_type::array16_type: 
650
40.8k
                case jsoncons::msgpack::msgpack_type::array32_type: 
651
40.8k
                {
652
40.8k
                    begin_array(visitor,type,ec);
653
40.8k
                    break;
654
26.6k
                }
655
656
66.7k
                case jsoncons::msgpack::msgpack_type::map16_type : 
657
74.9k
                case jsoncons::msgpack::msgpack_type::map32_type : 
658
74.9k
                {
659
74.9k
                    begin_object(visitor, type, ec);
660
74.9k
                    break;
661
66.7k
                }
662
663
55
                default:
664
55
                {
665
55
                    ec = msgpack_errc::unknown_type;
666
55
                    more_ = false;
667
55
                    return;
668
66.7k
                }
669
79.6M
            }
670
79.6M
        }
671
317M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::read_item(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
234
76.2M
    {
235
76.2M
        if (source_.is_error())
236
0
        {
237
0
            ec = msgpack_errc::source_error;
238
0
            more_ = false;
239
0
            return;
240
0
        }   
241
242
76.2M
        uint8_t type;
243
76.2M
        if (source_.read(&type, 1) == 0)
244
3.66k
        {
245
3.66k
            ec = msgpack_errc::unexpected_eof;
246
3.66k
            more_ = false;
247
3.66k
            return;
248
3.66k
        }
249
250
76.2M
        if (type <= 0xbf)
251
58.5M
        {
252
58.5M
            if (type <= 0x7f) 
253
37.3M
            {
254
                // positive fixint
255
37.3M
                visitor.uint64_value(type, semantic_tag::none, *this, ec);
256
37.3M
                more_ = !cursor_mode_;
257
37.3M
            }
258
21.2M
            else if (type <= 0x8f) 
259
1.81M
            {
260
1.81M
                begin_object(visitor,type,ec); // fixmap
261
1.81M
            }
262
19.3M
            else if (type <= 0x9f) 
263
2.03M
            {
264
2.03M
                begin_array(visitor,type,ec); // fixarray
265
2.03M
            }
266
17.3M
            else 
267
17.3M
            {
268
                // fixstr
269
17.3M
                const size_t len = type & 0x1f;
270
271
17.3M
                auto data = source_.read_span(len, bytes_buffer_);
272
17.3M
                if (data.size() != static_cast<std::size_t>(len))
273
64
                {
274
64
                    ec = msgpack_errc::unexpected_eof;
275
64
                    more_ = false;
276
64
                    return;
277
64
                }
278
279
17.3M
                auto result = unicode_traits::validate(data.data(), data.size());
280
17.3M
                if (result.ec != unicode_traits::unicode_errc())
281
220
                {
282
220
                    ec = msgpack_errc::invalid_utf8_text_string;
283
220
                    more_ = false;
284
220
                    return;
285
220
                }
286
17.3M
                visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
287
17.3M
                    semantic_tag::none, *this, ec);
288
17.3M
                more_ = !cursor_mode_;
289
17.3M
            }
290
58.5M
        }
291
17.6M
        else if (type >= 0xe0) 
292
10.7M
        {
293
            // negative fixint
294
10.7M
            visitor.int64_value(static_cast<int8_t>(type), semantic_tag::none, *this, ec);
295
10.7M
            more_ = !cursor_mode_;
296
10.7M
        }
297
6.91M
        else
298
6.91M
        {
299
6.91M
            switch (type)
300
6.91M
            {
301
1.18M
                case jsoncons::msgpack::msgpack_type::nil_type: 
302
1.18M
                {
303
1.18M
                    visitor.null_value(semantic_tag::none, *this, ec);
304
1.18M
                    more_ = !cursor_mode_;
305
1.18M
                    break;
306
0
                }
307
3.73M
                case jsoncons::msgpack::msgpack_type::true_type:
308
3.73M
                {
309
3.73M
                    visitor.bool_value(true, semantic_tag::none, *this, ec);
310
3.73M
                    more_ = !cursor_mode_;
311
3.73M
                    break;
312
0
                }
313
345k
                case jsoncons::msgpack::msgpack_type::false_type:
314
345k
                {
315
345k
                    visitor.bool_value(false, semantic_tag::none, *this, ec);
316
345k
                    more_ = !cursor_mode_;
317
345k
                    break;
318
0
                }
319
367k
                case jsoncons::msgpack::msgpack_type::float32_type: 
320
367k
                {
321
367k
                    uint8_t buf[sizeof(float)];
322
367k
                    if (source_.read(buf, sizeof(float)) != sizeof(float))
323
52
                    {
324
52
                        ec = msgpack_errc::unexpected_eof;
325
52
                        more_ = false;
326
52
                        return;
327
52
                    }
328
367k
                    float val = binary::big_to_native<float>(buf, sizeof(buf));
329
367k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
330
367k
                    more_ = !cursor_mode_;
331
367k
                    break;
332
367k
                }
333
334
59.1k
                case jsoncons::msgpack::msgpack_type::float64_type: 
335
59.1k
                {
336
59.1k
                    uint8_t buf[sizeof(double)];
337
59.1k
                    if (source_.read(buf, sizeof(double)) != sizeof(double))
338
34
                    {
339
34
                        ec = msgpack_errc::unexpected_eof;
340
34
                        more_ = false;
341
34
                        return;
342
34
                    }
343
59.1k
                    double val = binary::big_to_native<double>(buf, sizeof(buf));
344
59.1k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
345
59.1k
                    more_ = !cursor_mode_;
346
59.1k
                    break;
347
59.1k
                }
348
349
9.57k
                case jsoncons::msgpack::msgpack_type::uint8_type: 
350
9.57k
                {
351
9.57k
                    uint8_t b;
352
9.57k
                    if (source_.read(&b, 1) == 0)
353
8
                    {
354
8
                        ec = msgpack_errc::unexpected_eof;
355
8
                        more_ = false;
356
8
                        return;
357
8
                    }
358
9.56k
                    visitor.uint64_value(b, semantic_tag::none, *this, ec);
359
9.56k
                    more_ = !cursor_mode_;
360
9.56k
                    break;
361
9.57k
                }
362
363
894
                case jsoncons::msgpack::msgpack_type::uint16_type: 
364
894
                {
365
894
                    uint8_t buf[sizeof(uint16_t)];
366
894
                    if (source_.read(buf, sizeof(uint16_t)) !=sizeof(uint16_t)) 
367
7
                    {
368
7
                        ec = msgpack_errc::unexpected_eof;
369
7
                        more_ = false;
370
7
                        return;
371
7
                    }
372
887
                    uint16_t val = binary::big_to_native<uint16_t>(buf, sizeof(buf));
373
887
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
374
887
                    more_ = !cursor_mode_;
375
887
                    break;
376
894
                }
377
378
644
                case jsoncons::msgpack::msgpack_type::uint32_type: 
379
644
                {
380
644
                    uint8_t buf[sizeof(uint32_t)];
381
644
                    if (source_.read(buf, sizeof(uint32_t)) != sizeof(uint32_t))
382
9
                    {
383
9
                        ec = msgpack_errc::unexpected_eof;
384
9
                        more_ = false;
385
9
                        return;
386
9
                    }
387
635
                    uint32_t val = binary::big_to_native<uint32_t>(buf, sizeof(buf));
388
635
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
389
635
                    more_ = !cursor_mode_;
390
635
                    break;
391
644
                }
392
393
29.4k
                case jsoncons::msgpack::msgpack_type::uint64_type: 
394
29.4k
                {
395
29.4k
                    uint8_t buf[sizeof(uint64_t)];
396
29.4k
                    if (source_.read(buf, sizeof(uint64_t)) != sizeof(uint64_t))
397
10
                    {
398
10
                        ec = msgpack_errc::unexpected_eof;
399
10
                        more_ = false;
400
10
                        return;
401
10
                    }
402
29.4k
                    uint64_t val = binary::big_to_native<uint64_t>(buf, sizeof(buf));
403
29.4k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
404
29.4k
                    more_ = !cursor_mode_;
405
29.4k
                    break;
406
29.4k
                }
407
408
73.1k
                case jsoncons::msgpack::msgpack_type::int8_type: 
409
73.1k
                {
410
73.1k
                    uint8_t buf[sizeof(int8_t)];
411
73.1k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
412
3
                    {
413
3
                        ec = msgpack_errc::unexpected_eof;
414
3
                        more_ = false;
415
3
                        return;
416
3
                    }
417
73.1k
                    int8_t val = binary::big_to_native<int8_t>(buf, sizeof(buf));
418
73.1k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
419
73.1k
                    more_ = !cursor_mode_;
420
73.1k
                    break;
421
73.1k
                }
422
423
12.8k
                case jsoncons::msgpack::msgpack_type::int16_type: 
424
12.8k
                {
425
12.8k
                    uint8_t buf[sizeof(int16_t)];
426
12.8k
                    if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
427
8
                    {
428
8
                        ec = msgpack_errc::unexpected_eof;
429
8
                        more_ = false;
430
8
                        return;
431
8
                    }
432
12.8k
                    int16_t val = binary::big_to_native<int16_t>(buf, sizeof(buf));
433
12.8k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
434
12.8k
                    more_ = !cursor_mode_;
435
12.8k
                    break;
436
12.8k
                }
437
438
27.4k
                case jsoncons::msgpack::msgpack_type::int32_type: 
439
27.4k
                {
440
27.4k
                    uint8_t buf[sizeof(int32_t)];
441
27.4k
                    if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
442
9
                    {
443
9
                        ec = msgpack_errc::unexpected_eof;
444
9
                        more_ = false;
445
9
                        return;
446
9
                    }
447
27.4k
                    int32_t val = binary::big_to_native<int32_t>(buf, sizeof(buf));
448
27.4k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
449
27.4k
                    more_ = !cursor_mode_;
450
27.4k
                    break;
451
27.4k
                }
452
453
1.40k
                case jsoncons::msgpack::msgpack_type::int64_type: 
454
1.40k
                {
455
1.40k
                    uint8_t buf[sizeof(int64_t)];
456
1.40k
                    if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t))
457
11
                    {
458
11
                        ec = msgpack_errc::unexpected_eof;
459
11
                        more_ = false;
460
11
                        return;
461
11
                    }
462
1.39k
                    int64_t val = binary::big_to_native<int64_t>(buf, sizeof(buf));
463
1.39k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
464
1.39k
                    more_ = !cursor_mode_;
465
1.39k
                    break;
466
1.40k
                }
467
468
959
                case jsoncons::msgpack::msgpack_type::str8_type: 
469
1.22k
                case jsoncons::msgpack::msgpack_type::str16_type: 
470
10.0k
                case jsoncons::msgpack::msgpack_type::str32_type: 
471
10.0k
                {
472
10.0k
                    std::size_t len = get_size(type, ec);
473
10.0k
                    if (!more_)
474
19
                    {
475
19
                        return;
476
19
                    }
477
478
10.0k
                    auto data = source_.read_span(len, bytes_buffer_);
479
10.0k
                    if (data.size() != static_cast<std::size_t>(len))
480
87
                    {
481
87
                        ec = msgpack_errc::unexpected_eof;
482
87
                        more_ = false;
483
87
                        return;
484
87
                    }
485
486
9.91k
                    auto result = unicode_traits::validate(data.data(), data.size());
487
9.91k
                    if (result.ec != unicode_traits::unicode_errc())
488
35
                    {
489
35
                        ec = msgpack_errc::invalid_utf8_text_string;
490
35
                        more_ = false;
491
35
                        return;
492
35
                    }
493
9.87k
                    visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
494
9.87k
                        semantic_tag::none, *this, ec);
495
9.87k
                    more_ = !cursor_mode_;
496
9.87k
                    break;
497
9.91k
                }
498
499
452k
                case jsoncons::msgpack::msgpack_type::bin8_type: 
500
473k
                case jsoncons::msgpack::msgpack_type::bin16_type: 
501
473k
                case jsoncons::msgpack::msgpack_type::bin32_type: 
502
473k
                {
503
473k
                    std::size_t len = get_size(type,ec);
504
473k
                    if (!more_)
505
36
                    {
506
36
                        return;
507
36
                    }
508
473k
                    auto data = source_.read_span(len, bytes_buffer_);
509
473k
                    if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
510
136
                    {
511
136
                        ec = msgpack_errc::unexpected_eof;
512
136
                        more_ = false;
513
136
                        return;
514
136
                    }
515
516
473k
                    visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
517
473k
                        semantic_tag::none, 
518
473k
                        *this,
519
473k
                        ec);
520
473k
                    more_ = !cursor_mode_;
521
473k
                    break;
522
473k
                }
523
401k
                case jsoncons::msgpack::msgpack_type::fixext1_type: 
524
413k
                case jsoncons::msgpack::msgpack_type::fixext2_type: 
525
418k
                case jsoncons::msgpack::msgpack_type::fixext4_type: 
526
487k
                case jsoncons::msgpack::msgpack_type::fixext8_type: 
527
502k
                case jsoncons::msgpack::msgpack_type::fixext16_type: 
528
523k
                case jsoncons::msgpack::msgpack_type::ext8_type: 
529
526k
                case jsoncons::msgpack::msgpack_type::ext16_type: 
530
546k
                case jsoncons::msgpack::msgpack_type::ext32_type: 
531
546k
                {
532
546k
                    std::size_t len = get_size(type,ec);
533
546k
                    if (!more_)
534
38
                    {
535
38
                        return;
536
38
                    }
537
538
                    // type
539
546k
                    uint8_t buf[sizeof(int8_t)];
540
546k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
541
50
                    {
542
50
                        ec = msgpack_errc::unexpected_eof;
543
50
                        more_ = false;
544
50
                        return;
545
50
                    }
546
547
546k
                    int8_t ext_type = binary::big_to_native<int8_t>(buf, sizeof(buf));
548
549
546k
                    bool is_timestamp = false; 
550
546k
                    if (ext_type == -1)
551
109k
                    {
552
109k
                        is_timestamp = true;;
553
109k
                    }
554
555
                    // payload
556
546k
                    if (is_timestamp && len == 4)
557
1.35k
                    {
558
1.35k
                        uint8_t buf32[sizeof(uint32_t)];
559
1.35k
                        if (source_.read(buf32, sizeof(uint32_t)) != sizeof(uint32_t))
560
6
                        {
561
6
                            ec = msgpack_errc::unexpected_eof;
562
6
                            more_ = false;
563
6
                            return;
564
6
                        }
565
1.35k
                        uint32_t val = binary::big_to_native<uint32_t>(buf32, sizeof(buf32));
566
1.35k
                        visitor.uint64_value(val, semantic_tag::epoch_second, *this, ec);
567
1.35k
                        more_ = !cursor_mode_;
568
1.35k
                    }
569
545k
                    else if (is_timestamp && len == 8)
570
63.7k
                    {
571
63.7k
                        uint8_t buf64[sizeof(uint64_t)];
572
63.7k
                        if (source_.read(buf64, sizeof(uint64_t)) != sizeof(uint64_t))
573
27
                        {
574
27
                            ec = msgpack_errc::unexpected_eof;
575
27
                            more_ = false;
576
27
                            return;
577
27
                        }
578
63.6k
                        uint64_t data64 = binary::big_to_native<uint64_t>(buf64, sizeof(buf64));
579
63.6k
                        uint64_t sec = data64 & 0x00000003ffffffffL;
580
63.6k
                        uint64_t nsec = data64 >> 34;
581
582
63.6k
                        bigint nano(sec);
583
63.6k
                        nano *= uint64_t(nanos_in_second);
584
63.6k
                        nano += nsec;
585
63.6k
                        text_buffer_.clear();
586
63.6k
                        nano.append_to_buffer(text_buffer_);
587
63.6k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
588
63.6k
                        more_ = !cursor_mode_;
589
63.6k
                        if (!more_) return;
590
63.6k
                    }
591
481k
                    else if (is_timestamp && len == 12)
592
41.0k
                    {
593
41.0k
                        uint8_t buf1[sizeof(uint32_t)];
594
41.0k
                        if (source_.read(buf1, sizeof(uint32_t)) != sizeof(uint32_t))
595
14
                        {
596
14
                            ec = msgpack_errc::unexpected_eof;
597
14
                            more_ = false;
598
14
                            return;
599
14
                        }
600
41.0k
                        uint32_t nsec = binary::big_to_native<uint32_t>(buf1, sizeof(buf1));
601
602
41.0k
                        uint8_t buf2[sizeof(int64_t)];
603
41.0k
                        if (source_.read(buf2, sizeof(int64_t)) != sizeof(int64_t))
604
23
                        {
605
23
                            ec = msgpack_errc::unexpected_eof;
606
23
                            more_ = false;
607
23
                            return;
608
23
                        }
609
41.0k
                        int64_t sec = binary::big_to_native<int64_t>(buf2, sizeof(buf2));
610
611
41.0k
                        bigint nano(sec);
612
613
41.0k
                        nano *= uint64_t(nanos_in_second);
614
615
41.0k
                        if (nano < 0)
616
25.4k
                        {
617
25.4k
                            nano -= nsec;
618
25.4k
                        }
619
15.6k
                        else
620
15.6k
                        {
621
15.6k
                            nano += nsec;
622
15.6k
                        }
623
624
41.0k
                        text_buffer_.clear();
625
41.0k
                        nano.append_to_buffer(text_buffer_);
626
41.0k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
627
41.0k
                        more_ = !cursor_mode_;
628
41.0k
                        if (!more_) return;
629
41.0k
                    }
630
440k
                    else
631
440k
                    {
632
440k
                        auto data = source_.read_span(len, bytes_buffer_);
633
440k
                        if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
634
189
                        {
635
189
                            ec = msgpack_errc::unexpected_eof;
636
189
                            more_ = false;
637
189
                            return;
638
189
                        }
639
640
440k
                        visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
641
440k
                                                          static_cast<uint8_t>(ext_type), 
642
440k
                                                          *this,
643
440k
                                                          ec);
644
440k
                        more_ = !cursor_mode_;
645
440k
                    }
646
546k
                    break;
647
546k
                }
648
649
546k
                case jsoncons::msgpack::msgpack_type::array16_type: 
650
6.41k
                case jsoncons::msgpack::msgpack_type::array32_type: 
651
6.41k
                {
652
6.41k
                    begin_array(visitor,type,ec);
653
6.41k
                    break;
654
5.18k
                }
655
656
20.4k
                case jsoncons::msgpack::msgpack_type::map16_type : 
657
22.0k
                case jsoncons::msgpack::msgpack_type::map32_type : 
658
22.0k
                {
659
22.0k
                    begin_object(visitor, type, ec);
660
22.0k
                    break;
661
20.4k
                }
662
663
6
                default:
664
6
                {
665
6
                    ec = msgpack_errc::unknown_type;
666
6
                    more_ = false;
667
6
                    return;
668
20.4k
                }
669
6.91M
            }
670
6.91M
        }
671
76.2M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::read_item(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
234
158M
    {
235
158M
        if (source_.is_error())
236
0
        {
237
0
            ec = msgpack_errc::source_error;
238
0
            more_ = false;
239
0
            return;
240
0
        }   
241
242
158M
        uint8_t type;
243
158M
        if (source_.read(&type, 1) == 0)
244
10.3k
        {
245
10.3k
            ec = msgpack_errc::unexpected_eof;
246
10.3k
            more_ = false;
247
10.3k
            return;
248
10.3k
        }
249
250
158M
        if (type <= 0xbf)
251
75.1M
        {
252
75.1M
            if (type <= 0x7f) 
253
57.3M
            {
254
                // positive fixint
255
57.3M
                visitor.uint64_value(type, semantic_tag::none, *this, ec);
256
57.3M
                more_ = !cursor_mode_;
257
57.3M
            }
258
17.7M
            else if (type <= 0x8f) 
259
2.06M
            {
260
2.06M
                begin_object(visitor,type,ec); // fixmap
261
2.06M
            }
262
15.7M
            else if (type <= 0x9f) 
263
7.24M
            {
264
7.24M
                begin_array(visitor,type,ec); // fixarray
265
7.24M
            }
266
8.47M
            else 
267
8.47M
            {
268
                // fixstr
269
8.47M
                const size_t len = type & 0x1f;
270
271
8.47M
                auto data = source_.read_span(len, bytes_buffer_);
272
8.47M
                if (data.size() != static_cast<std::size_t>(len))
273
150
                {
274
150
                    ec = msgpack_errc::unexpected_eof;
275
150
                    more_ = false;
276
150
                    return;
277
150
                }
278
279
8.47M
                auto result = unicode_traits::validate(data.data(), data.size());
280
8.47M
                if (result.ec != unicode_traits::unicode_errc())
281
530
                {
282
530
                    ec = msgpack_errc::invalid_utf8_text_string;
283
530
                    more_ = false;
284
530
                    return;
285
530
                }
286
8.47M
                visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
287
8.47M
                    semantic_tag::none, *this, ec);
288
8.47M
                more_ = !cursor_mode_;
289
8.47M
            }
290
75.1M
        }
291
83.4M
        else if (type >= 0xe0) 
292
14.0M
        {
293
            // negative fixint
294
14.0M
            visitor.int64_value(static_cast<int8_t>(type), semantic_tag::none, *this, ec);
295
14.0M
            more_ = !cursor_mode_;
296
14.0M
        }
297
69.4M
        else
298
69.4M
        {
299
69.4M
            switch (type)
300
69.4M
            {
301
1.78M
                case jsoncons::msgpack::msgpack_type::nil_type: 
302
1.78M
                {
303
1.78M
                    visitor.null_value(semantic_tag::none, *this, ec);
304
1.78M
                    more_ = !cursor_mode_;
305
1.78M
                    break;
306
0
                }
307
10.7M
                case jsoncons::msgpack::msgpack_type::true_type:
308
10.7M
                {
309
10.7M
                    visitor.bool_value(true, semantic_tag::none, *this, ec);
310
10.7M
                    more_ = !cursor_mode_;
311
10.7M
                    break;
312
0
                }
313
51.4M
                case jsoncons::msgpack::msgpack_type::false_type:
314
51.4M
                {
315
51.4M
                    visitor.bool_value(false, semantic_tag::none, *this, ec);
316
51.4M
                    more_ = !cursor_mode_;
317
51.4M
                    break;
318
0
                }
319
224k
                case jsoncons::msgpack::msgpack_type::float32_type: 
320
224k
                {
321
224k
                    uint8_t buf[sizeof(float)];
322
224k
                    if (source_.read(buf, sizeof(float)) != sizeof(float))
323
48
                    {
324
48
                        ec = msgpack_errc::unexpected_eof;
325
48
                        more_ = false;
326
48
                        return;
327
48
                    }
328
224k
                    float val = binary::big_to_native<float>(buf, sizeof(buf));
329
224k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
330
224k
                    more_ = !cursor_mode_;
331
224k
                    break;
332
224k
                }
333
334
92.9k
                case jsoncons::msgpack::msgpack_type::float64_type: 
335
92.9k
                {
336
92.9k
                    uint8_t buf[sizeof(double)];
337
92.9k
                    if (source_.read(buf, sizeof(double)) != sizeof(double))
338
30
                    {
339
30
                        ec = msgpack_errc::unexpected_eof;
340
30
                        more_ = false;
341
30
                        return;
342
30
                    }
343
92.9k
                    double val = binary::big_to_native<double>(buf, sizeof(buf));
344
92.9k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
345
92.9k
                    more_ = !cursor_mode_;
346
92.9k
                    break;
347
92.9k
                }
348
349
39.6k
                case jsoncons::msgpack::msgpack_type::uint8_type: 
350
39.6k
                {
351
39.6k
                    uint8_t b;
352
39.6k
                    if (source_.read(&b, 1) == 0)
353
4
                    {
354
4
                        ec = msgpack_errc::unexpected_eof;
355
4
                        more_ = false;
356
4
                        return;
357
4
                    }
358
39.6k
                    visitor.uint64_value(b, semantic_tag::none, *this, ec);
359
39.6k
                    more_ = !cursor_mode_;
360
39.6k
                    break;
361
39.6k
                }
362
363
403k
                case jsoncons::msgpack::msgpack_type::uint16_type: 
364
403k
                {
365
403k
                    uint8_t buf[sizeof(uint16_t)];
366
403k
                    if (source_.read(buf, sizeof(uint16_t)) !=sizeof(uint16_t)) 
367
9
                    {
368
9
                        ec = msgpack_errc::unexpected_eof;
369
9
                        more_ = false;
370
9
                        return;
371
9
                    }
372
403k
                    uint16_t val = binary::big_to_native<uint16_t>(buf, sizeof(buf));
373
403k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
374
403k
                    more_ = !cursor_mode_;
375
403k
                    break;
376
403k
                }
377
378
74.4k
                case jsoncons::msgpack::msgpack_type::uint32_type: 
379
74.4k
                {
380
74.4k
                    uint8_t buf[sizeof(uint32_t)];
381
74.4k
                    if (source_.read(buf, sizeof(uint32_t)) != sizeof(uint32_t))
382
10
                    {
383
10
                        ec = msgpack_errc::unexpected_eof;
384
10
                        more_ = false;
385
10
                        return;
386
10
                    }
387
74.4k
                    uint32_t val = binary::big_to_native<uint32_t>(buf, sizeof(buf));
388
74.4k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
389
74.4k
                    more_ = !cursor_mode_;
390
74.4k
                    break;
391
74.4k
                }
392
393
9.59k
                case jsoncons::msgpack::msgpack_type::uint64_type: 
394
9.59k
                {
395
9.59k
                    uint8_t buf[sizeof(uint64_t)];
396
9.59k
                    if (source_.read(buf, sizeof(uint64_t)) != sizeof(uint64_t))
397
18
                    {
398
18
                        ec = msgpack_errc::unexpected_eof;
399
18
                        more_ = false;
400
18
                        return;
401
18
                    }
402
9.58k
                    uint64_t val = binary::big_to_native<uint64_t>(buf, sizeof(buf));
403
9.58k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
404
9.58k
                    more_ = !cursor_mode_;
405
9.58k
                    break;
406
9.59k
                }
407
408
344k
                case jsoncons::msgpack::msgpack_type::int8_type: 
409
344k
                {
410
344k
                    uint8_t buf[sizeof(int8_t)];
411
344k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
412
3
                    {
413
3
                        ec = msgpack_errc::unexpected_eof;
414
3
                        more_ = false;
415
3
                        return;
416
3
                    }
417
344k
                    int8_t val = binary::big_to_native<int8_t>(buf, sizeof(buf));
418
344k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
419
344k
                    more_ = !cursor_mode_;
420
344k
                    break;
421
344k
                }
422
423
102k
                case jsoncons::msgpack::msgpack_type::int16_type: 
424
102k
                {
425
102k
                    uint8_t buf[sizeof(int16_t)];
426
102k
                    if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
427
9
                    {
428
9
                        ec = msgpack_errc::unexpected_eof;
429
9
                        more_ = false;
430
9
                        return;
431
9
                    }
432
102k
                    int16_t val = binary::big_to_native<int16_t>(buf, sizeof(buf));
433
102k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
434
102k
                    more_ = !cursor_mode_;
435
102k
                    break;
436
102k
                }
437
438
28.7k
                case jsoncons::msgpack::msgpack_type::int32_type: 
439
28.7k
                {
440
28.7k
                    uint8_t buf[sizeof(int32_t)];
441
28.7k
                    if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
442
11
                    {
443
11
                        ec = msgpack_errc::unexpected_eof;
444
11
                        more_ = false;
445
11
                        return;
446
11
                    }
447
28.7k
                    int32_t val = binary::big_to_native<int32_t>(buf, sizeof(buf));
448
28.7k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
449
28.7k
                    more_ = !cursor_mode_;
450
28.7k
                    break;
451
28.7k
                }
452
453
30.6k
                case jsoncons::msgpack::msgpack_type::int64_type: 
454
30.6k
                {
455
30.6k
                    uint8_t buf[sizeof(int64_t)];
456
30.6k
                    if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t))
457
23
                    {
458
23
                        ec = msgpack_errc::unexpected_eof;
459
23
                        more_ = false;
460
23
                        return;
461
23
                    }
462
30.6k
                    int64_t val = binary::big_to_native<int64_t>(buf, sizeof(buf));
463
30.6k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
464
30.6k
                    more_ = !cursor_mode_;
465
30.6k
                    break;
466
30.6k
                }
467
468
2.07k
                case jsoncons::msgpack::msgpack_type::str8_type: 
469
3.75k
                case jsoncons::msgpack::msgpack_type::str16_type: 
470
5.79k
                case jsoncons::msgpack::msgpack_type::str32_type: 
471
5.79k
                {
472
5.79k
                    std::size_t len = get_size(type, ec);
473
5.79k
                    if (!more_)
474
72
                    {
475
72
                        return;
476
72
                    }
477
478
5.71k
                    auto data = source_.read_span(len, bytes_buffer_);
479
5.71k
                    if (data.size() != static_cast<std::size_t>(len))
480
333
                    {
481
333
                        ec = msgpack_errc::unexpected_eof;
482
333
                        more_ = false;
483
333
                        return;
484
333
                    }
485
486
5.38k
                    auto result = unicode_traits::validate(data.data(), data.size());
487
5.38k
                    if (result.ec != unicode_traits::unicode_errc())
488
116
                    {
489
116
                        ec = msgpack_errc::invalid_utf8_text_string;
490
116
                        more_ = false;
491
116
                        return;
492
116
                    }
493
5.26k
                    visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
494
5.26k
                        semantic_tag::none, *this, ec);
495
5.26k
                    more_ = !cursor_mode_;
496
5.26k
                    break;
497
5.38k
                }
498
499
232k
                case jsoncons::msgpack::msgpack_type::bin8_type: 
500
239k
                case jsoncons::msgpack::msgpack_type::bin16_type: 
501
241k
                case jsoncons::msgpack::msgpack_type::bin32_type: 
502
241k
                {
503
241k
                    std::size_t len = get_size(type,ec);
504
241k
                    if (!more_)
505
93
                    {
506
93
                        return;
507
93
                    }
508
240k
                    auto data = source_.read_span(len, bytes_buffer_);
509
240k
                    if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
510
413
                    {
511
413
                        ec = msgpack_errc::unexpected_eof;
512
413
                        more_ = false;
513
413
                        return;
514
413
                    }
515
516
240k
                    visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
517
240k
                        semantic_tag::none, 
518
240k
                        *this,
519
240k
                        ec);
520
240k
                    more_ = !cursor_mode_;
521
240k
                    break;
522
240k
                }
523
1.09M
                case jsoncons::msgpack::msgpack_type::fixext1_type: 
524
3.43M
                case jsoncons::msgpack::msgpack_type::fixext2_type: 
525
3.53M
                case jsoncons::msgpack::msgpack_type::fixext4_type: 
526
3.60M
                case jsoncons::msgpack::msgpack_type::fixext8_type: 
527
3.70M
                case jsoncons::msgpack::msgpack_type::fixext16_type: 
528
3.79M
                case jsoncons::msgpack::msgpack_type::ext8_type: 
529
3.79M
                case jsoncons::msgpack::msgpack_type::ext16_type: 
530
3.79M
                case jsoncons::msgpack::msgpack_type::ext32_type: 
531
3.79M
                {
532
3.79M
                    std::size_t len = get_size(type,ec);
533
3.79M
                    if (!more_)
534
85
                    {
535
85
                        return;
536
85
                    }
537
538
                    // type
539
3.79M
                    uint8_t buf[sizeof(int8_t)];
540
3.79M
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
541
149
                    {
542
149
                        ec = msgpack_errc::unexpected_eof;
543
149
                        more_ = false;
544
149
                        return;
545
149
                    }
546
547
3.79M
                    int8_t ext_type = binary::big_to_native<int8_t>(buf, sizeof(buf));
548
549
3.79M
                    bool is_timestamp = false; 
550
3.79M
                    if (ext_type == -1)
551
135k
                    {
552
135k
                        is_timestamp = true;;
553
135k
                    }
554
555
                    // payload
556
3.79M
                    if (is_timestamp && len == 4)
557
4.49k
                    {
558
4.49k
                        uint8_t buf32[sizeof(uint32_t)];
559
4.49k
                        if (source_.read(buf32, sizeof(uint32_t)) != sizeof(uint32_t))
560
10
                        {
561
10
                            ec = msgpack_errc::unexpected_eof;
562
10
                            more_ = false;
563
10
                            return;
564
10
                        }
565
4.48k
                        uint32_t val = binary::big_to_native<uint32_t>(buf32, sizeof(buf32));
566
4.48k
                        visitor.uint64_value(val, semantic_tag::epoch_second, *this, ec);
567
4.48k
                        more_ = !cursor_mode_;
568
4.48k
                    }
569
3.79M
                    else if (is_timestamp && len == 8)
570
53.8k
                    {
571
53.8k
                        uint8_t buf64[sizeof(uint64_t)];
572
53.8k
                        if (source_.read(buf64, sizeof(uint64_t)) != sizeof(uint64_t))
573
28
                        {
574
28
                            ec = msgpack_errc::unexpected_eof;
575
28
                            more_ = false;
576
28
                            return;
577
28
                        }
578
53.7k
                        uint64_t data64 = binary::big_to_native<uint64_t>(buf64, sizeof(buf64));
579
53.7k
                        uint64_t sec = data64 & 0x00000003ffffffffL;
580
53.7k
                        uint64_t nsec = data64 >> 34;
581
582
53.7k
                        bigint nano(sec);
583
53.7k
                        nano *= uint64_t(nanos_in_second);
584
53.7k
                        nano += nsec;
585
53.7k
                        text_buffer_.clear();
586
53.7k
                        nano.append_to_buffer(text_buffer_);
587
53.7k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
588
53.7k
                        more_ = !cursor_mode_;
589
53.7k
                        if (!more_) return;
590
53.7k
                    }
591
3.73M
                    else if (is_timestamp && len == 12)
592
73.2k
                    {
593
73.2k
                        uint8_t buf1[sizeof(uint32_t)];
594
73.2k
                        if (source_.read(buf1, sizeof(uint32_t)) != sizeof(uint32_t))
595
12
                        {
596
12
                            ec = msgpack_errc::unexpected_eof;
597
12
                            more_ = false;
598
12
                            return;
599
12
                        }
600
73.2k
                        uint32_t nsec = binary::big_to_native<uint32_t>(buf1, sizeof(buf1));
601
602
73.2k
                        uint8_t buf2[sizeof(int64_t)];
603
73.2k
                        if (source_.read(buf2, sizeof(int64_t)) != sizeof(int64_t))
604
20
                        {
605
20
                            ec = msgpack_errc::unexpected_eof;
606
20
                            more_ = false;
607
20
                            return;
608
20
                        }
609
73.2k
                        int64_t sec = binary::big_to_native<int64_t>(buf2, sizeof(buf2));
610
611
73.2k
                        bigint nano(sec);
612
613
73.2k
                        nano *= uint64_t(nanos_in_second);
614
615
73.2k
                        if (nano < 0)
616
24.0k
                        {
617
24.0k
                            nano -= nsec;
618
24.0k
                        }
619
49.1k
                        else
620
49.1k
                        {
621
49.1k
                            nano += nsec;
622
49.1k
                        }
623
624
73.2k
                        text_buffer_.clear();
625
73.2k
                        nano.append_to_buffer(text_buffer_);
626
73.2k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
627
73.2k
                        more_ = !cursor_mode_;
628
73.2k
                        if (!more_) return;
629
73.2k
                    }
630
3.66M
                    else
631
3.66M
                    {
632
3.66M
                        auto data = source_.read_span(len, bytes_buffer_);
633
3.66M
                        if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
634
592
                        {
635
592
                            ec = msgpack_errc::unexpected_eof;
636
592
                            more_ = false;
637
592
                            return;
638
592
                        }
639
640
3.66M
                        visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
641
3.66M
                                                          static_cast<uint8_t>(ext_type), 
642
3.66M
                                                          *this,
643
3.66M
                                                          ec);
644
3.66M
                        more_ = !cursor_mode_;
645
3.66M
                    }
646
3.79M
                    break;
647
3.79M
                }
648
649
3.79M
                case jsoncons::msgpack::msgpack_type::array16_type: 
650
21.5k
                case jsoncons::msgpack::msgpack_type::array32_type: 
651
21.5k
                {
652
21.5k
                    begin_array(visitor,type,ec);
653
21.5k
                    break;
654
13.4k
                }
655
656
17.9k
                case jsoncons::msgpack::msgpack_type::map16_type : 
657
23.2k
                case jsoncons::msgpack::msgpack_type::map32_type : 
658
23.2k
                {
659
23.2k
                    begin_object(visitor, type, ec);
660
23.2k
                    break;
661
17.9k
                }
662
663
41
                default:
664
41
                {
665
41
                    ec = msgpack_errc::unknown_type;
666
41
                    more_ = false;
667
41
                    return;
668
17.9k
                }
669
69.4M
            }
670
69.4M
        }
671
158M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::read_item(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
234
83.1M
    {
235
83.1M
        if (source_.is_error())
236
0
        {
237
0
            ec = msgpack_errc::source_error;
238
0
            more_ = false;
239
0
            return;
240
0
        }   
241
242
83.1M
        uint8_t type;
243
83.1M
        if (source_.read(&type, 1) == 0)
244
3.75k
        {
245
3.75k
            ec = msgpack_errc::unexpected_eof;
246
3.75k
            more_ = false;
247
3.75k
            return;
248
3.75k
        }
249
250
83.1M
        if (type <= 0xbf)
251
50.3M
        {
252
50.3M
            if (type <= 0x7f) 
253
43.0M
            {
254
                // positive fixint
255
43.0M
                visitor.uint64_value(type, semantic_tag::none, *this, ec);
256
43.0M
                more_ = !cursor_mode_;
257
43.0M
            }
258
7.34M
            else if (type <= 0x8f) 
259
4.75M
            {
260
4.75M
                begin_object(visitor,type,ec); // fixmap
261
4.75M
            }
262
2.59M
            else if (type <= 0x9f) 
263
1.79M
            {
264
1.79M
                begin_array(visitor,type,ec); // fixarray
265
1.79M
            }
266
793k
            else 
267
793k
            {
268
                // fixstr
269
793k
                const size_t len = type & 0x1f;
270
271
793k
                auto data = source_.read_span(len, bytes_buffer_);
272
793k
                if (data.size() != static_cast<std::size_t>(len))
273
30
                {
274
30
                    ec = msgpack_errc::unexpected_eof;
275
30
                    more_ = false;
276
30
                    return;
277
30
                }
278
279
793k
                auto result = unicode_traits::validate(data.data(), data.size());
280
793k
                if (result.ec != unicode_traits::unicode_errc())
281
261
                {
282
261
                    ec = msgpack_errc::invalid_utf8_text_string;
283
261
                    more_ = false;
284
261
                    return;
285
261
                }
286
793k
                visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
287
793k
                    semantic_tag::none, *this, ec);
288
793k
                more_ = !cursor_mode_;
289
793k
            }
290
50.3M
        }
291
32.7M
        else if (type >= 0xe0) 
292
29.4M
        {
293
            // negative fixint
294
29.4M
            visitor.int64_value(static_cast<int8_t>(type), semantic_tag::none, *this, ec);
295
29.4M
            more_ = !cursor_mode_;
296
29.4M
        }
297
3.32M
        else
298
3.32M
        {
299
3.32M
            switch (type)
300
3.32M
            {
301
518k
                case jsoncons::msgpack::msgpack_type::nil_type: 
302
518k
                {
303
518k
                    visitor.null_value(semantic_tag::none, *this, ec);
304
518k
                    more_ = !cursor_mode_;
305
518k
                    break;
306
0
                }
307
1.40M
                case jsoncons::msgpack::msgpack_type::true_type:
308
1.40M
                {
309
1.40M
                    visitor.bool_value(true, semantic_tag::none, *this, ec);
310
1.40M
                    more_ = !cursor_mode_;
311
1.40M
                    break;
312
0
                }
313
155k
                case jsoncons::msgpack::msgpack_type::false_type:
314
155k
                {
315
155k
                    visitor.bool_value(false, semantic_tag::none, *this, ec);
316
155k
                    more_ = !cursor_mode_;
317
155k
                    break;
318
0
                }
319
107k
                case jsoncons::msgpack::msgpack_type::float32_type: 
320
107k
                {
321
107k
                    uint8_t buf[sizeof(float)];
322
107k
                    if (source_.read(buf, sizeof(float)) != sizeof(float))
323
53
                    {
324
53
                        ec = msgpack_errc::unexpected_eof;
325
53
                        more_ = false;
326
53
                        return;
327
53
                    }
328
107k
                    float val = binary::big_to_native<float>(buf, sizeof(buf));
329
107k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
330
107k
                    more_ = !cursor_mode_;
331
107k
                    break;
332
107k
                }
333
334
27.0k
                case jsoncons::msgpack::msgpack_type::float64_type: 
335
27.0k
                {
336
27.0k
                    uint8_t buf[sizeof(double)];
337
27.0k
                    if (source_.read(buf, sizeof(double)) != sizeof(double))
338
37
                    {
339
37
                        ec = msgpack_errc::unexpected_eof;
340
37
                        more_ = false;
341
37
                        return;
342
37
                    }
343
27.0k
                    double val = binary::big_to_native<double>(buf, sizeof(buf));
344
27.0k
                    visitor.double_value(val, semantic_tag::none, *this, ec);
345
27.0k
                    more_ = !cursor_mode_;
346
27.0k
                    break;
347
27.0k
                }
348
349
1.49k
                case jsoncons::msgpack::msgpack_type::uint8_type: 
350
1.49k
                {
351
1.49k
                    uint8_t b;
352
1.49k
                    if (source_.read(&b, 1) == 0)
353
1
                    {
354
1
                        ec = msgpack_errc::unexpected_eof;
355
1
                        more_ = false;
356
1
                        return;
357
1
                    }
358
1.49k
                    visitor.uint64_value(b, semantic_tag::none, *this, ec);
359
1.49k
                    more_ = !cursor_mode_;
360
1.49k
                    break;
361
1.49k
                }
362
363
11.3k
                case jsoncons::msgpack::msgpack_type::uint16_type: 
364
11.3k
                {
365
11.3k
                    uint8_t buf[sizeof(uint16_t)];
366
11.3k
                    if (source_.read(buf, sizeof(uint16_t)) !=sizeof(uint16_t)) 
367
2
                    {
368
2
                        ec = msgpack_errc::unexpected_eof;
369
2
                        more_ = false;
370
2
                        return;
371
2
                    }
372
11.3k
                    uint16_t val = binary::big_to_native<uint16_t>(buf, sizeof(buf));
373
11.3k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
374
11.3k
                    more_ = !cursor_mode_;
375
11.3k
                    break;
376
11.3k
                }
377
378
8.01k
                case jsoncons::msgpack::msgpack_type::uint32_type: 
379
8.01k
                {
380
8.01k
                    uint8_t buf[sizeof(uint32_t)];
381
8.01k
                    if (source_.read(buf, sizeof(uint32_t)) != sizeof(uint32_t))
382
5
                    {
383
5
                        ec = msgpack_errc::unexpected_eof;
384
5
                        more_ = false;
385
5
                        return;
386
5
                    }
387
8.01k
                    uint32_t val = binary::big_to_native<uint32_t>(buf, sizeof(buf));
388
8.01k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
389
8.01k
                    more_ = !cursor_mode_;
390
8.01k
                    break;
391
8.01k
                }
392
393
2.99k
                case jsoncons::msgpack::msgpack_type::uint64_type: 
394
2.99k
                {
395
2.99k
                    uint8_t buf[sizeof(uint64_t)];
396
2.99k
                    if (source_.read(buf, sizeof(uint64_t)) != sizeof(uint64_t))
397
11
                    {
398
11
                        ec = msgpack_errc::unexpected_eof;
399
11
                        more_ = false;
400
11
                        return;
401
11
                    }
402
2.98k
                    uint64_t val = binary::big_to_native<uint64_t>(buf, sizeof(buf));
403
2.98k
                    visitor.uint64_value(val, semantic_tag::none, *this, ec);
404
2.98k
                    more_ = !cursor_mode_;
405
2.98k
                    break;
406
2.99k
                }
407
408
2.16k
                case jsoncons::msgpack::msgpack_type::int8_type: 
409
2.16k
                {
410
2.16k
                    uint8_t buf[sizeof(int8_t)];
411
2.16k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
412
1
                    {
413
1
                        ec = msgpack_errc::unexpected_eof;
414
1
                        more_ = false;
415
1
                        return;
416
1
                    }
417
2.16k
                    int8_t val = binary::big_to_native<int8_t>(buf, sizeof(buf));
418
2.16k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
419
2.16k
                    more_ = !cursor_mode_;
420
2.16k
                    break;
421
2.16k
                }
422
423
5.45k
                case jsoncons::msgpack::msgpack_type::int16_type: 
424
5.45k
                {
425
5.45k
                    uint8_t buf[sizeof(int16_t)];
426
5.45k
                    if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
427
4
                    {
428
4
                        ec = msgpack_errc::unexpected_eof;
429
4
                        more_ = false;
430
4
                        return;
431
4
                    }
432
5.45k
                    int16_t val = binary::big_to_native<int16_t>(buf, sizeof(buf));
433
5.45k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
434
5.45k
                    more_ = !cursor_mode_;
435
5.45k
                    break;
436
5.45k
                }
437
438
3.22k
                case jsoncons::msgpack::msgpack_type::int32_type: 
439
3.22k
                {
440
3.22k
                    uint8_t buf[sizeof(int32_t)];
441
3.22k
                    if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
442
10
                    {
443
10
                        ec = msgpack_errc::unexpected_eof;
444
10
                        more_ = false;
445
10
                        return;
446
10
                    }
447
3.21k
                    int32_t val = binary::big_to_native<int32_t>(buf, sizeof(buf));
448
3.21k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
449
3.21k
                    more_ = !cursor_mode_;
450
3.21k
                    break;
451
3.22k
                }
452
453
3.25k
                case jsoncons::msgpack::msgpack_type::int64_type: 
454
3.25k
                {
455
3.25k
                    uint8_t buf[sizeof(int64_t)];
456
3.25k
                    if (source_.read(buf, sizeof(int64_t)) != sizeof(int64_t))
457
9
                    {
458
9
                        ec = msgpack_errc::unexpected_eof;
459
9
                        more_ = false;
460
9
                        return;
461
9
                    }
462
3.24k
                    int64_t val = binary::big_to_native<int64_t>(buf, sizeof(buf));
463
3.24k
                    visitor.int64_value(val, semantic_tag::none, *this, ec);
464
3.24k
                    more_ = !cursor_mode_;
465
3.24k
                    break;
466
3.25k
                }
467
468
683
                case jsoncons::msgpack::msgpack_type::str8_type: 
469
960
                case jsoncons::msgpack::msgpack_type::str16_type: 
470
1.36k
                case jsoncons::msgpack::msgpack_type::str32_type: 
471
1.36k
                {
472
1.36k
                    std::size_t len = get_size(type, ec);
473
1.36k
                    if (!more_)
474
19
                    {
475
19
                        return;
476
19
                    }
477
478
1.34k
                    auto data = source_.read_span(len, bytes_buffer_);
479
1.34k
                    if (data.size() != static_cast<std::size_t>(len))
480
49
                    {
481
49
                        ec = msgpack_errc::unexpected_eof;
482
49
                        more_ = false;
483
49
                        return;
484
49
                    }
485
486
1.29k
                    auto result = unicode_traits::validate(data.data(), data.size());
487
1.29k
                    if (result.ec != unicode_traits::unicode_errc())
488
67
                    {
489
67
                        ec = msgpack_errc::invalid_utf8_text_string;
490
67
                        more_ = false;
491
67
                        return;
492
67
                    }
493
1.22k
                    visitor.string_value(jsoncons::string_view(reinterpret_cast<const char*>(data.data()),data.size()), 
494
1.22k
                        semantic_tag::none, *this, ec);
495
1.22k
                    more_ = !cursor_mode_;
496
1.22k
                    break;
497
1.29k
                }
498
499
443k
                case jsoncons::msgpack::msgpack_type::bin8_type: 
500
444k
                case jsoncons::msgpack::msgpack_type::bin16_type: 
501
445k
                case jsoncons::msgpack::msgpack_type::bin32_type: 
502
445k
                {
503
445k
                    std::size_t len = get_size(type,ec);
504
445k
                    if (!more_)
505
45
                    {
506
45
                        return;
507
45
                    }
508
445k
                    auto data = source_.read_span(len, bytes_buffer_);
509
445k
                    if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
510
66
                    {
511
66
                        ec = msgpack_errc::unexpected_eof;
512
66
                        more_ = false;
513
66
                        return;
514
66
                    }
515
516
445k
                    visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
517
445k
                        semantic_tag::none, 
518
445k
                        *this,
519
445k
                        ec);
520
445k
                    more_ = !cursor_mode_;
521
445k
                    break;
522
445k
                }
523
360k
                case jsoncons::msgpack::msgpack_type::fixext1_type: 
524
419k
                case jsoncons::msgpack::msgpack_type::fixext2_type: 
525
427k
                case jsoncons::msgpack::msgpack_type::fixext4_type: 
526
457k
                case jsoncons::msgpack::msgpack_type::fixext8_type: 
527
457k
                case jsoncons::msgpack::msgpack_type::fixext16_type: 
528
578k
                case jsoncons::msgpack::msgpack_type::ext8_type: 
529
578k
                case jsoncons::msgpack::msgpack_type::ext16_type: 
530
589k
                case jsoncons::msgpack::msgpack_type::ext32_type: 
531
589k
                {
532
589k
                    std::size_t len = get_size(type,ec);
533
589k
                    if (!more_)
534
26
                    {
535
26
                        return;
536
26
                    }
537
538
                    // type
539
589k
                    uint8_t buf[sizeof(int8_t)];
540
589k
                    if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
541
63
                    {
542
63
                        ec = msgpack_errc::unexpected_eof;
543
63
                        more_ = false;
544
63
                        return;
545
63
                    }
546
547
589k
                    int8_t ext_type = binary::big_to_native<int8_t>(buf, sizeof(buf));
548
549
589k
                    bool is_timestamp = false; 
550
589k
                    if (ext_type == -1)
551
135k
                    {
552
135k
                        is_timestamp = true;;
553
135k
                    }
554
555
                    // payload
556
589k
                    if (is_timestamp && len == 4)
557
3.82k
                    {
558
3.82k
                        uint8_t buf32[sizeof(uint32_t)];
559
3.82k
                        if (source_.read(buf32, sizeof(uint32_t)) != sizeof(uint32_t))
560
5
                        {
561
5
                            ec = msgpack_errc::unexpected_eof;
562
5
                            more_ = false;
563
5
                            return;
564
5
                        }
565
3.81k
                        uint32_t val = binary::big_to_native<uint32_t>(buf32, sizeof(buf32));
566
3.81k
                        visitor.uint64_value(val, semantic_tag::epoch_second, *this, ec);
567
3.81k
                        more_ = !cursor_mode_;
568
3.81k
                    }
569
585k
                    else if (is_timestamp && len == 8)
570
23.8k
                    {
571
23.8k
                        uint8_t buf64[sizeof(uint64_t)];
572
23.8k
                        if (source_.read(buf64, sizeof(uint64_t)) != sizeof(uint64_t))
573
16
                        {
574
16
                            ec = msgpack_errc::unexpected_eof;
575
16
                            more_ = false;
576
16
                            return;
577
16
                        }
578
23.8k
                        uint64_t data64 = binary::big_to_native<uint64_t>(buf64, sizeof(buf64));
579
23.8k
                        uint64_t sec = data64 & 0x00000003ffffffffL;
580
23.8k
                        uint64_t nsec = data64 >> 34;
581
582
23.8k
                        bigint nano(sec);
583
23.8k
                        nano *= uint64_t(nanos_in_second);
584
23.8k
                        nano += nsec;
585
23.8k
                        text_buffer_.clear();
586
23.8k
                        nano.append_to_buffer(text_buffer_);
587
23.8k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
588
23.8k
                        more_ = !cursor_mode_;
589
23.8k
                        if (!more_) return;
590
23.8k
                    }
591
562k
                    else if (is_timestamp && len == 12)
592
105k
                    {
593
105k
                        uint8_t buf1[sizeof(uint32_t)];
594
105k
                        if (source_.read(buf1, sizeof(uint32_t)) != sizeof(uint32_t))
595
10
                        {
596
10
                            ec = msgpack_errc::unexpected_eof;
597
10
                            more_ = false;
598
10
                            return;
599
10
                        }
600
105k
                        uint32_t nsec = binary::big_to_native<uint32_t>(buf1, sizeof(buf1));
601
602
105k
                        uint8_t buf2[sizeof(int64_t)];
603
105k
                        if (source_.read(buf2, sizeof(int64_t)) != sizeof(int64_t))
604
18
                        {
605
18
                            ec = msgpack_errc::unexpected_eof;
606
18
                            more_ = false;
607
18
                            return;
608
18
                        }
609
105k
                        int64_t sec = binary::big_to_native<int64_t>(buf2, sizeof(buf2));
610
611
105k
                        bigint nano(sec);
612
613
105k
                        nano *= uint64_t(nanos_in_second);
614
615
105k
                        if (nano < 0)
616
74.9k
                        {
617
74.9k
                            nano -= nsec;
618
74.9k
                        }
619
30.9k
                        else
620
30.9k
                        {
621
30.9k
                            nano += nsec;
622
30.9k
                        }
623
624
105k
                        text_buffer_.clear();
625
105k
                        nano.append_to_buffer(text_buffer_);
626
105k
                        visitor.string_value(text_buffer_, semantic_tag::epoch_nano, *this, ec);
627
105k
                        more_ = !cursor_mode_;
628
105k
                        if (!more_) return;
629
105k
                    }
630
456k
                    else
631
456k
                    {
632
456k
                        auto data = source_.read_span(len, bytes_buffer_);
633
456k
                        if (JSONCONS_UNLIKELY(data.size() != static_cast<std::size_t>(len)))
634
137
                        {
635
137
                            ec = msgpack_errc::unexpected_eof;
636
137
                            more_ = false;
637
137
                            return;
638
137
                        }
639
640
455k
                        visitor.byte_string_value(byte_string_view(data.data(),data.size()), 
641
455k
                                                          static_cast<uint8_t>(ext_type), 
642
455k
                                                          *this,
643
455k
                                                          ec);
644
455k
                        more_ = !cursor_mode_;
645
455k
                    }
646
589k
                    break;
647
589k
                }
648
649
589k
                case jsoncons::msgpack::msgpack_type::array16_type: 
650
12.8k
                case jsoncons::msgpack::msgpack_type::array32_type: 
651
12.8k
                {
652
12.8k
                    begin_array(visitor,type,ec);
653
12.8k
                    break;
654
8.03k
                }
655
656
28.3k
                case jsoncons::msgpack::msgpack_type::map16_type : 
657
29.6k
                case jsoncons::msgpack::msgpack_type::map32_type : 
658
29.6k
                {
659
29.6k
                    begin_object(visitor, type, ec);
660
29.6k
                    break;
661
28.3k
                }
662
663
8
                default:
664
8
                {
665
8
                    ec = msgpack_errc::unknown_type;
666
8
                    more_ = false;
667
8
                    return;
668
28.3k
                }
669
3.32M
            }
670
3.32M
        }
671
83.1M
    }
672
673
    void begin_array(generic_visitor& visitor, uint8_t type, std::error_code& ec)
674
11.1M
    {
675
11.1M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
676
11
        {
677
11
            ec = msgpack_errc::max_nesting_depth_exceeded;
678
11
            more_ = false;
679
11
            return;
680
11
        } 
681
11.1M
        std::size_t length = get_size(type, ec);
682
11.1M
        if (!more_)
683
120
        {
684
120
            return;
685
120
        }
686
11.1M
        state_stack_.emplace_back(parse_mode::array,length);
687
11.1M
        visitor.begin_array(length, semantic_tag::none, *this, ec);
688
11.1M
        more_ = !cursor_mode_;
689
11.1M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::begin_array(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
674
2.04M
    {
675
2.04M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
676
1
        {
677
1
            ec = msgpack_errc::max_nesting_depth_exceeded;
678
1
            more_ = false;
679
1
            return;
680
1
        } 
681
2.04M
        std::size_t length = get_size(type, ec);
682
2.04M
        if (!more_)
683
24
        {
684
24
            return;
685
24
        }
686
2.04M
        state_stack_.emplace_back(parse_mode::array,length);
687
2.04M
        visitor.begin_array(length, semantic_tag::none, *this, ec);
688
2.04M
        more_ = !cursor_mode_;
689
2.04M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::begin_array(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
674
7.26M
    {
675
7.26M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
676
7
        {
677
7
            ec = msgpack_errc::max_nesting_depth_exceeded;
678
7
            more_ = false;
679
7
            return;
680
7
        } 
681
7.26M
        std::size_t length = get_size(type, ec);
682
7.26M
        if (!more_)
683
61
        {
684
61
            return;
685
61
        }
686
7.26M
        state_stack_.emplace_back(parse_mode::array,length);
687
7.26M
        visitor.begin_array(length, semantic_tag::none, *this, ec);
688
7.26M
        more_ = !cursor_mode_;
689
7.26M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::begin_array(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
674
1.81M
    {
675
1.81M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
676
3
        {
677
3
            ec = msgpack_errc::max_nesting_depth_exceeded;
678
3
            more_ = false;
679
3
            return;
680
3
        } 
681
1.81M
        std::size_t length = get_size(type, ec);
682
1.81M
        if (!more_)
683
35
        {
684
35
            return;
685
35
        }
686
1.81M
        state_stack_.emplace_back(parse_mode::array,length);
687
1.81M
        visitor.begin_array(length, semantic_tag::none, *this, ec);
688
1.81M
        more_ = !cursor_mode_;
689
1.81M
    }
690
691
    void end_array(generic_visitor& visitor, std::error_code& ec)
692
10.9M
    {
693
10.9M
        --nesting_depth_;
694
695
10.9M
        visitor.end_array(*this, ec);
696
10.9M
        more_ = !cursor_mode_;
697
10.9M
        state_stack_.pop_back();
698
10.9M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::end_array(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
692
2.01M
    {
693
2.01M
        --nesting_depth_;
694
695
2.01M
        visitor.end_array(*this, ec);
696
2.01M
        more_ = !cursor_mode_;
697
2.01M
        state_stack_.pop_back();
698
2.01M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::end_array(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
692
7.18M
    {
693
7.18M
        --nesting_depth_;
694
695
7.18M
        visitor.end_array(*this, ec);
696
7.18M
        more_ = !cursor_mode_;
697
7.18M
        state_stack_.pop_back();
698
7.18M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::end_array(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
692
1.77M
    {
693
1.77M
        --nesting_depth_;
694
695
1.77M
        visitor.end_array(*this, ec);
696
1.77M
        more_ = !cursor_mode_;
697
1.77M
        state_stack_.pop_back();
698
1.77M
    }
699
700
    void begin_object(generic_visitor& visitor, uint8_t type, std::error_code& ec)
701
8.71M
    {
702
8.71M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
703
9
        {
704
9
            ec = msgpack_errc::max_nesting_depth_exceeded;
705
9
            more_ = false;
706
9
            return;
707
9
        } 
708
8.71M
        std::size_t length = get_size(type, ec);
709
8.71M
        if (!more_)
710
116
        {
711
116
            return;
712
116
        }
713
8.71M
        state_stack_.emplace_back(parse_mode::map_key,length);
714
8.71M
        visitor.begin_object(length, semantic_tag::none, *this, ec);
715
8.71M
        more_ = !cursor_mode_;
716
8.71M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::begin_object(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
701
1.84M
    {
702
1.84M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
703
2
        {
704
2
            ec = msgpack_errc::max_nesting_depth_exceeded;
705
2
            more_ = false;
706
2
            return;
707
2
        } 
708
1.84M
        std::size_t length = get_size(type, ec);
709
1.84M
        if (!more_)
710
21
        {
711
21
            return;
712
21
        }
713
1.84M
        state_stack_.emplace_back(parse_mode::map_key,length);
714
1.84M
        visitor.begin_object(length, semantic_tag::none, *this, ec);
715
1.84M
        more_ = !cursor_mode_;
716
1.84M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::begin_object(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
701
2.09M
    {
702
2.09M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
703
5
        {
704
5
            ec = msgpack_errc::max_nesting_depth_exceeded;
705
5
            more_ = false;
706
5
            return;
707
5
        } 
708
2.09M
        std::size_t length = get_size(type, ec);
709
2.09M
        if (!more_)
710
63
        {
711
63
            return;
712
63
        }
713
2.09M
        state_stack_.emplace_back(parse_mode::map_key,length);
714
2.09M
        visitor.begin_object(length, semantic_tag::none, *this, ec);
715
2.09M
        more_ = !cursor_mode_;
716
2.09M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::begin_object(jsoncons::basic_generic_visitor<char>&, unsigned char, std::__1::error_code&)
Line
Count
Source
701
4.78M
    {
702
4.78M
        if (JSONCONS_UNLIKELY(++nesting_depth_ > max_nesting_depth_))
703
2
        {
704
2
            ec = msgpack_errc::max_nesting_depth_exceeded;
705
2
            more_ = false;
706
2
            return;
707
2
        } 
708
4.78M
        std::size_t length = get_size(type, ec);
709
4.78M
        if (!more_)
710
32
        {
711
32
            return;
712
32
        }
713
4.78M
        state_stack_.emplace_back(parse_mode::map_key,length);
714
4.78M
        visitor.begin_object(length, semantic_tag::none, *this, ec);
715
4.78M
        more_ = !cursor_mode_;
716
4.78M
    }
717
718
    void end_object(generic_visitor& visitor, std::error_code& ec)
719
8.59M
    {
720
8.59M
        --nesting_depth_;
721
8.59M
        visitor.end_object(*this, ec);
722
8.59M
        more_ = !cursor_mode_;
723
8.59M
        state_stack_.pop_back();
724
8.59M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::end_object(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
719
1.81M
    {
720
1.81M
        --nesting_depth_;
721
1.81M
        visitor.end_object(*this, ec);
722
1.81M
        more_ = !cursor_mode_;
723
1.81M
        state_stack_.pop_back();
724
1.81M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::end_object(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
719
2.01M
    {
720
2.01M
        --nesting_depth_;
721
2.01M
        visitor.end_object(*this, ec);
722
2.01M
        more_ = !cursor_mode_;
723
2.01M
        state_stack_.pop_back();
724
2.01M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::end_object(jsoncons::basic_generic_visitor<char>&, std::__1::error_code&)
Line
Count
Source
719
4.75M
    {
720
4.75M
        --nesting_depth_;
721
4.75M
        visitor.end_object(*this, ec);
722
4.75M
        more_ = !cursor_mode_;
723
4.75M
        state_stack_.pop_back();
724
4.75M
    }
725
726
    std::size_t get_size(uint8_t type, std::error_code& ec)
727
25.9M
    {
728
25.9M
        switch (type)
729
25.9M
        {
730
3.71k
            case jsoncons::msgpack::msgpack_type::str8_type: 
731
1.13M
            case jsoncons::msgpack::msgpack_type::bin8_type: 
732
1.36M
            case jsoncons::msgpack::msgpack_type::ext8_type: 
733
1.36M
            {
734
1.36M
                uint8_t buf[sizeof(int8_t)];
735
1.36M
                if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
736
170
                {
737
170
                    ec = msgpack_errc::unexpected_eof;
738
170
                    more_ = false;
739
170
                    return 0;
740
170
                }
741
1.36M
                uint8_t len = binary::big_to_native<uint8_t>(buf, sizeof(buf));
742
1.36M
                return static_cast<std::size_t>(len);
743
1.36M
            }
744
745
2.22k
            case jsoncons::msgpack::msgpack_type::str16_type: 
746
30.9k
            case jsoncons::msgpack::msgpack_type::bin16_type: 
747
35.1k
            case jsoncons::msgpack::msgpack_type::ext16_type: 
748
61.7k
            case jsoncons::msgpack::msgpack_type::array16_type: 
749
128k
            case jsoncons::msgpack::msgpack_type::map16_type:
750
128k
            {
751
128k
                uint8_t buf[sizeof(int16_t)];
752
128k
                if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
753
234
                {
754
234
                    ec = msgpack_errc::unexpected_eof;
755
234
                    more_ = false;
756
234
                    return 0;
757
234
                }
758
128k
                uint16_t len = binary::big_to_native<uint16_t>(buf, sizeof(buf));
759
128k
                return static_cast<std::size_t>(len);
760
128k
            }
761
762
11.2k
            case jsoncons::msgpack::msgpack_type::str32_type: 
763
13.4k
            case jsoncons::msgpack::msgpack_type::bin32_type: 
764
48.3k
            case jsoncons::msgpack::msgpack_type::ext32_type: 
765
62.4k
            case jsoncons::msgpack::msgpack_type::array32_type: 
766
70.6k
            case jsoncons::msgpack::msgpack_type::map32_type : 
767
70.6k
            {
768
70.6k
                uint8_t buf[sizeof(int32_t)];
769
70.6k
                if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
770
265
                {
771
265
                    ec = msgpack_errc::unexpected_eof;
772
265
                    more_ = false;
773
265
                    return 0;
774
265
                }
775
70.4k
                uint32_t len = binary::big_to_native<uint32_t>(buf, sizeof(buf));
776
70.4k
                return static_cast<std::size_t>(len);
777
70.6k
            }
778
1.85M
            case jsoncons::msgpack::msgpack_type::fixext1_type: 
779
1.85M
                return 1;
780
2.41M
            case jsoncons::msgpack::msgpack_type::fixext2_type: 
781
2.41M
                return 2;
782
115k
            case jsoncons::msgpack::msgpack_type::fixext4_type: 
783
115k
                return 4;
784
163k
            case jsoncons::msgpack::msgpack_type::fixext8_type: 
785
163k
                return 8;
786
116k
            case jsoncons::msgpack::msgpack_type::fixext16_type: 
787
116k
                return 16;
788
19.7M
            default:
789
19.7M
                if ((type > 0x8f && type <= 0x9f) // fixarray
790
8.64M
                    || (type > 0x7f && type <= 0x8f) // fixmap
791
19.7M
        )
792
19.7M
                {
793
19.7M
                    return type & 0x0f;
794
19.7M
                }
795
0
                else
796
0
                {
797
0
                    ec = msgpack_errc::unknown_type;
798
0
                    more_ = false;
799
0
                    return 0;
800
0
                }
801
0
                break;
802
25.9M
        }
803
25.9M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::iterator_source<std::__1::__wrap_iter<unsigned char*> >, std::__1::allocator<char> >::get_size(unsigned char, std::__1::error_code&)
Line
Count
Source
727
4.91M
    {
728
4.91M
        switch (type)
729
4.91M
        {
730
959
            case jsoncons::msgpack::msgpack_type::str8_type: 
731
453k
            case jsoncons::msgpack::msgpack_type::bin8_type: 
732
475k
            case jsoncons::msgpack::msgpack_type::ext8_type: 
733
475k
            {
734
475k
                uint8_t buf[sizeof(int8_t)];
735
475k
                if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
736
37
                {
737
37
                    ec = msgpack_errc::unexpected_eof;
738
37
                    more_ = false;
739
37
                    return 0;
740
37
                }
741
475k
                uint8_t len = binary::big_to_native<uint8_t>(buf, sizeof(buf));
742
475k
                return static_cast<std::size_t>(len);
743
475k
            }
744
745
267
            case jsoncons::msgpack::msgpack_type::str16_type: 
746
20.9k
            case jsoncons::msgpack::msgpack_type::bin16_type: 
747
23.1k
            case jsoncons::msgpack::msgpack_type::ext16_type: 
748
28.3k
            case jsoncons::msgpack::msgpack_type::array16_type: 
749
48.8k
            case jsoncons::msgpack::msgpack_type::map16_type:
750
48.8k
            {
751
48.8k
                uint8_t buf[sizeof(int16_t)];
752
48.8k
                if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
753
45
                {
754
45
                    ec = msgpack_errc::unexpected_eof;
755
45
                    more_ = false;
756
45
                    return 0;
757
45
                }
758
48.8k
                uint16_t len = binary::big_to_native<uint16_t>(buf, sizeof(buf));
759
48.8k
                return static_cast<std::size_t>(len);
760
48.8k
            }
761
762
8.79k
            case jsoncons::msgpack::msgpack_type::str32_type: 
763
9.04k
            case jsoncons::msgpack::msgpack_type::bin32_type: 
764
29.8k
            case jsoncons::msgpack::msgpack_type::ext32_type: 
765
31.0k
            case jsoncons::msgpack::msgpack_type::array32_type: 
766
32.6k
            case jsoncons::msgpack::msgpack_type::map32_type : 
767
32.6k
            {
768
32.6k
                uint8_t buf[sizeof(int32_t)];
769
32.6k
                if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
770
56
                {
771
56
                    ec = msgpack_errc::unexpected_eof;
772
56
                    more_ = false;
773
56
                    return 0;
774
56
                }
775
32.5k
                uint32_t len = binary::big_to_native<uint32_t>(buf, sizeof(buf));
776
32.5k
                return static_cast<std::size_t>(len);
777
32.6k
            }
778
401k
            case jsoncons::msgpack::msgpack_type::fixext1_type: 
779
401k
                return 1;
780
11.8k
            case jsoncons::msgpack::msgpack_type::fixext2_type: 
781
11.8k
                return 2;
782
4.80k
            case jsoncons::msgpack::msgpack_type::fixext4_type: 
783
4.80k
                return 4;
784
69.0k
            case jsoncons::msgpack::msgpack_type::fixext8_type: 
785
69.0k
                return 8;
786
14.8k
            case jsoncons::msgpack::msgpack_type::fixext16_type: 
787
14.8k
                return 16;
788
3.85M
            default:
789
3.85M
                if ((type > 0x8f && type <= 0x9f) // fixarray
790
1.81M
                    || (type > 0x7f && type <= 0x8f) // fixmap
791
3.85M
        )
792
3.85M
                {
793
3.85M
                    return type & 0x0f;
794
3.85M
                }
795
0
                else
796
0
                {
797
0
                    ec = msgpack_errc::unknown_type;
798
0
                    more_ = false;
799
0
                    return 0;
800
0
                }
801
0
                break;
802
4.91M
        }
803
4.91M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::stream_source<unsigned char, std::__1::allocator<unsigned char> >, std::__1::allocator<char> >::get_size(unsigned char, std::__1::error_code&)
Line
Count
Source
727
13.3M
    {
728
13.3M
        switch (type)
729
13.3M
        {
730
2.07k
            case jsoncons::msgpack::msgpack_type::str8_type: 
731
234k
            case jsoncons::msgpack::msgpack_type::bin8_type: 
732
322k
            case jsoncons::msgpack::msgpack_type::ext8_type: 
733
322k
            {
734
322k
                uint8_t buf[sizeof(int8_t)];
735
322k
                if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
736
90
                {
737
90
                    ec = msgpack_errc::unexpected_eof;
738
90
                    more_ = false;
739
90
                    return 0;
740
90
                }
741
322k
                uint8_t len = binary::big_to_native<uint8_t>(buf, sizeof(buf));
742
322k
                return static_cast<std::size_t>(len);
743
322k
            }
744
745
1.68k
            case jsoncons::msgpack::msgpack_type::str16_type: 
746
8.63k
            case jsoncons::msgpack::msgpack_type::bin16_type: 
747
10.3k
            case jsoncons::msgpack::msgpack_type::ext16_type: 
748
23.7k
            case jsoncons::msgpack::msgpack_type::array16_type: 
749
41.6k
            case jsoncons::msgpack::msgpack_type::map16_type:
750
41.6k
            {
751
41.6k
                uint8_t buf[sizeof(int16_t)];
752
41.6k
                if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
753
136
                {
754
136
                    ec = msgpack_errc::unexpected_eof;
755
136
                    more_ = false;
756
136
                    return 0;
757
136
                }
758
41.5k
                uint16_t len = binary::big_to_native<uint16_t>(buf, sizeof(buf));
759
41.5k
                return static_cast<std::size_t>(len);
760
41.6k
            }
761
762
2.03k
            case jsoncons::msgpack::msgpack_type::str32_type: 
763
3.46k
            case jsoncons::msgpack::msgpack_type::bin32_type: 
764
6.61k
            case jsoncons::msgpack::msgpack_type::ext32_type: 
765
14.7k
            case jsoncons::msgpack::msgpack_type::array32_type: 
766
20.0k
            case jsoncons::msgpack::msgpack_type::map32_type : 
767
20.0k
            {
768
20.0k
                uint8_t buf[sizeof(int32_t)];
769
20.0k
                if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
770
148
                {
771
148
                    ec = msgpack_errc::unexpected_eof;
772
148
                    more_ = false;
773
148
                    return 0;
774
148
                }
775
19.8k
                uint32_t len = binary::big_to_native<uint32_t>(buf, sizeof(buf));
776
19.8k
                return static_cast<std::size_t>(len);
777
20.0k
            }
778
1.09M
            case jsoncons::msgpack::msgpack_type::fixext1_type: 
779
1.09M
                return 1;
780
2.33M
            case jsoncons::msgpack::msgpack_type::fixext2_type: 
781
2.33M
                return 2;
782
103k
            case jsoncons::msgpack::msgpack_type::fixext4_type: 
783
103k
                return 4;
784
64.1k
            case jsoncons::msgpack::msgpack_type::fixext8_type: 
785
64.1k
                return 8;
786
101k
            case jsoncons::msgpack::msgpack_type::fixext16_type: 
787
101k
                return 16;
788
9.31M
            default:
789
9.31M
                if ((type > 0x8f && type <= 0x9f) // fixarray
790
2.06M
                    || (type > 0x7f && type <= 0x8f) // fixmap
791
9.31M
        )
792
9.31M
                {
793
9.31M
                    return type & 0x0f;
794
9.31M
                }
795
0
                else
796
0
                {
797
0
                    ec = msgpack_errc::unknown_type;
798
0
                    more_ = false;
799
0
                    return 0;
800
0
                }
801
0
                break;
802
13.3M
        }
803
13.3M
    }
jsoncons::msgpack::basic_msgpack_parser<jsoncons::chars_source<unsigned char>, std::__1::allocator<char> >::get_size(unsigned char, std::__1::error_code&)
Line
Count
Source
727
7.63M
    {
728
7.63M
        switch (type)
729
7.63M
        {
730
683
            case jsoncons::msgpack::msgpack_type::str8_type: 
731
444k
            case jsoncons::msgpack::msgpack_type::bin8_type: 
732
565k
            case jsoncons::msgpack::msgpack_type::ext8_type: 
733
565k
            {
734
565k
                uint8_t buf[sizeof(int8_t)];
735
565k
                if (source_.read(buf, sizeof(int8_t)) != sizeof(int8_t))
736
43
                {
737
43
                    ec = msgpack_errc::unexpected_eof;
738
43
                    more_ = false;
739
43
                    return 0;
740
43
                }
741
565k
                uint8_t len = binary::big_to_native<uint8_t>(buf, sizeof(buf));
742
565k
                return static_cast<std::size_t>(len);
743
565k
            }
744
745
277
            case jsoncons::msgpack::msgpack_type::str16_type: 
746
1.30k
            case jsoncons::msgpack::msgpack_type::bin16_type: 
747
1.61k
            case jsoncons::msgpack::msgpack_type::ext16_type: 
748
9.64k
            case jsoncons::msgpack::msgpack_type::array16_type: 
749
37.9k
            case jsoncons::msgpack::msgpack_type::map16_type:
750
37.9k
            {
751
37.9k
                uint8_t buf[sizeof(int16_t)];
752
37.9k
                if (source_.read(buf, sizeof(int16_t)) != sizeof(int16_t))
753
53
                {
754
53
                    ec = msgpack_errc::unexpected_eof;
755
53
                    more_ = false;
756
53
                    return 0;
757
53
                }
758
37.9k
                uint16_t len = binary::big_to_native<uint16_t>(buf, sizeof(buf));
759
37.9k
                return static_cast<std::size_t>(len);
760
37.9k
            }
761
762
403
            case jsoncons::msgpack::msgpack_type::str32_type: 
763
956
            case jsoncons::msgpack::msgpack_type::bin32_type: 
764
11.8k
            case jsoncons::msgpack::msgpack_type::ext32_type: 
765
16.6k
            case jsoncons::msgpack::msgpack_type::array32_type: 
766
18.0k
            case jsoncons::msgpack::msgpack_type::map32_type : 
767
18.0k
            {
768
18.0k
                uint8_t buf[sizeof(int32_t)];
769
18.0k
                if (source_.read(buf, sizeof(int32_t)) != sizeof(int32_t))
770
61
                {
771
61
                    ec = msgpack_errc::unexpected_eof;
772
61
                    more_ = false;
773
61
                    return 0;
774
61
                }
775
17.9k
                uint32_t len = binary::big_to_native<uint32_t>(buf, sizeof(buf));
776
17.9k
                return static_cast<std::size_t>(len);
777
18.0k
            }
778
360k
            case jsoncons::msgpack::msgpack_type::fixext1_type: 
779
360k
                return 1;
780
59.5k
            case jsoncons::msgpack::msgpack_type::fixext2_type: 
781
59.5k
                return 2;
782
7.38k
            case jsoncons::msgpack::msgpack_type::fixext4_type: 
783
7.38k
                return 4;
784
30.0k
            case jsoncons::msgpack::msgpack_type::fixext8_type: 
785
30.0k
                return 8;
786
469
            case jsoncons::msgpack::msgpack_type::fixext16_type: 
787
469
                return 16;
788
6.55M
            default:
789
6.55M
                if ((type > 0x8f && type <= 0x9f) // fixarray
790
4.75M
                    || (type > 0x7f && type <= 0x8f) // fixmap
791
6.55M
        )
792
6.55M
                {
793
6.55M
                    return type & 0x0f;
794
6.55M
                }
795
0
                else
796
0
                {
797
0
                    ec = msgpack_errc::unknown_type;
798
0
                    more_ = false;
799
0
                    return 0;
800
0
                }
801
0
                break;
802
7.63M
        }
803
7.63M
    }
804
};
805
806
} // namespace msgpack
807
} // namespace jsoncons
808
809
#endif // JSONCONS_EXT_MSGPACK_MSGPACK_PARSER_HPP