MongoDB C++ Driver mongocxx-4.0.0
Loading...
Searching...
No Matches
document.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
19
26
28
29namespace bsoncxx {
30namespace v_noabi {
31namespace builder {
32namespace basic {
33
38class document : public sub_document {
39 public:
43 document() : sub_document(&_core), _core(false) {}
44
45 ~document() = default;
46
50 document(document&& doc) noexcept : sub_document(&_core), _core(std::move(doc._core)) {}
51
55 document& operator=(document&& doc) noexcept {
56 _core = std::move(doc._core);
57 return *this;
58 }
59
60 document(const document&) = delete;
61 document& operator=(const document&) = delete;
62
67 return _core.view_document();
68 }
69
77 return view();
78 }
79
92
96 void clear() {
97 _core.clear();
98 }
99
100 private:
101 core _core;
102};
103
114template <typename... Args>
117 document.append(std::forward<Args>(args)...);
118 return document.extract();
119}
120
121} // namespace basic
122} // namespace builder
123} // namespace v_noabi
124} // namespace bsoncxx
125
126namespace bsoncxx {
127namespace builder {
128namespace basic {
129
130using ::bsoncxx::v_noabi::builder::basic::make_document;
131
132} // namespace basic
133} // namespace builder
134} // namespace bsoncxx
135
137
142
143#if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
144
145namespace bsoncxx {
146namespace builder {
147namespace basic {
148
150template <typename... Args>
152
153} // namespace basic
154} // namespace builder
155} // namespace bsoncxx
156
157#endif // defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
Declares bsoncxx::v_noabi::builder::basic::array.
Declares bsoncxx::v_noabi::builder::basic::document.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A traditional builder-style interface for constructing a BSON document.
Definition document.hpp:38
bsoncxx::v_noabi::document::value extract()
Transfer ownership of the underlying document to the caller.
Definition document.hpp:89
document(document &&doc) noexcept
Move constructor.
Definition document.hpp:50
document()
Default constructor.
Definition document.hpp:43
bsoncxx::v_noabi::document::view view() const
Definition document.hpp:66
void clear()
Reset the underlying BSON to an empty document.
Definition document.hpp:96
document & operator=(document &&doc) noexcept
Move assignment operator.
Definition document.hpp:55
An internal class of builder::basic. Users should almost always construct a builder::basic::document ...
Definition sub_document.hpp:43
void append(Arg &&a, Args &&... args)
Appends multiple basic::kvp key-value pairs.
Definition sub_document.hpp:51
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::document::value extract_document()
Transfers ownership of the underlying document to the caller.
bsoncxx::v_noabi::document::view view_document() const
Gets a view over the document.
A read-only BSON document that owns its underlying buffer. When a document::value goes out of scope,...
Definition value.hpp:38
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Provides bsoncxx::v_noabi::builder::core.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
For internal use only!
Declares bsoncxx::v_noabi::builder::basic::kvp.
v_noabi::document::value make_document(Args &&... args)
bsoncxx::v_noabi::builder::basic::make_document
bsoncxx::v_noabi::document::value make_document(Args &&... args)
Creates a document from a list of key-value pairs.
Definition document.hpp:115
The top-level namespace within which all bsoncxx library entities are declared.
Provides bsoncxx::v_noabi::builder::basic::sub_document.