]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/json/detail/object.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / json / detail / object.hpp
CommitLineData
20effc67
TL
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>
1e59de90 14#include <boost/json/string_view.hpp>
20effc67
TL
15#include <cstdlib>
16
17BOOST_JSON_NS_BEGIN
18
1e59de90 19class object;
20effc67
TL
20class value;
21class key_value_pair;
22
23namespace detail {
24
25class unchecked_object
26{
27 // each element is two values,
28 // first one is a string key,
29 // second one is the value.
30 value* data_;
31 std::size_t size_;
32 storage_ptr const& sp_;
33
34public:
35 inline
36 ~unchecked_object();
37
38 unchecked_object(
39 value* data,
40 std::size_t size, // # of kv-pairs
41 storage_ptr const& sp) noexcept
42 : data_(data)
43 , size_(size)
44 , sp_(sp)
45 {
46 }
47
48 unchecked_object(
49 unchecked_object&& other) noexcept
50 : data_(other.data_)
51 , size_(other.size_)
52 , sp_(other.sp_)
53 {
54 other.data_ = nullptr;
55 }
56
57 storage_ptr const&
58 storage() const noexcept
59 {
60 return sp_;
61 }
62
63 std::size_t
64 size() const noexcept
65 {
66 return size_;
67 }
68
69 value*
70 release() noexcept
71 {
72 auto const data = data_;
73 data_ = nullptr;
74 return data;
75 }
76};
77
1e59de90
TL
78template<class CharRange>
79std::pair<key_value_pair*, std::size_t>
80find_in_object(
81 object const& obj,
82 CharRange key) noexcept;
83
84extern template
85BOOST_JSON_DECL
86std::pair<key_value_pair*, std::size_t>
87find_in_object<string_view>(
88 object const&,
89 string_view key) noexcept;
90
20effc67
TL
91} // detail
92BOOST_JSON_NS_END
93
94#endif