MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
value.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <cstdlib>
18#include <memory>
19
21
24
26
27namespace bsoncxx {
28namespace v_noabi {
29namespace array {
30
36class value {
37 public:
38 using deleter_type = void(BSONCXX_ABI_CDECL*)(std::uint8_t*);
39 using unique_ptr_type = std::unique_ptr<uint8_t[], deleter_type>;
40
53 BSONCXX_ABI_EXPORT_CDECL() value(std::uint8_t* data, std::size_t length, deleter_type dtor);
54
64 BSONCXX_ABI_EXPORT_CDECL() value(unique_ptr_type ptr, std::size_t length);
65
75
77 BSONCXX_ABI_EXPORT_CDECL(value&) operator=(const value&);
78
79 value(value&&) = default;
80 value& operator=(value&&) = default;
81
85 array::view view() const noexcept {
86 return array::view{static_cast<uint8_t*>(_data.get()), _length};
87 }
88
94 operator array::view() const noexcept {
95 return view();
96 }
97
108
109 private:
110 unique_ptr_type _data;
111 std::size_t _length{0};
112};
113
114} // namespace array
115} // namespace v_noabi
116} // namespace bsoncxx
117
119
Declares bsoncxx::v_noabi::array::value.
Provides bsoncxx::v_noabi::array::view.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A read-only BSON array that owns its underlying buffer. When a array::value goes out of scope,...
Definition value.hpp:36
unique_ptr_type release()
Transfer ownership of the underlying buffer to the caller.
array::view view() const noexcept
Get a view over the document owned by this value.
Definition value.hpp:85
A read-only, non-owning view of a BSON document.
Definition view.hpp:36
Provides bsoncxx::v_noabi::document::value.
#define BSONCXX_ABI_CDECL
Expands to __cdecl when built with MSVC on Windows.
Definition fwd.hpp:217
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:225
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace reserved for the C++ standard library.