MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
core.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
17#include <memory>
18#include <stdexcept>
19#include <string>
20#include <type_traits>
21
23
30#include <bsoncxx/types.hpp>
31
33
34namespace bsoncxx {
35namespace v_noabi {
36namespace builder {
37
46class core {
47 public:
48 class impl;
49
56 explicit BSONCXX_ABI_EXPORT_CDECL() core(bool is_array);
57
58 BSONCXX_ABI_EXPORT_CDECL() core(core&& rhs) noexcept;
59 BSONCXX_ABI_EXPORT_CDECL(core&) operator=(core&& rhs) noexcept;
60
62
63 core(core const&) = delete;
64 core& operator=(core const&) = delete;
65
87
102
115
128
139
150
169
182 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_double const& value);
183
196 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_string const& value);
197
210 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_document const& value);
211
224 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_array const& value);
225
238 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_binary const& value);
239
252 BSONCXX_ABI_EXPORT_CDECL(uint8_t*) append(binary_sub_type sub_type, uint32_t length);
253
266 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_undefined const& value);
267
281
294 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_bool const& value);
295
308 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_date const& value);
309
322 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_null const& value);
323
336 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_regex const& value);
337
350 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_dbpointer const& value);
351
364 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_code const& value);
365
378 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_symbol const& value);
379
392 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_codewscope const& value);
393
406 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_int32 const& value);
407
420 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_timestamp const& value);
421
434 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_int64 const& value);
435
448 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_decimal128 const& value);
449
462 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_minkey const& value);
463
476 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::b_maxkey const& value);
477
489 BSONCXX_ABI_EXPORT_CDECL(core&) append(types::bson_value::view const& value);
490
503
516
530 template <typename T>
531 core& append(T* v) {
532 static_assert(detail::is_alike<T, char>::value, "append is disabled for non-char pointer types");
534
535 return *this;
536 }
537
550
563
575 BSONCXX_ABI_EXPORT_CDECL(core&) append(std::int32_t value);
576
588 BSONCXX_ABI_EXPORT_CDECL(core&) append(std::int64_t value);
589
602
615
628
641
655
668
686
703
709
713 core& open_binary() = delete;
714
725
726 private:
727 std::unique_ptr<impl> _impl;
728};
729
730} // namespace builder
731} // namespace v_noabi
732} // namespace bsoncxx
733
735
Provides bsoncxx::v_noabi::array::value.
Provides bsoncxx::v_noabi::array::view.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v_noabi macro guard postlude header.
The bsoncxx v_noabi macro guard prelude header.
core(bool is_array)
Constructs an empty BSON datum.
A read-only BSON array that owns its underlying buffer.
Definition value.hpp:37
A read-only, non-owning view of a BSON document.
Definition view.hpp:36
core & append(types::b_double const &value)
Appends a BSON double.
core & append(bool value)
Appends a native boolean as a BSON boolean.
void clear()
Deletes the contents of the underlying BSON datum. After calling clear(), the state of this class wil...
core & append(double value)
Appends a native double as a BSON double.
core & close_binary()
Closes the current sub-binary within this BSON datum.
bsoncxx::v_noabi::array::view view_array() const
Gets a view over the array.
bsoncxx::v_noabi::array::value extract_array()
Transfers ownership of the underlying document to the caller.
core & append(decimal128 value)
Appends a decimal128 object as a BSON Decimal128.
core & append(std::int64_t value)
Appends a native int64_t as a BSON 64-bit signed integer.
core & append(bsoncxx::v_noabi::document::view view)
Appends the given document view.
core & append(bsoncxx::v_noabi::array::view view)
Appends the given array view.
core & key_owned(std::string key)
Appends a key passed as an STL string. Transfers ownership of the key to this class.
core(bool is_array)
Constructs an empty BSON datum.
core & key_view(stdx::string_view key)
Appends a key passed as a non-owning stdx::string_view.
core & open_document()
Opens a sub-document within this BSON datum.
core & close_array()
Closes the current sub-array within this BSON datum.
core & open_binary()=delete
A sub-binary must be opened by invoking bsoncxx::v_noabi::builder::basic::sub_binary::allocate()
bsoncxx::v_noabi::document::value extract_document()
Transfers ownership of the underlying document to the caller.
core & concatenate(bsoncxx::v_noabi::document::view const &view)
Appends the keys from a BSON document into this BSON datum.
core & append(std::int32_t value)
Appends a native int32_t as a BSON 32-bit signed integer.
core & open_array()
Opens a sub-array within this BSON datum.
core & append(oid const &value)
Appends an oid as a BSON ObjectId.
core & close_document()
Closes the current sub-document within this BSON datum.
bsoncxx::v_noabi::document::view view_document() const
Gets a view over the document.
A JSON-like builder for creating documents.
Definition list.hpp:149
Represents a MongoDB BSON Decimal128.
Definition decimal128.hpp:40
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:39
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Represents a MongoDB BSON ObjectId.
Definition oid.hpp:36
Declares bsoncxx::v_noabi::builder::core.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
Declares entities used to build BSON documents.
Declares C++17 standard library polyfills.
Declares entities representing BSON value types.
Declares entities whose ABI stability is NOT guaranteed.
binary_sub_type
An enumeration of each BSON binary sub type.
Definition types.hpp:72
The top-level namespace within which all bsoncxx library entities are declared.
A BSON UTF-8 encoded string value.
Definition types.hpp:136
Provides entities used to represent BSON types.
Provides std::string_view-related polyfills for library API usage.
For internal use only!