Loading...
Searching...
No Matches
document.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <bsoncxx/builder/basic/document-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/builder/basic/array-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/basic/impl.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/basic/kvp.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/basic/sub_document.hpp>
#include <bsoncxx/builder/core.hpp>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace builder {
namespace basic {
class document : public sub_document {
public:
document() : sub_document(&_core), _core(false) {}
~document() = default;
document(document&& doc) noexcept : sub_document(&_core), _core(std::move(doc._core)) {}
document& operator=(document&& doc) noexcept {
_core = std::move(doc._core);
return *this;
}
document(document const&) = delete;
document& operator=(document const&) = delete;
v_noabi::document::view view() const {
return _core.view_document();
}
operator v_noabi::document::view() const {
return view();
}
v_noabi::document::value extract() {
return _core.extract_document();
}
void clear() {
_core.clear();
}
private:
core _core;
};
template <typename... Args>
v_noabi::document::value make_document(Args&&... args) {
document document;
document.append(std::forward<Args>(args)...);
return document.extract();
}
} // namespace basic
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
namespace builder {
namespace basic {
using v_noabi::builder::basic::make_document;
} // namespace basic
} // namespace builder
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
array-fwd.hpp
Declares bsoncxx::v_noabi::builder::basic::array.
document-fwd.hpp
Declares bsoncxx::v_noabi::builder::basic::document.
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::builder::basic::document::document
document()
Default constructor.
Definition document.hpp:46
bsoncxx::v_noabi::builder::basic::document
A traditional builder-style interface for constructing a BSON document.
Definition document.hpp:41
bsoncxx::v_noabi::builder::basic::document::document
document(document &&doc) noexcept
Move constructor.
Definition document.hpp:53
bsoncxx::v_noabi::builder::basic::document::extract
v_noabi::document::value extract()
Transfer ownership of the underlying document to the caller.
Definition document.hpp:92
bsoncxx::v_noabi::builder::basic::document::document
document()
Default constructor.
Definition document.hpp:46
bsoncxx::v_noabi::builder::basic::document::view
v_noabi::document::view view() const
Definition document.hpp:69
bsoncxx::v_noabi::builder::basic::document::clear
void clear()
Reset the underlying BSON to an empty document.
Definition document.hpp:99
bsoncxx::v_noabi::builder::basic::document::operator=
document & operator=(document &&doc) noexcept
Move assignment operator.
Definition document.hpp:58
bsoncxx::v_noabi::builder::basic::sub_document::append
void append(Arg &&a, Args &&... args)
Appends multiple basic::kvp key-value pairs.
Definition sub_document.hpp:54
bsoncxx::v_noabi::builder::core
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
bsoncxx::v_noabi::document::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:40
core.hpp
Provides bsoncxx::v_noabi::builder::core.
impl.hpp
For internal use only!
kvp.hpp
Declares bsoncxx::v_noabi::builder::basic::kvp.
bsoncxx::builder::basic
Declares entities used with "basic" BSON builder syntax.
bsoncxx::builder
Declares entities used to build BSON documents.
bsoncxx::v_noabi::builder::basic
Declares entities used with "basic" BSON builder syntax.
bsoncxx::v_noabi::builder::basic::make_document
v_noabi::document::value make_document(Args &&... args)
Creates a document from a list of key-value pairs.
Definition document.hpp:118
bsoncxx::v_noabi::builder
Declares entities used to build BSON documents.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
sub_document.hpp
Provides bsoncxx::v_noabi::builder::basic::sub_document.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.