MongoDB C++ Driver mongocxx-3.0.3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bsoncxx::builder::stream::key_context< base > Class Template Reference

A stream context which expects a key, which can later be followed by value, then more key/value pairs. More...

#include <key_context.hpp>

+ Inheritance diagram for bsoncxx::builder::stream::key_context< base >:

Public Member Functions

 key_context (core *core)
 Create a key_context given a core builder.
 
template<std::size_t n>
value_context< key_contextoperator<< (const char(&v)[n])
 << operator for accepting a literal key and appending it to the core builder.
 
value_context< key_contextoperator<< (std::string str)
 << operator for accepting a std::string key and appending it to the core builder.
 
value_context< key_contextoperator<< (stdx::string_view str)
 << operator for accepting a stdx::string_view key and appending it to the core builder.
 
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.
 
template<typename T >
std::enable_if< std::is_same< base, closed_context >::value &&std::is_same< typenamestd::remove_reference< T >::type, constfinalize_type >::value, bsoncxx::document::value >::type operator<< (T &&)
 << operator for finalizing the stream.
 
key_context operator<< (concatenate_doc doc)
 << operator for concatenating another document.
 
base operator<< (const close_document_type)
 << operator for closing a subdocument in the core builder.
 
 operator key_context ()
 Conversion operator which provides a rooted document given any stream currently in a nested key_context.
 

Detailed Description

template<class base = closed_context>
class bsoncxx::builder::stream::key_context< base >

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 << ...

Constructor & Destructor Documentation

◆ key_context()

template<class base = closed_context>
bsoncxx::builder::stream::key_context< base >::key_context ( core core)
inline

Create a key_context given a core builder.

Parameters
coreThe core builder to orchestrate

Member Function Documentation

◆ operator<<() [1/7]

template<class base = closed_context>
key_context bsoncxx::builder::stream::key_context< base >::operator<< ( concatenate_doc  doc)
inline

<< operator for concatenating another document.

This operation concatenates all of the keys and values from the passed document into the current stream.

Parameters
docA document to concatenate

◆ operator<<() [2/7]

template<class base = closed_context>
template<std::size_t n>
value_context< key_context > bsoncxx::builder::stream::key_context< base >::operator<< ( const char(&)  v[n])
inline

<< operator for accepting a literal key and appending it to the core builder.

Parameters
vThe key to append

◆ operator<<() [3/7]

template<class base = closed_context>
base bsoncxx::builder::stream::key_context< base >::operator<< ( const close_document_type  )
inline

<< operator for closing a subdocument in the core builder.

Parameters
_A close_document_type token

◆ operator<<() [4/7]

template<class base = closed_context>
value_context< key_context > bsoncxx::builder::stream::key_context< base >::operator<< ( std::string  str)
inline

<< operator for accepting a std::string key and appending it to the core builder.

Parameters
strThe key to append

◆ operator<<() [5/7]

template<class base = closed_context>
value_context< key_context > bsoncxx::builder::stream::key_context< base >::operator<< ( stdx::string_view  str)
inline

<< operator for accepting a stdx::string_view key and appending it to the core builder.

Parameters
strThe key to append

◆ operator<<() [6/7]

template<class base = closed_context>
template<typename T >
std::enable_if< std::is_same< base, closed_context >::value &&std::is_same< typenamestd::remove_reference< T >::type, constfinalize_type >::value, bsoncxx::document::value >::type bsoncxx::builder::stream::key_context< base >::operator<< ( T &&  )
inline

<< operator for finalizing the stream.

This operation finishes all processing necessary to fully encode the bson bytes and returns an owning value.

Parameters
_A finalize_type token
Returns
A value type which holds the complete bson document.

◆ operator<<() [7/7]

template<class base = closed_context>
template<typename T >
std::enable_if< util::is_functor< T, void(key_context<>)>::value, key_context >::type & bsoncxx::builder::stream::key_context< base >::operator<< ( T &&  func)
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.

Parameters
funcThe callback to invoke

The documentation for this class was generated from the following files: