Loading...
Searching...
No Matches
core.hpp
Go to the documentation of this file.
// Copyright 2009-present MongoDB, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <memory>
#include <stdexcept> // IWYU pragma: keep: backward compatibility, to be removed.
#include <string>
#include <type_traits> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/core-fwd.hpp> // IWYU pragma: export
#include <bsoncxx/array/value.hpp>
#include <bsoncxx/array/view.hpp>
#include <bsoncxx/document/value.hpp>
#include <bsoncxx/document/view.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <bsoncxx/stdx/type_traits.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/types.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace builder {
class core {
public:
class impl;
explicit BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() core(bool is_array);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() core(core&& rhs) noexcept;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) operator=(core&& rhs) noexcept;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE() ~core();
core(core const&) = delete;
core& operator=(core const&) = delete;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) key_view(stdx::string_view key);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) key_owned(std::string key);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) open_document();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) open_array();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) close_document();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) close_array();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) concatenate(v_noabi::document::view const& view);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_double const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_string const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_document const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_array const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_binary const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(uint8_t*) append(binary_sub_type sub_type, uint32_t length);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_undefined const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_oid const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_bool const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_date const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_null const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_regex const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_dbpointer const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_code const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_symbol const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_codewscope const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_int32 const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_timestamp const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_int64 const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_decimal128 const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_minkey const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::b_maxkey const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(types::bson_value::view const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(std::string str);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(stdx::string_view str);
template <typename T>
core& append(T* v) {
static_assert(detail::is_alike<T, char>::value, "append is disabled for non-char pointer types");
append(types::b_string{v});
return *this;
}
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(bool value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(double value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(std::int32_t value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(std::int64_t value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(oid const& value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(decimal128 value);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(v_noabi::document::view view);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) append(v_noabi::array::view view);
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::document::view) view_document() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::array::view) view_array() const;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::document::value) extract_document();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(v_noabi::array::value) extract_array();
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(void) clear();
core& open_binary() = delete;
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(core&) close_binary();
private:
std::unique_ptr<impl> _impl;
};
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
BSONCXX_ABI_EXPORT_CDECL_UNSTABLE
#define BSONCXX_ABI_EXPORT_CDECL_UNSTABLE(...)
Equivalent to BSONCXX_ABI_EXPORT_UNSTABLE with BSONCXX_ABI_CDECL.
Definition config.hpp:28
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::builder::core::core
core(bool is_array)
Constructs an empty BSON datum.
bsoncxx::v_noabi::array::value
A read-only BSON array that owns its underlying buffer.
Definition value.hpp:44
bsoncxx::v_noabi::array::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:41
bsoncxx::v_noabi::builder::core::append
core & append(types::b_double const &value)
Appends a BSON double.
bsoncxx::v_noabi::builder::core::append
core & append(v_noabi::document::view view)
Appends the given document view.
bsoncxx::v_noabi::builder::core::append
core & append(bool value)
Appends a native boolean as a BSON boolean.
bsoncxx::v_noabi::builder::core::concatenate
core & concatenate(v_noabi::document::view const &view)
Appends the keys from a BSON document into this BSON datum.
bsoncxx::v_noabi::builder::core::clear
void clear()
Deletes the contents of the underlying BSON datum. After calling clear(), the state of this class wil...
bsoncxx::v_noabi::builder::core::append
core & append(double value)
Appends a native double as a BSON double.
bsoncxx::v_noabi::builder::core::close_binary
core & close_binary()
Closes the current sub-binary within this BSON datum.
bsoncxx::v_noabi::builder::core::view_document
v_noabi::document::view view_document() const
Gets a view over the document.
bsoncxx::v_noabi::builder::core::append
core & append(decimal128 value)
Appends a decimal128 object as a BSON Decimal128.
bsoncxx::v_noabi::builder::core::append
core & append(std::int64_t value)
Appends a native int64_t as a BSON 64-bit signed integer.
bsoncxx::v_noabi::builder::core::key_owned
core & key_owned(std::string key)
Appends a key passed as an STL string. Transfers ownership of the key to this class.
bsoncxx::v_noabi::builder::core::core
core(bool is_array)
Constructs an empty BSON datum.
bsoncxx::v_noabi::builder::core::key_view
core & key_view(stdx::string_view key)
Appends a key passed as a non-owning stdx::string_view.
bsoncxx::v_noabi::builder::core::open_document
core & open_document()
Opens a sub-document within this BSON datum.
bsoncxx::v_noabi::builder::core::extract_array
v_noabi::array::value extract_array()
Transfers ownership of the underlying document to the caller.
bsoncxx::v_noabi::builder::core::close_array
core & close_array()
Closes the current sub-array within this BSON datum.
bsoncxx::v_noabi::builder::core::extract_document
v_noabi::document::value extract_document()
Transfers ownership of the underlying document to the caller.
bsoncxx::v_noabi::builder::core::open_binary
core & open_binary()=delete
A sub-binary must be opened by invoking bsoncxx::v_noabi::builder::basic::sub_binary::allocate().
bsoncxx::v_noabi::builder::core::append
core & append(std::int32_t value)
Appends a native int32_t as a BSON 32-bit signed integer.
bsoncxx::v_noabi::builder::core::append
core & append(v_noabi::array::view view)
Appends the given array view.
bsoncxx::v_noabi::builder::core::open_array
core & open_array()
Opens a sub-array within this BSON datum.
bsoncxx::v_noabi::builder::core::append
core & append(oid const &value)
Appends an oid as a BSON ObjectId.
bsoncxx::v_noabi::builder::core::close_document
core & close_document()
Closes the current sub-document within this BSON datum.
bsoncxx::v_noabi::builder::core::view_array
v_noabi::array::view view_array() const
Gets a view over the array.
bsoncxx::v_noabi::builder::document
A JSON-like builder for creating documents.
Definition list.hpp:149
bsoncxx::v_noabi::decimal128
Represents a MongoDB BSON Decimal128.
Definition decimal128.hpp:45
bsoncxx::v_noabi::document::value
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:48
bsoncxx::v_noabi::document::view
A read-only, non-owning view of a BSON document.
Definition view.hpp:40
bsoncxx::v_noabi::oid
Represents a MongoDB BSON ObjectId.
Definition oid.hpp:41
core-fwd.hpp
Declares bsoncxx::v_noabi::builder::core.
bsoncxx::v_noabi::builder
Declares entities used to build BSON documents.
bsoncxx::v_noabi::stdx
Declares C++17 standard library polyfills.
bsoncxx::v_noabi::types
Declares entities representing BSON value types.
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx::v_noabi::binary_sub_type
binary_sub_type
An enumeration of each BSON binary sub type.
Definition types.hpp:78
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
bsoncxx::v_noabi::types::b_string
A BSON UTF-8 encoded string value.
Definition types.hpp:177
types.hpp
Provides entities used to represent BSON types.
value.hpp
Provides bsoncxx::v_noabi::array::value.
view.hpp
Provides bsoncxx::v_noabi::array::view.
value.hpp
Provides bsoncxx::v_noabi::document::value.
view.hpp
Provides bsoncxx::v_noabi::document::view.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
type_traits.hpp
For internal use only!