Loading...
Searching...
No Matches
single_context.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <bsoncxx/builder/stream/single_context-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/builder/core.hpp>
#include <bsoncxx/builder/stream/array_context.hpp>
#include <bsoncxx/builder/stream/key_context.hpp>
#include <bsoncxx/builder/stream/value_context.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace builder {
namespace stream {
class single_context {
public:
single_context(core* core) : _core(core) {}
key_context<> operator<<(open_document_type) {
_core->open_document();
return wrap_document();
}
array_context<> operator<<(open_array_type) {
_core->open_array();
return wrap_array();
}
template <class T>
void operator<<(T&& t) {
_core->append(std::forward<T>(t));
}
private:
array_context<> wrap_array() {
return array_context<>(_core);
}
key_context<> wrap_document() {
return key_context<>(_core);
}
core* _core;
};
template <class T>
array_context<T>::operator single_context() {
return single_context(_core);
}
template <class T>
value_context<T>::operator single_context() {
return single_context(_core);
}
} // namespace stream
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
array_context.hpp
Provides bsoncxx::v_noabi::builder::stream::array_context.
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::builder::stream::single_context::single_context
single_context(core *core)
Create a single_context given a core builder.
Definition single_context.hpp:46
bsoncxx::v_noabi::builder::core
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
bsoncxx::v_noabi::builder::core::open_document
core & open_document()
Opens a sub-document within this BSON datum.
bsoncxx::v_noabi::builder::core::open_array
core & open_array()
Opens a sub-array within this BSON datum.
bsoncxx::v_noabi::builder::stream::array_context<>
bsoncxx::v_noabi::builder::stream::array_context::array_context
array_context(core *core)
Create an array_context given a core builder.
Definition array_context.hpp:59
bsoncxx::v_noabi::builder::stream::key_context<>
bsoncxx::v_noabi::builder::stream::single_context
A stream context which appends a single value.
Definition single_context.hpp:38
bsoncxx::v_noabi::builder::stream::single_context::operator<<
key_context operator<<(open_document_type)
<< operator for opening a new subdocument in the core builder.
Definition single_context.hpp:53
bsoncxx::v_noabi::builder::stream::single_context::operator<<
void operator<<(T &&t)
<< operator for accepting a real value and appending it to the core builder.
Definition single_context.hpp:78
bsoncxx::v_noabi::builder::stream::single_context::single_context
single_context(core *core)
Create a single_context given a core builder.
Definition single_context.hpp:46
bsoncxx::v_noabi::builder::stream::value_context::value_context
value_context(core *core)
Create a value_context given a core builder.
Definition value_context.hpp:59
core.hpp
Provides bsoncxx::v_noabi::builder::core.
key_context.hpp
Provides bsoncxx::v_noabi::builder::stream::key_context.
bsoncxx::v_noabi::builder::stream
Declares entities used with "streaming" BSON builder syntax.
bsoncxx::v_noabi::builder
Declares entities used to build BSON documents.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
single_context-fwd.hpp
Declares bsoncxx::v_noabi::builder::stream::single_context.
bsoncxx::v_noabi::builder::stream::open_document_type
The type of a stream manipulator to open a subdocument.
Definition helpers.hpp:29
value_context.hpp
Provides bsoncxx::v_noabi::builder::stream::value_context.