20#include <bsoncxx/array/view.hpp>
21#include <bsoncxx/document/view.hpp>
23#include <bsoncxx/config/prelude.hpp>
26BSONCXX_INLINE_NAMESPACE_BEGIN
36 using deleter_type = void (*)(std::uint8_t*);
37 using unique_ptr_type = std::unique_ptr<uint8_t[], deleter_type>;
51 value(std::uint8_t* data, std::size_t length, deleter_type dtor);
62 value(unique_ptr_type ptr, std::size_t length);
88 typename std::enable_if<!std::is_same<T, typename array::
view>::
value,
int>::
type = 0>
93 value& operator=(
const T& t) {
152 const std::uint8_t*
data()
const;
182 BSONCXX_INLINE operator document::
view() const noexcept;
191 template <typename T>
194 from_bson(temp, this->
view());
207 template <
typename T>
209 from_bson(t, this->
view());
230 unique_ptr_type _data;
231 std::size_t _length{0};
235 return document::view{
static_cast<uint8_t*
>(_data.get()), _length};
253BSONCXX_INLINE
bool operator!=(
const value& lhs,
const value& rhs) {
254 return !(lhs == rhs);
262BSONCXX_INLINE_NAMESPACE_END
265#include <bsoncxx/config/postlude.hpp>
A variant view type that accesses values in serialized BSON documents.
Definition element.hpp:76
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:34
void get(T &t)
Constructs an object of type T from this document object.
Definition value.hpp:208
bool empty() const
Checks if the underlying document is empty, i.e.
void reset(document::view view)
Replace the formerly-owned buffer with the new view.
unique_ptr_type release()
Transfer ownership of the underlying buffer to the caller.
value(std::uint8_t *data, std::size_t length, deleter_type dtor)
Constructs a value from a buffer.
document::view::const_iterator begin() const
std::size_t length() const
Gets the length of the underlying buffer.
document::view::const_iterator find(stdx::string_view key) const
Finds the first element of the document with the provided key.
document::view::const_iterator cbegin() const
bool operator==(const value &lhs, const value &rhs)
Compares two document values for (in)-equality.
Definition value.hpp:249
document::view::const_iterator cend() const
document::view view() const noexcept
Get a view over the document owned by this value.
Definition value.hpp:234
value(unique_ptr_type ptr, std::size_t length)
Constructs a value from a std::unique_ptr to a buffer.
element operator[](stdx::string_view key) const
Finds the first element of the document with the provided key.
const std::uint8_t * data() const
Access the raw bytes of the underlying document.
document::view::const_iterator end() const
value(document::view view)
Constructs a value from a view of a document.
A const iterator over the contents of a document view.
Definition view.hpp:153
A read-only, non-owning view of a BSON document.
Definition view.hpp:33
Top level namespace for MongoDB C++ BSON functionality.
Definition element.hpp:24
type
An enumeration of each BSON type.
Definition types.hpp:46