MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
impl.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
21
23
24namespace bsoncxx {
25namespace v_noabi {
26namespace builder {
27namespace basic {
28namespace impl {
29
30template <typename T>
31detail::requires_t<void, detail::is_invocable<T, sub_document>> generic_append(core* core, T&& func) {
32 core->open_document();
33 detail::invoke(std::forward<T>(func), sub_document{core});
34 core->close_document();
35}
36
37template <typename T, typename Placeholder = void> // placeholder 'void' for VS2015 compat
38detail::requires_t<void, detail::is_invocable<T, sub_array>> generic_append(core* core, T&& func) {
39 core->open_array();
40 detail::invoke(std::forward<T>(func), sub_array{core});
41 core->close_array();
42}
43
44template <typename T>
45detail::requires_t<void, detail::is_invocable<T, sub_binary>> generic_append(core* core, T&& func) {
46 // Opened by the user invoking `sub_binary::allocate()` in `func`.
47 detail::invoke(std::forward<T>(func), sub_binary{core});
48 core->close_binary();
49}
50
51template <typename T, typename = void, typename = void>
52detail::requires_not_t<
53 void,
54 detail::is_invocable<T, sub_document>,
55 detail::is_invocable<T, sub_array>,
56 detail::is_invocable<T, sub_binary>>
57generic_append(core* core, T&& t) {
58 core->append(std::forward<T>(t));
59}
60
61template <typename T>
62void value_append(core* core, T&& t) {
63 generic_append(core, std::forward<T>(t));
64}
65
66} // namespace impl
67} // namespace basic
68} // namespace builder
69} // namespace v_noabi
70} // namespace bsoncxx
71
73
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
Declares entities used with "basic" BSON builder syntax.
Declares entities used to build BSON documents.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all bsoncxx library entities are declared.
Provides bsoncxx::v_noabi::builder::basic::sub_array.
Declares bsoncxx::v_noabi::builder::basic::sub_binary.
Provides bsoncxx::v_noabi::builder::basic::sub_document.
For internal use only!