Loading...
Searching...
No Matches
array.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/array-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/array/value.hpp>
#include <bsoncxx/array/view.hpp>
#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_array.hpp>
#include <bsoncxx/builder/core.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace builder {
namespace basic {
class array : public sub_array {
public:
array() : sub_array(&_core), _core(true) {}
~array() = default;
array(array&& arr) noexcept : sub_array(&_core), _core(std::move(arr._core)) {}
array& operator=(array&& arr) noexcept {
_core = std::move(arr._core);
return *this;
}
array(array const&) = delete;
array& operator=(array const&) = delete;
v_noabi::array::view view() const {
return _core.view_array();
}
operator v_noabi::array::view() const {
return view();
}
v_noabi::array::value extract() {
return _core.extract_array();
}
void clear() {
_core.clear();
}
private:
core _core;
};
template <typename... Args>
v_noabi::array::value make_array(Args&&... args) {
array array;
array.append(std::forward<Args>(args)...);
return array.extract();
}
} // namespace basic
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
namespace builder {
namespace basic {
using v_noabi::builder::basic::make_array;
} // namespace basic
} // namespace builder
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
array-fwd.hpp
Declares bsoncxx::v_noabi::builder::basic::array.
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::builder::basic::array::array
array()
Default constructor.
Definition array.hpp:42
bsoncxx::v_noabi::array::value
A read-only BSON array that owns its underlying buffer.
Definition value.hpp:44
bsoncxx::v_noabi::array::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:41
bsoncxx::v_noabi::builder::basic::array
A traditional builder-style interface for constructing a BSON array.
Definition array.hpp:37
bsoncxx::v_noabi::builder::basic::array::~array
~array()=default
Destructor.
bsoncxx::v_noabi::builder::basic::array::clear
void clear()
Reset the underlying BSON to an empty array.
Definition array.hpp:98
bsoncxx::v_noabi::builder::basic::array::extract
v_noabi::array::value extract()
Transfer ownership of the underlying array to the caller.
Definition array.hpp:91
bsoncxx::v_noabi::builder::basic::array::array
array(array &&arr) noexcept
Move constructor.
Definition array.hpp:52
bsoncxx::v_noabi::builder::basic::array::array
array()
Default constructor.
Definition array.hpp:42
bsoncxx::v_noabi::builder::basic::array::view
v_noabi::array::view view() const
Definition array.hpp:68
bsoncxx::v_noabi::builder::basic::array::operator=
array & operator=(array &&arr) noexcept
Move assignment operator.
Definition array.hpp:57
bsoncxx::v_noabi::builder::basic::sub_array::sub_array
sub_array(core *core)
Default constructor.
Definition sub_array.hpp:49
bsoncxx::v_noabi::builder::basic::sub_array::append
void append(Arg &&a, Args &&... args)
Appends multiple BSON values.
Definition sub_array.hpp:55
bsoncxx::v_noabi::builder::core
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
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_array
v_noabi::array::value make_array(Args &&... args)
Creates an array from a list of elements.
Definition array.hpp:117
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_array.hpp
Provides bsoncxx::v_noabi::builder::basic::sub_array.
value.hpp
Provides bsoncxx::v_noabi::array::value.
view.hpp
Provides bsoncxx::v_noabi::array::view.