MongoDB C++ Driver
mongocxx-3.0.2
|
A read-only BSON document that owns its underlying buffer. More...
#include <value.hpp>
Public Member Functions | |
value (std::uint8_t *data, std::size_t length, deleter_type dtor) | |
Constructs a value from a buffer. More... | |
value (unique_ptr_type ptr, std::size_t length) | |
Constructs a value from a std::unique_ptr to a buffer. More... | |
value (document::view view) | |
Constructs a value from a view of a document. More... | |
document::view | view () const noexcept |
Get a view over the document owned by this value. | |
operator document::view () const noexcept | |
Conversion operator that provides a view given a value. More... | |
unique_ptr_type | release () |
Transfer ownership of the underlying buffer to the caller. More... | |
A read-only BSON document that owns its underlying buffer.
When a document::value goes out of scope, the underlying buffer is freed. Generally this class should be used sparingly; document::view should be used instead wherever possible.
bsoncxx::document::value::value | ( | std::uint8_t * | data, |
std::size_t | length, | ||
deleter_type | dtor | ||
) |
Constructs a value from a buffer.
This constructor transfers ownership of the buffer to the resulting value. A user-provided deleter is used to destroy the buffer.
data | A pointer to a buffer containing a valid BSON document. |
length | The length of the document. |
dtor | A user provided deleter. |
bsoncxx::document::value::value | ( | unique_ptr_type | ptr, |
std::size_t | length | ||
) |
Constructs a value from a std::unique_ptr to a buffer.
The ownership of the buffer is transferred to the constructed value.
ptr | A pointer to a buffer containing a valid BSON document. |
length | The length of the document. |
|
explicit |
Constructs a value from a view of a document.
The data referenced by the document::view will be copied into a new buffer managed by the constructed value.
view | A view of another document to copy. |
|
noexcept |
Conversion operator that provides a view given a value.
unique_ptr_type bsoncxx::document::value::release | ( | ) |
Transfer ownership of the underlying buffer to the caller.