MongoDB C++ Driver
mongocxx-3.0.1
|
A stream context which expects a key, which can later be followed by value, then more key/value pairs. More...
#include <key_context.hpp>
Public Member Functions | |
key_context (core *core) | |
Create a key_context given a core builder. More... | |
template<std::size_t n> | |
value_context< key_context > | operator<< (const char(&v)[n]) |
<< operator for accepting a literal key and appending it to the core builder. More... | |
value_context< key_context > | operator<< (std::string str) |
<< operator for accepting a std::string key and appending it to the core builder. More... | |
value_context< key_context > | operator<< (stdx::string_view str) |
<< operator for accepting a stdx::string_view key and appending it to the core builder. More... | |
template<typename T > | |
std::enable_if< util::is_functor< T, void(key_context<>)>::value, key_context >::type & | operator<< (T &&func) |
<< operator for accepting a callable of the form void(key_context) and invoking it to perform 1 or more key, value appends to the core builder. More... | |
template<typename T > | |
std::enable_if< std::is_same< base, closed_context >::value &&std::is_same< typename std::remove_reference< T >::type, const finalize_type >::value, bsoncxx::document::value >::type | operator<< (T &&) |
<< operator for finalizing the stream. More... | |
key_context | operator<< (concatenate_doc doc) |
<< operator for concatenating another document. More... | |
base | operator<< (const close_document_type) |
<< operator for closing a subdocument in the core builder. More... | |
operator key_context () | |
Conversion operator which provides a rooted document given any stream currently in a nested key_context. | |
A stream context which expects a key, which can later be followed by value, then more key/value pairs.
The template argument can be used to hold additional information about containing documents or arrays. I.e. value_context<> implies that this document is a sub_document in a document, while array_context would indicated a sub_document in an array. These types can be nested, such that contextual parsing (for key/value pairs) and depth (to prevent an invalid document_close) are enforced by the type system.
When in document context, the first parameter will be in key_context, then in value_context, then in key_context, etc.
I.e. builder << key_context << value_context << key_context << ...
|
inline |
Create a key_context given a core builder.
core | The core builder to orchestrate |
|
inline |
<< operator for accepting a literal key and appending it to the core builder.
v | The key to append |
|
inline |
<< operator for accepting a std::string key and appending it to the core builder.
str | The key to append |
|
inline |
<< operator for accepting a stdx::string_view key and appending it to the core builder.
str | The key to append |
|
inline |
<< operator for accepting a callable of the form void(key_context) and invoking it to perform 1 or more key, value appends to the core builder.
func | The callback to invoke |
|
inline |
<< operator for finalizing the stream.
This operation finishes all processing necessary to fully encode the bson bytes and returns an owning value.
_ | A finalize_type token |
|
inline |
<< operator for concatenating another document.
This operation concatenates all of the keys and values from the passed document into the current stream.
doc | A document to concatenate |
|
inline |
<< operator for closing a subdocument in the core builder.
_ | A close_document_type token |