Loading...
Searching...
No Matches
sub_binary.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 <bsoncxx/builder/basic/sub_binary-fwd.hpp> // IWYU pragma: export
//
#include <cstdint>
#include <bsoncxx/vector/accessor-fwd.hpp>
#include <bsoncxx/vector/detail-fwd.hpp>
#include <bsoncxx/vector/formats-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/builder/core.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace builder {
namespace basic {
class sub_binary {
public:
sub_binary(core* core) : _core{core} {}
std::uint8_t* allocate(binary_sub_type sub_type, std::uint32_t length) {
return _core->append(sub_type, length);
}
template <typename Format, typename SFINAE = typename vector::detail::format_traits<Format>::value_type>
vector::accessor<Format> allocate(Format fmt, std::size_t element_count) {
(void)fmt;
std::uint32_t binary_data_length = Format::length_for_append(element_count);
std::uint8_t* binary_data = allocate(binary_sub_type::k_vector, binary_data_length);
Format::write_frame(binary_data, binary_data_length, element_count);
return {vector::detail::accessor_data<Format>(binary_data, binary_data_length)};
}
private:
core* _core;
};
} // namespace basic
} // namespace builder
} // namespace v_noabi
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
accessor-fwd.hpp
Declares bsoncxx::v_noabi::vector::accessor.
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::builder::basic::sub_binary::sub_binary
sub_binary(core *core)
Default constructor.
Definition sub_binary.hpp:45
bsoncxx::v_noabi::builder::basic::sub_binary::allocate
vector::accessor< Format > allocate(Format fmt, std::size_t element_count)
Allocate and format space for a BSON Binary Vector with uninitialized elements.
Definition sub_binary.hpp:67
bsoncxx::v_noabi::builder::basic::sub_binary::allocate
std::uint8_t * allocate(binary_sub_type sub_type, std::uint32_t length)
Allocate space for an un-initialized BSON Binary element of any subtype.
Definition sub_binary.hpp:54
bsoncxx::v_noabi::builder::basic::sub_binary::sub_binary
sub_binary(core *core)
Default constructor.
Definition sub_binary.hpp:45
bsoncxx::v_noabi::builder::core
A low-level interface for constructing BSON documents and arrays.
Definition core.hpp:46
bsoncxx::v_noabi::vector::accessor
Accessor for the contents of a valid BSON Binary Vector.
Definition accessor.hpp:53
core.hpp
Provides bsoncxx::v_noabi::builder::core.
detail-fwd.hpp
For internal use only!
formats-fwd.hpp
Declares entities in bsoncxx::v_noabi::vector::formats.
bsoncxx::v_noabi::builder::basic
Declares entities used with "basic" BSON builder syntax.
bsoncxx::v_noabi::builder
Declares entities used to build BSON documents.
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::v_noabi::binary_sub_type::k_vector
@ k_vector
BSON Binary Vector.
Definition types.hpp:88
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
sub_binary-fwd.hpp
Declares bsoncxx::v_noabi::builder::basic::sub_binary.
types.hpp
Provides entities used to represent BSON types.