MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
18
19//
20
22
29
31
32namespace bsoncxx {
33namespace v_noabi {
34namespace builder {
35namespace basic {
36
41class document : public sub_document {
42 public:
46 document() : sub_document(&_core), _core(false) {}
47
48 ~document() = default;
49
53 document(document&& doc) noexcept : sub_document(&_core), _core(std::move(doc._core)) {}
54
58 document& operator=(document&& doc) noexcept {
59 _core = std::move(doc._core);
60 return *this;
61 }
62
63 document(document const&) = delete;
64 document& operator=(document const&) = delete;
65
70 return _core.view_document();
71 }
72
80 return view();
81 }
82
93 return _core.extract_document();
94 }
95
99 void clear() {
100 _core.clear();
101 }
102
103 private:
104 core _core;
105};
106
117template <typename... Args>
120 document.append(std::forward<Args>(args)...);
121 return document.extract();
122}
123
124} // namespace basic
125} // namespace builder
126} // namespace v_noabi
127} // namespace bsoncxx
128
129namespace bsoncxx {
130namespace builder {
131namespace basic {
132
134
135} // namespace basic
136} // namespace builder
137} // namespace bsoncxx
138
140
Declares bsoncxx::v_noabi::builder::basic::array.
Declares bsoncxx::v_noabi::builder::basic::document.
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
document()
Default constructor.
Definition document.hpp:46
A traditional builder-style interface for constructing a BSON document.
Definition document.hpp:41
bsoncxx::v_noabi::document::value extract()
Transfer ownership of the underlying document to the caller.
Definition document.hpp:92
document(document &&doc) noexcept
Move constructor.
Definition document.hpp:53
document()
Default constructor.
Definition document.hpp:46
bsoncxx::v_noabi::document::view view() const
Definition document.hpp:69
void clear()
Reset the underlying BSON to an empty document.
Definition document.hpp:99
document & operator=(document &&doc) noexcept
Move assignment operator.
Definition document.hpp:58
void append(Arg &&a, Args &&... args)
Appends multiple basic::kvp key-value pairs.
Definition sub_document.hpp:54
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:39
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.
Declares entities used with "basic" BSON builder syntax.
Declares entities used to build BSON documents.
Declares entities used with "basic" BSON builder syntax.
bsoncxx::v_noabi::document::value make_document(Args &&... args)
Creates a document from a list of key-value pairs.
Definition document.hpp:118
Declares entities used to build BSON documents.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all bsoncxx library entities are declared.
Provides bsoncxx::v_noabi::builder::basic::sub_document.