MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
sub_array.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
22
24
25namespace bsoncxx {
26namespace v_noabi {
27namespace builder {
28namespace basic {
29
30namespace impl {
31
32template <typename T>
33void value_append(core* core, T&& t);
34
35} // namespace impl
36
41class sub_array {
42 public:
46 sub_array(core* core) : _core(core) {}
47
51 template <typename Arg, typename... Args>
52 void append(Arg&& a, Args&&... args) {
53 append_(std::forward<Arg>(a));
54 append(std::forward<Args>(args)...);
55 }
56
60 BSONCXX_INLINE
61 void append() {}
62
63 private:
64 //
65 // Appends a BSON value.
66 //
67 template <typename T>
68 void append_(T&& t) {
69 impl::value_append(_core, std::forward<T>(t));
70 }
71
72 //
73 // Concatenates another bson array directly.
74 //
75 BSONCXX_INLINE
76 void append_(concatenate_array array) {
77 _core->concatenate(array.view());
78 }
79
80 core* _core;
81};
82
83} // namespace basic
84} // namespace builder
85} // namespace v_noabi
86} // namespace bsoncxx
87
89
Redeclares bsoncxx::v_noabi::builder::concatenate in the bsoncxx::v_noabi::builder::basic namespace.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A JSON-like builder for creating arrays.
Definition list.hpp:185
An internal class of builder::basic. Users should almost always construct a builder::basic::array ins...
Definition sub_array.hpp:41
sub_array(core *core)
Default constructor.
Definition sub_array.hpp:46
void append(Arg &&a, Args &&... args)
Appends multiple BSON values.
Definition sub_array.hpp:52
BSONCXX_ABI_NO_EXPORT void append()
Inductive base-case for the variadic append(...)
Definition sub_array.hpp:61
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
core & concatenate(const bsoncxx::v_noabi::document::view &view)
Appends the keys from a BSON document into this BSON datum.
bson_value::view view()
Provides a view of the underlying BSON value.
Definition list.hpp:107
Provides concatenators for use with "streaming" BSON builder syntax.
Provides bsoncxx::v_noabi::builder::core.
The top-level namespace within which all bsoncxx library entities are declared.
Container to concatenate an array. Use this with the array stream builder in order to pass an array i...
Definition concatenate.hpp:60
Declares bsoncxx::v_noabi::builder::basic::sub_array.