MongoDB C++ Driver  mongocxx-3.10.2
core.hpp
1 // Copyright 2014 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 <type_traits>
20 
21 #include <bsoncxx/builder/core-fwd.hpp>
22 
23 #include <bsoncxx/array/value.hpp>
24 #include <bsoncxx/array/view.hpp>
25 #include <bsoncxx/document/value.hpp>
26 #include <bsoncxx/document/view.hpp>
27 #include <bsoncxx/stdx/string_view.hpp>
28 #include <bsoncxx/stdx/type_traits.hpp>
29 #include <bsoncxx/types.hpp>
30 
31 #include <bsoncxx/config/prelude.hpp>
32 
33 namespace bsoncxx {
34 namespace v_noabi {
35 namespace builder {
36 
45 class core {
46  public:
47  class BSONCXX_PRIVATE impl;
48 
55  explicit core(bool is_array);
56 
57  core(core&& rhs) noexcept;
58  core& operator=(core&& rhs) noexcept;
59 
60  ~core();
61 
82  core& key_view(stdx::string_view key);
83 
97  core& key_owned(std::string key);
98 
111 
124 
135 
146 
165 
178  core& append(const types::b_double& value);
179 
192  core& append(const types::b_string& value);
193 
206  core& append(const types::b_document& value);
207 
220  core& append(const types::b_array& value);
221 
234  core& append(const types::b_binary& value);
235 
249 
262  core& append(const types::b_oid& value);
263 
276  core& append(const types::b_bool& value);
277 
290  core& append(const types::b_date& value);
291 
304  core& append(const types::b_null& value);
305 
318  core& append(const types::b_regex& value);
319 
333 
346  core& append(const types::b_code& value);
347 
360  core& append(const types::b_symbol& value);
361 
375 
388  core& append(const types::b_int32& value);
389 
403 
416  core& append(const types::b_int64& value);
417 
431 
444  core& append(const types::b_minkey& value);
445 
458  core& append(const types::b_maxkey& value);
459 
472 
484  core& append(std::string str);
485 
497  core& append(stdx::string_view str);
498 
512  template <typename T>
513  BSONCXX_INLINE core& append(T* v) {
514  static_assert(detail::is_alike<T, char>::value,
515  "append is disabled for non-char pointer types");
517 
518  return *this;
519  }
520 
532  core& append(bool value);
533 
545  core& append(double value);
546 
558  core& append(std::int32_t value);
559 
571  core& append(std::int64_t value);
572 
584  core& append(const oid& value);
585 
598 
611 
624 
638 
651 
669 
686 
691  void clear();
692 
693  private:
694  std::unique_ptr<impl> _impl;
695 };
696 
697 } // namespace builder
698 } // namespace v_noabi
699 } // namespace bsoncxx
700 
701 #include <bsoncxx/config/postlude.hpp>
A read-only BSON array that owns its underlying buffer.
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:45
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.
core & append(T *v)
Appends a char* or const char*.
Definition: core.hpp:513
core & append(std::string str)
Appends an STL string as a BSON UTF-8 string.
core & append(const types::b_binary &value)
Appends a BSON binary datum.
void clear()
Deletes the contents of the underlying BSON datum.
core & append(const types::b_maxkey &value)
Appends a BSON max-key.
core & append(bsoncxx::v_noabi::document::view view)
Appends the given document view.
core & append(std::int32_t value)
Appends a native int32_t as a BSON 32-bit signed integer.
bsoncxx::v_noabi::array::view view_array() const
Gets a view over the array.
core & append(stdx::string_view str)
Appends a string view as a BSON UTF-8 string.
core & append(const types::b_code &value)
Appends a BSON JavaScript code.
core & append(const types::b_timestamp &value)
Appends a BSON replication timestamp.
core & append(const types::b_bool &value)
Appends a BSON boolean.
core & append(const types::b_double &value)
Appends a BSON double.
core & append(decimal128 value)
Appends a decimal128 object as a BSON Decimal128.
bsoncxx::v_noabi::array::value extract_array()
Transfers ownership of the underlying document to the caller.
core & close_document()
Closes the current sub-document within this BSON datum.
core & append(const types::b_array &value)
Appends a BSON array.
core & append(const types::b_date &value)
Appends a BSON date.
core & concatenate(const bsoncxx::v_noabi::document::view &view)
Appends the keys from a BSON document into this BSON datum.
core & append(const types::b_minkey &value)
Appends a BSON min-key.
core & open_array()
Opens a sub-array within this BSON datum.
core & append(const types::b_oid &value)
Appends a BSON ObjectId.
core & append(const types::b_null &value)
Appends a BSON null.
core & append(const types::b_int32 &value)
Appends a BSON 32-bit signed integer.
core(bool is_array)
Constructs an empty BSON datum.
core & append(double value)
Appends a native double as a BSON double.
core & append(const types::b_int64 &value)
Appends a BSON 64-bit signed integer.
core & append(const types::b_document &value)
Appends a BSON document.
core & append(const types::b_string &value)
Append a BSON UTF-8 string.
core & append(const types::b_symbol &value)
Appends a BSON symbol.
core & append(const types::b_regex &value)
Appends a BSON regex.
core & open_document()
Opens a sub-document within this BSON datum.
bsoncxx::v_noabi::document::value extract_document()
Transfers ownership of the underlying document to the caller.
core & append(const oid &value)
Appends an oid as a BSON ObjectId.
core & append(std::int64_t value)
Appends a native int64_t as a BSON 64-bit signed integer.
core & append(const types::b_dbpointer &value)
Appends a BSON DBPointer.
core & append(const types::b_decimal128 &value)
Appends a BSON Decimal128.
core & append(const types::b_undefined &value)
Appends a BSON undefined.
core & close_array()
Closes the current sub-array within this BSON datum.
core & append(const types::b_codewscope &value)
Appends a BSON JavaScript code with scope.
bsoncxx::v_noabi::document::view view_document() const
Gets a view over the document.
core & append(const types::bson_value::view &value)
Appends a BSON variant value.
core & append(bool value)
Appends a native boolean as a BSON boolean.
core & key_view(stdx::string_view key)
Appends a key passed as a non-owning stdx::string_view.
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.
Definition: value.hpp:38
A read-only, non-owning view of a BSON document.
Definition: view.hpp:35
Represents a MongoDB ObjectId.
Definition: oid.hpp:40
A view-only variant that can contain any BSON type.
Definition: view.hpp:41
The top-level namespace for bsoncxx library entities.
Definition: element-fwd.hpp:19
A BSON array value.
Definition: types.hpp:197
A BSON binary data value.
Definition: types.hpp:222
A BSON boolean value.
Definition: types.hpp:280
A BSON JavaScript code value.
Definition: types.hpp:436
A BSON JavaScript code with scope value.
Definition: types.hpp:507
A BSON date value.
Definition: types.hpp:305
A BSON DBPointer value.
Definition: types.hpp:417
A BSON Decimal128 value.
Definition: types.hpp:610
A BSON document value.
Definition: types.hpp:165
A BSON double value.
Definition: types.hpp:99
A BSON signed 32-bit integer value.
Definition: types.hpp:541
A BSON 64-bit signed integer value.
Definition: types.hpp:585
A BSON max-key value.
Definition: types.hpp:653
A BSON min-key value.
Definition: types.hpp:637
A BSON null value.
Definition: types.hpp:364
A BSON ObjectId value.
Definition: types.hpp:262
A BSON regex value.
Definition: types.hpp:380
A BSON UTF-8 encoded string value.
Definition: types.hpp:124
A BSON Symbol value.
Definition: types.hpp:473
A BSON replication timestamp value.
Definition: types.hpp:566
A BSON undefined value.
Definition: types.hpp:246