MongoDB C++ Driver mongocxx-4.0.0
|
#include <bsoncxx/v_noabi/bsoncxx/document/value.hpp>
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.
Public Member Functions | |
template<typename T , detail::requires_not_t< int, std::is_same< T, array::view > > = 0> | |
value (const T &t) | |
Constructor used for serialization of user objects. This uses argument-dependent lookup to find the function declaration void to_bson(T& t, bsoncxx::v_noabi::document::value doc) . | |
value (document::view view) | |
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. | |
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. | |
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. | |
document::view::const_iterator | begin () const |
document::view::const_iterator | cbegin () const |
document::view::const_iterator | cend () const |
const std::uint8_t * | data () const |
Access the raw bytes of the underlying document. | |
bool | empty () const |
Checks if the underlying document is empty, i.e. it is equivalent to the trivial document '{}'. | |
document::view::const_iterator | end () const |
document::view::const_iterator | find (stdx::string_view key) const |
Finds the first element of the document with the provided key. If there is no such element, the past-the-end iterator will be returned. The runtime of find() is linear in the length of the document. This method only searches the top-level document, and will not recurse to any subdocuments. | |
template<typename T > | |
T | get () |
Constructs an object of type T from this document object. This method uses argument-dependent lookup to find the function declaration void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc) . | |
template<typename T > | |
void | get (T &t) |
Constructs an object of type T from this document object. This method uses argument-dependent lookup to find the function declaration void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc) . | |
std::size_t | length () const |
Gets the length of the underlying buffer. | |
operator document::view () const noexcept | |
Conversion operator that provides a view given a value. | |
element | operator[] (stdx::string_view key) const |
Finds the first element of the document with the provided key. If there is no such element, the invalid document::element will be returned. The runtime of operator[] is linear in the length of the document. | |
unique_ptr_type | release () |
Transfer ownership of the underlying buffer to the caller. | |
void | reset (document::view view) |
Replace the formerly-owned buffer with the new view. This will make a copy of the passed-in view. | |
document::view | view () const noexcept |
Get a view over the document owned by this value. | |
Related Symbols | |
(Note that these are not member symbols.) | |
bool | operator== (const value &lhs, const value &rhs) |
Compares two document values for (in)-equality. | |
bool | operator!= (const value &lhs, const value &rhs) |
Compares two document values for (in)-equality. | |
bsoncxx::v_noabi::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::v_noabi::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. |
|
inlineexplicit |
Constructor used for serialization of user objects. This uses argument-dependent lookup to find the function declaration void to_bson(T& t, bsoncxx::v_noabi::document::value doc)
.
t | A user-defined object to serialize into a BSON object. |
document::view::const_iterator bsoncxx::v_noabi::document::value::begin | ( | ) | const |
document::view::const_iterator bsoncxx::v_noabi::document::value::cbegin | ( | ) | const |
document::view::const_iterator bsoncxx::v_noabi::document::value::cend | ( | ) | const |
const std::uint8_t * bsoncxx::v_noabi::document::value::data | ( | ) | const |
Access the raw bytes of the underlying document.
bool bsoncxx::v_noabi::document::value::empty | ( | ) | const |
Checks if the underlying document is empty, i.e. it is equivalent to the trivial document '{}'.
document::view::const_iterator bsoncxx::v_noabi::document::value::end | ( | ) | const |
document::view::const_iterator bsoncxx::v_noabi::document::value::find | ( | stdx::string_view | key | ) | const |
Finds the first element of the document with the provided key. If there is no such element, the past-the-end iterator will be returned. The runtime of find() is linear in the length of the document. This method only searches the top-level document, and will not recurse to any subdocuments.
key | The key to search for. |
|
inline |
Constructs an object of type T from this document object. This method uses argument-dependent lookup to find the function declaration void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc)
.
void get(T& t)
.
|
inline |
Constructs an object of type T from this document object. This method uses argument-dependent lookup to find the function declaration void from_bson(T& t, const bsoncxx::v_noabi::document::view& doc)
.
t | The object to construct. The contents of the document object will be deserialized into t. |
std::size_t bsoncxx::v_noabi::document::value::length | ( | ) | const |
Gets the length of the underlying buffer.
|
inlinenoexcept |
Conversion operator that provides a view given a value.
element bsoncxx::v_noabi::document::value::operator[] | ( | stdx::string_view | key | ) | const |
Finds the first element of the document with the provided key. If there is no such element, the invalid document::element will be returned. The runtime of operator[] is linear in the length of the document.
key | The key to search for. |
unique_ptr_type bsoncxx::v_noabi::document::value::release | ( | ) |
Transfer ownership of the underlying buffer to the caller.
void bsoncxx::v_noabi::document::value::reset | ( | document::view | view | ) |
Replace the formerly-owned buffer with the new view. This will make a copy of the passed-in view.
|
inlinenoexcept |
Get a view over the document owned by this value.
Compares two document values for (in)-equality.
Compares two document values for (in)-equality.