Loading...
Searching...
No Matches
bsoncxx::builder::stream::key_context< base > Class Template Reference

`#include <bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp>`

## Description

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

A stream context which expects a key.

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

## Public Member Functions

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

## Constructor & Destructor Documentation

## key_context()

template<class base>

bsoncxx::v_noabi::builder::stream::key_context< base >::key_context | ( | core * | core | ) |

inline

Create a key_context given a core builder.

Parameters

  core | The core builder to orchestrate

## Member Function Documentation

## operator key_context<>()

template<class base>

bsoncxx::v_noabi::builder::stream::key_context< base >::operator key_context<> | ( |  | ) |

inline

Conversion operator which provides a rooted document given any stream currently in a nested key_context.

## operator<<() [1/7]

template<class base>
template<std::size_t n>

value_context< key_context > bsoncxx::v_noabi::builder::stream::key_context< base >::operator<< | ( | char const (&) | v[n] | ) |

inline

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

Parameters

  v | The key to append

Exceptions

  bsoncxx::v_noabi::exception | if the previous value appended to the builder was also a key.

## operator<<() [2/7]

template<class base>

base bsoncxx::v_noabi::builder::stream::key_context< base >::operator<< | ( | close_document_type const |  | ) |

inline

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

The argument must be a close_document_type token (it is otherwise ignored).

## operator<<() [3/7]

template<class base>

key_context bsoncxx::v_noabi::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

  doc | A document to concatenate

## operator<<() [4/7]

template<class base>

value_context< key_context > bsoncxx::v_noabi::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

  str | The key to append

Exceptions

  bsoncxx::v_noabi::exception | if the previous value appended to the builder was also a key.

## operator<<() [5/7]

template<class base>

value_context< key_context > bsoncxx::v_noabi::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

  str | The key to append

Exceptions

  bsoncxx::v_noabi::exception | if the previous value appended to the builder was also a key.

## operator<<() [6/7]

template<class base>
template<typename T>

detail::requires_t< v_noabi::document::value, std::is_same< base, closed_context >, detail::is_alike< T, finalize_type > > bsoncxx::v_noabi::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.

The argument must be a finalize_type token (it is otherwise ignored).

Returns
  A value type which holds the complete bson document.

## operator<<() [7/7]

template<class base>
template<typename T>

detail::requires_t< key_context &, detail::is_invocable< T, key_context > > bsoncxx::v_noabi::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

  func | The callback to invoke

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

- bsoncxx/v_noabi/bsoncxx/builder/stream/key_context-fwd.hpp
- bsoncxx/v_noabi/bsoncxx/builder/stream/key_context.hpp