MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
single_context.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
18
23
25
26namespace bsoncxx {
27namespace v_noabi {
28namespace builder {
29namespace stream {
30
39 public:
47
54 _core->open_document();
55
56 return wrap_document();
57 }
58
64 array_context<> operator<<(open_array_type) {
65 _core->open_array();
66
67 return wrap_array();
68 }
69
77 template <class T>
78 void operator<<(T&& t) {
79 _core->append(std::forward<T>(t));
80 }
81
82 private:
83 array_context<> wrap_array() {
84 return array_context<>(_core);
85 }
86
87 key_context<> wrap_document() {
88 return key_context<>(_core);
89 }
90
91 core* _core;
92};
93
97template <class T>
101
105template <class T>
109
110} // namespace stream
111} // namespace builder
112} // namespace v_noabi
113} // namespace bsoncxx
114
116
Provides bsoncxx::v_noabi::builder::stream::array_context.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
core & append(const types::b_double &value)
Appends a BSON double.
core & open_document()
Opens a sub-document within this BSON datum.
core & open_array()
Opens a sub-array within this BSON datum.
A stream context which appends a single value.
Definition single_context.hpp:38
key_context operator<<(open_document_type)
<< operator for opening a new subdocument in the core builder.
Definition single_context.hpp:53
void operator<<(T &&t)
<< operator for accepting a real value and appending it to the core builder.
Definition single_context.hpp:78
single_context(core *core)
Create a single_context given a core builder.
Definition single_context.hpp:46
A stream context which expects a value, which can later be followed by more key/value pairs.
Definition value_context.hpp:50
Provides bsoncxx::v_noabi::builder::core.
Provides bsoncxx::v_noabi::builder::stream::key_context.
The top-level namespace within which all bsoncxx library entities are declared.
Declares bsoncxx::v_noabi::builder::stream::single_context.
The type of a stream manipulator to open a subdocument.
Definition helpers.hpp:32
Provides bsoncxx::v_noabi::builder::stream::value_context.