Loading...
Searching...
No Matches
view.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/v1/element/view-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/detail/prelude.hpp>
#include <bsoncxx/v1/types/id-fwd.hpp>
#include <bsoncxx/v1/types/value-fwd.hpp>
#include <bsoncxx/v1/types/view-fwd.hpp>
#include <bsoncxx/v1/config/export.hpp>
#include <bsoncxx/v1/detail/macros.hpp>
#include <bsoncxx/v1/stdx/string_view.hpp>
#include <array>
#include <cstddef>
#include <cstdint>
#include <system_error>
#include <type_traits>
namespace bsoncxx {
namespace v1 {
namespace element {
class view {
private:
class impl;
alignas(BSONCXX_PRIVATE_MAX_ALIGN_T) std::array<unsigned char, 32> _storage;
public:
BSONCXX_ABI_EXPORT_CDECL() ~view();
// Handled by the nothrow copy constructor.
// view(view&& other) noexcept;
// Handled by the nothrow copy assignment operator.
// view& operator=(view&& other) noexcept;
BSONCXX_ABI_EXPORT_CDECL() view(view const& other) noexcept;
BSONCXX_ABI_EXPORT_CDECL(view&) operator=(view const& other) noexcept;
BSONCXX_ABI_EXPORT_CDECL() view();
explicit BSONCXX_ABI_EXPORT_CDECL() operator bool() const;
BSONCXX_ABI_EXPORT_CDECL(std::uint8_t const*) raw() const;
BSONCXX_ABI_EXPORT_CDECL(std::uint32_t) length() const;
BSONCXX_ABI_EXPORT_CDECL(std::uint32_t) offset() const;
BSONCXX_ABI_EXPORT_CDECL(std::uint32_t) keylen() const;
BSONCXX_ABI_EXPORT_CDECL(v1::types::id) type_id() const;
BSONCXX_ABI_EXPORT_CDECL(v1::stdx::string_view) key() const;
#pragma push_macro("X")
#undef X
#define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(v1::types::b_##_name) get_##_name() const;
BSONCXX_V1_TYPES_XMACRO(X)
#pragma pop_macro("X")
BSONCXX_ABI_EXPORT_CDECL(v1::types::view) type_view() const;
BSONCXX_ABI_EXPORT_CDECL(v1::types::value) type_value() const;
BSONCXX_ABI_EXPORT_CDECL(v1::element::view) operator[](v1::stdx::string_view key) const;
BSONCXX_ABI_EXPORT_CDECL(v1::element::view) operator[](std::uint32_t idx) const;
enum class errc {
zero,
invalid_view,
invalid_data,
};
static BSONCXX_ABI_EXPORT_CDECL(std::error_category const&) error_category();
friend std::error_code make_error_code(errc v) {
return {static_cast<int>(v), error_category()};
}
class internal;
private:
explicit view(impl i);
};
} // namespace element
} // namespace v1
} // namespace bsoncxx
template <>
struct std::is_error_code_enum<bsoncxx::v1::element::view::errc> : true_type {};
#include <bsoncxx/v1/detail/postlude.hpp>
export.hpp
Provides macros to control the set of symbols exported in the ABI.
BSONCXX_ABI_EXPORT_CDECL
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
macros.hpp
For internal use only!
postlude.hpp
The bsoncxx v1 macro guard postlude header.
prelude.hpp
The bsoncxx v1 macro guard prelude header.
bsoncxx::v1::element::view
A non-owning, read-only BSON element.
Definition view.hpp:82
bsoncxx::v1::element::view::type_view
v1::types::view type_view() const
Return a view of the underlying BSON type value.
bsoncxx::v1::element::view::view
view(view const &other) noexcept
Copy (or move) construction.
bsoncxx::v1::element::view::length
std::uint32_t length() const
Return the "length" component of the underlying BSON bytes.
bsoncxx::v1::element::view::type_value
v1::types::value type_value() const
Return a deep copy of the underlying BSON type value.
bsoncxx::v1::element::view::type_id
v1::types::id type_id() const
Return the type.
bsoncxx::v1::element::view::keylen
std::uint32_t keylen() const
Return the "keylen" component of the underlying BSON bytes.
bsoncxx::v1::element::view::key
v1::stdx::string_view key() const
Return the key.
bsoncxx::v1::element::view::raw
std::uint8_t const * raw() const
Return the "raw" component of the underlying BSON bytes.
bsoncxx::v1::element::view::error_category
static std::error_category const & error_category()
The error category for bsoncxx::v1::element::view::errc.
bsoncxx::v1::element::view::offset
std::uint32_t offset() const
Return the "offset" component of the underlying BSON bytes.
bsoncxx::v1::element::view::make_error_code
friend std::error_code make_error_code(errc v)
Support implicit conversion to std::error_code.
Definition view.hpp:245
bsoncxx::v1::element::view::view
view()
Initialize as an invalid element without any associated BSON bytes.
bsoncxx::v1::element::view::operator[]
v1::element::view operator[](std::uint32_t idx) const
Return the first element within the represented BSON array whose key compares equal to i.
bsoncxx::v1::element::view::errc
errc
Errors codes which may be returned by bsoncxx::v1::element::view.
Definition view.hpp:231
bsoncxx::v1::element::view::errc::invalid_view
@ invalid_view
View is invalid.
Definition view.hpp:233
bsoncxx::v1::element::view::errc::zero
@ zero
Zero.
Definition view.hpp:232
bsoncxx::v1::element::view::errc::invalid_data
@ invalid_data
Data is invalid.
Definition view.hpp:234
bsoncxx::v1::element::view::~view
~view()
Destroy this object.
bsoncxx::v1::element::view::operator[]
v1::element::view operator[](v1::stdx::string_view key) const
Return the first element within the represented BSON document whose key compares equal to key.
bsoncxx::v1::stdx::string_view
A polyfill for std::string_view.
Definition string_view.hpp:412
bsoncxx::v1::types::value
A union of BSON type values.
Definition value.hpp:52
bsoncxx::v1::types::view
A non-owning, read-only union of BSON type values.
Definition view.hpp:979
bsoncxx::v1::element
Declares entities representing a BSON element.
bsoncxx::v1::stdx
Declares C++17 standard library polyfills.
bsoncxx::v1::types
Declares entities representing a BSON type value.
bsoncxx::v1
Declares entities whose ABI stability is guaranteed for documented symbols.
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
view-fwd.hpp
Declares bsoncxx::v1::element::view.
string_view.hpp
Provides std::string_view-related polyfills for library API usage.
id-fwd.hpp
Declares enumerations identifying the type of a BSON element.
BSONCXX_V1_TYPES_XMACRO
#define BSONCXX_V1_TYPES_XMACRO(X)
X-macro over the name and value of BSON types.
Definition id-fwd.hpp:44
value-fwd.hpp
Declares bsoncxx::v1::types::value.
view-fwd.hpp
Declares non-owning, read-only entities representing a BSON type value.