Coverage Report

Created: 2025-11-08 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boost/boost/json/detail/object.hpp
Line
Count
Source
1
//
2
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3
//
4
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
//
7
// Official repository: https://github.com/boostorg/json
8
//
9
10
#ifndef BOOST_JSON_DETAIL_OBJECT_HPP
11
#define BOOST_JSON_DETAIL_OBJECT_HPP
12
13
#include <boost/json/storage_ptr.hpp>
14
#include <boost/json/string_view.hpp>
15
#include <cstdlib>
16
17
namespace boost {
18
namespace json {
19
20
class object;
21
class value;
22
class key_value_pair;
23
24
namespace detail {
25
26
class unchecked_object
27
{
28
    // each element is two values,
29
    // first one is a string key,
30
    // second one is the value.
31
    value* data_;
32
    std::size_t size_;
33
    storage_ptr const& sp_;
34
35
public:
36
    inline
37
    ~unchecked_object();
38
39
    unchecked_object(
40
        value* data,
41
        std::size_t size, // # of kv-pairs
42
        storage_ptr const& sp) noexcept
43
24.8k
        : data_(data)
44
24.8k
        , size_(size)
45
24.8k
        , sp_(sp)
46
24.8k
    {
47
24.8k
    }
48
49
    unchecked_object(
50
        unchecked_object&& other) noexcept
51
        : data_(other.data_)
52
        , size_(other.size_)
53
        , sp_(other.sp_)
54
0
    {
55
0
        other.data_ = nullptr;
56
0
    }
57
58
    storage_ptr const&
59
    storage() const noexcept
60
24.8k
    {
61
24.8k
        return sp_;
62
24.8k
    }
63
64
    std::size_t
65
    size() const noexcept
66
40.2k
    {
67
40.2k
        return size_;
68
40.2k
    }
69
70
    value*
71
    release() noexcept
72
7.70k
    {
73
7.70k
        auto const data = data_;
74
7.70k
        data_ = nullptr;
75
7.70k
        return data;
76
7.70k
    }
77
};
78
79
template<class CharRange>
80
std::pair<key_value_pair*, std::size_t>
81
find_in_object(
82
    object const& obj,
83
    CharRange key) noexcept;
84
85
extern template
86
BOOST_JSON_DECL
87
std::pair<key_value_pair*, std::size_t>
88
find_in_object<string_view>(
89
    object const&,
90
    string_view key) noexcept;
91
92
} // detail
93
} // namespace json
94
} // namespace boost
95
96
#endif