MongoDB C++ Driver mongocxx-4.0.0
Loading...
Searching...
No Matches
array.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
18
25
27
28namespace bsoncxx {
29namespace v_noabi {
30namespace builder {
31namespace basic {
32
37class array : public sub_array {
38 public:
42 array() : sub_array(&_core), _core(true) {}
43
47 ~array() = default;
48
52 array(array&& arr) noexcept : sub_array(&_core), _core(std::move(arr._core)) {}
53
57 array& operator=(array&& arr) noexcept {
58 _core = std::move(arr._core);
59 return *this;
60 }
61
62 array(const array&) = delete;
63 array& operator=(const array&) = delete;
64
69 return _core.view_array();
70 }
71
79 return view();
80 }
81
94
98 void clear() {
99 _core.clear();
100 }
101
102 private:
103 core _core;
104};
105
116template <typename... Args>
118 array array;
119 array.append(std::forward<Args>(args)...);
120 return array.extract();
121}
122
123} // namespace basic
124} // namespace builder
125} // namespace v_noabi
126} // namespace bsoncxx
127
128namespace bsoncxx {
129namespace builder {
130namespace basic {
131
132using ::bsoncxx::v_noabi::builder::basic::make_array;
133
134} // namespace basic
135} // namespace builder
136} // namespace bsoncxx
137
139
144
145#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
146
147namespace bsoncxx {
148namespace builder {
149namespace basic {
150
152template <typename... Args>
154
155} // namespace basic
156} // namespace builder
157} // namespace bsoncxx
158
159#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
Provides bsoncxx::v_noabi::array::value.
Provides bsoncxx::v_noabi::array::view.
Declares bsoncxx::v_noabi::builder::basic::array.
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
A read-only, non-owning view of a BSON document.
Definition view.hpp:36
A traditional builder-style interface for constructing a BSON array.
Definition array.hpp:37
void clear()
Reset the underlying BSON to an empty array.
Definition array.hpp:98
bsoncxx::v_noabi::array::view view() const
Definition array.hpp:68
array(array &&arr) noexcept
Move constructor.
Definition array.hpp:52
array()
Default constructor.
Definition array.hpp:42
bsoncxx::v_noabi::array::value extract()
Transfer ownership of the underlying array to the caller.
Definition array.hpp:91
array & operator=(array &&arr) noexcept
Move assignment operator.
Definition array.hpp:57
An internal class of builder::basic. Users should almost always construct a builder::basic::array ins...
Definition sub_array.hpp:41
sub_array(core *core)
Default constructor.
Definition sub_array.hpp:46
void append(Arg &&a, Args &&... args)
Appends multiple BSON values.
Definition sub_array.hpp:52
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
void clear()
Deletes the contents of the underlying BSON datum. After calling clear(), the state of this class wil...
bsoncxx::v_noabi::array::view view_array() const
Gets a view over the array.
bsoncxx::v_noabi::array::value extract_array()
Transfers ownership of the underlying document to the caller.
Provides bsoncxx::v_noabi::builder::core.
For internal use only!
Declares bsoncxx::v_noabi::builder::basic::kvp.
v_noabi::array::value make_array(Args &&... args)
bsoncxx::v_noabi::builder::basic::make_array
bsoncxx::v_noabi::array::value make_array(Args &&... args)
Creates an array from a list of elements.
Definition array.hpp:117
The top-level namespace within which all bsoncxx library entities are declared.
Provides bsoncxx::v_noabi::builder::basic::sub_array.