MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
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(const core&) = delete;
64 core& operator=(const core&) = delete;
65
86 BSONCXX_ABI_EXPORT_CDECL(core&) key_view(stdx::string_view key);
87
102
115
128
139
150
169
182 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_double& value);
183
196 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_string& value);
197
210 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_document& value);
211
224 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_array& value);
225
238 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_binary& value);
239
252 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_undefined& value);
253
266 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_oid& value);
267
280 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_bool& value);
281
294 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_date& value);
295
308 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_null& value);
309
322 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_regex& value);
323
336 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_dbpointer& value);
337
350 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_code& value);
351
364 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_symbol& value);
365
378 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_codewscope& value);
379
392 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_int32& value);
393
406 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_timestamp& value);
407
420 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_int64& value);
421
434 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_decimal128& value);
435
448 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_minkey& value);
449
462 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::b_maxkey& value);
463
475 BSONCXX_ABI_EXPORT_CDECL(core&) append(const types::bson_value::view& value);
476
489
501 BSONCXX_ABI_EXPORT_CDECL(core&) append(stdx::string_view str);
502
516 template <typename T>
517 core& append(T* v) {
518 static_assert(detail::is_alike<T, char>::value,
519 "append is disabled for non-char pointer types");
521
522 return *this;
523 }
524
537
550
562 BSONCXX_ABI_EXPORT_CDECL(core&) append(std::int32_t value);
563
575 BSONCXX_ABI_EXPORT_CDECL(core&) append(std::int64_t value);
576
589
602
615
628
642
655
673
690
696
697 private:
698 std::unique_ptr<impl> _impl;
699};
700
701} // namespace builder
702} // namespace v_noabi
703} // namespace bsoncxx
704
706
Provides bsoncxx::v_noabi::array::value.
Provides bsoncxx::v_noabi::array::view.
The bsoncxx macro guard postlude header.
The bsoncxx macro guard prelude header.
A read-only BSON array that owns its underlying buffer. When a array::value goes out of scope,...
Definition value.hpp:36
A read-only, non-owning view of a BSON document.
Definition view.hpp:36
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
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 & append(const oid &value)
Appends an oid as a BSON ObjectId.
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 & key_view(stdx::string_view key)
Appends a key passed as a non-owning stdx::string_view.
core & append(const types::b_double &value)
Appends a BSON double.
core & open_document()
Opens a sub-document within this BSON datum.
core & close_array()
Closes the current sub-array within this BSON datum.
core & concatenate(const bsoncxx::v_noabi::document::view &view)
Appends the keys from a BSON document into this BSON datum.
bsoncxx::v_noabi::document::value extract_document()
Transfers ownership of the underlying document to the caller.
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 & 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:160
Represents an IEEE 754-2008 BSON Decimal128 value in a platform-independent way.
Definition decimal128.hpp:32
A read-only BSON document that owns its underlying buffer. When a document::value goes out of scope,...
Definition value.hpp:38
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Represents a MongoDB ObjectId. As this BSON type is used within the MongoDB server as a primary key f...
Definition oid.hpp:41
Declares bsoncxx::v_noabi::builder::core.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition fwd.hpp:225
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace reserved for the C++ standard library.
Provides std::string_view-related polyfills for library API usage.
A BSON UTF-8 encoded string value.
Definition types.hpp:136
Provides <type_traits>-related polyfills for internal use.
Provides entities used to represent BSON types.