Loading...
Searching...
No Matches
element.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/array/element-fwd.hpp> // IWYU pragma: export
//
#include <bsoncxx/v1/types/id-fwd.hpp>
#include <bsoncxx/v1/element/view.hpp> // IWYU pragma: export
#include <cstddef>
#include <cstdint> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/array/view-fwd.hpp> // IWYU pragma: keep: backward compatibility, to be removed.
#include <bsoncxx/types/bson_value/view-fwd.hpp>
#include <bsoncxx/document/element.hpp> // IWYU pragma: export
#include <bsoncxx/config/prelude.hpp>
namespace bsoncxx {
namespace v_noabi {
namespace array {
class element : private v_noabi::document::element {
public:
element() : v_noabi::document::element() {}
/* explicit(false) */ element(v1::element::view const& v) : v_noabi::document::element{v} {}
using v_noabi::document::element::operator v1::element::view;
using v_noabi::document::element::operator bool;
using v_noabi::document::element::raw;
using v_noabi::document::element::length;
using v_noabi::document::element::offset;
using v_noabi::document::element::keylen;
using v_noabi::document::element::type;
using v_noabi::document::element::key;
#pragma push_macro("X")
#undef X
#define X(_name, _value) using v_noabi::document::element::get_##_name;
BSONCXX_V1_TYPES_XMACRO(X)
#pragma pop_macro("X")
using v_noabi::document::element::get_value;
using v_noabi::document::element::get_owning_value;
using v_noabi::document::element::type_view;
using v_noabi::document::element::type_value;
using v_noabi::document::element::operator[];
friend bool operator==(element const& lhs, v_noabi::types::bson_value::view const& rhs);
};
inline bool operator==(element const& lhs, v_noabi::types::bson_value::view const& rhs) {
return static_cast<v_noabi::document::element const&>(lhs) == rhs;
}
inline bool operator==(v_noabi::types::bson_value::view const& lhs, element const& rhs) {
return rhs == lhs;
}
inline bool operator!=(element const& lhs, v_noabi::types::bson_value::view const& rhs) {
return !(lhs == rhs);
}
inline bool operator!=(v_noabi::types::bson_value::view const& lhs, element const& rhs) {
return !(lhs == rhs);
}
} // namespace array
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
namespace v_noabi {
// Ambiguous whether `v1::element::view` should be converted to `v_noabi::array::element` or
// `v_noabi::document::element.` Require users to explicitly cast to the expected type instead.
//
// v_noabi::array::element from_v1(v1::element::view const& v);
inline v1::element::view to_v1(v_noabi::array::element const& v) {
return v1::element::view{v};
}
} // namespace v_noabi
} // namespace bsoncxx
namespace bsoncxx {
namespace array {
using v_noabi::array::operator==;
using v_noabi::array::operator!=;
} // namespace array
} // namespace bsoncxx
#include <bsoncxx/config/postlude.hpp>
element-fwd.hpp
Declares bsoncxx::v_noabi::array::element.
postlude.hpp
The bsoncxx v_noabi macro guard postlude header.
prelude.hpp
The bsoncxx v_noabi macro guard prelude header.
bsoncxx::v1::element::view
A non-owning, read-only BSON element.
Definition view.hpp:82
bsoncxx::v_noabi::array::element
A variant view type that accesses values in serialized BSON arrays.
Definition element.hpp:46
bsoncxx::v_noabi::array::element::operator==
friend bool operator==(element const &lhs, v_noabi::types::bson_value::view const &rhs)
Convenience methods to compare for equality against a bson_value.
Definition element.hpp:95
bsoncxx::v_noabi::array::element::operator==
bool operator==(v_noabi::types::bson_value::view const &lhs, element const &rhs)
Convenience methods to compare for equality against a bson_value.
Definition element.hpp:100
bsoncxx::v_noabi::array::element::operator!=
bool operator!=(v_noabi::types::bson_value::view const &lhs, element const &rhs)
Convenience methods to compare for equality against a bson_value.
Definition element.hpp:110
bsoncxx::v_noabi::array::element::operator!=
bool operator!=(element const &lhs, v_noabi::types::bson_value::view const &rhs)
Convenience methods to compare for equality against a bson_value.
Definition element.hpp:105
bsoncxx::v_noabi::document::element
A variant view type that accesses values in serialized BSON documents.
Definition element.hpp:52
bsoncxx::v_noabi::document::element::get_value
v_noabi::types::bson_value::view get_value() const
Getter for a types::bson_value::view variant wrapper of the value portion of the element.
bsoncxx::v_noabi::document::element::keylen
std::uint32_t keylen() const
Getter for the element's key length.
Definition element.hpp:117
bsoncxx::v_noabi::document::element::key
v1::stdx::string_view key() const
Getter for the element's key.
bsoncxx::v_noabi::document::element::type_value
v_noabi::types::bson_value::value type_value() const
Equivalent to get_owning_value() const.
bsoncxx::v_noabi::document::element::raw
std::uint8_t const * raw() const
Getter for the raw bson bytes the element points to.
Definition element.hpp:90
bsoncxx::v_noabi::document::element::length
std::uint32_t length() const
Getter for length of the raw bson bytes the element points to.
Definition element.hpp:99
bsoncxx::v_noabi::document::element::offset
std::uint32_t offset() const
Getter for the offset into the raw bson bytes the element points to.
Definition element.hpp:108
bsoncxx::v_noabi::document::element::element
element()=default
Construct an invalid element.
bsoncxx::v_noabi::document::element::type_view
v_noabi::types::bson_value::view type_view() const
Equivalent to get_value() const.
bsoncxx::v_noabi::document::element::get_owning_value
v_noabi::types::bson_value::value get_owning_value() const
Getter for a types::bson_value::value variant wrapper of the value portion of the element....
bsoncxx::v_noabi::document::element::type
v_noabi::type type() const
Getter for the type of the element.
bsoncxx::v_noabi::types::bson_value::view
A non-owning variant that can contain any BSON type.
Definition view.hpp:62
element.hpp
Provides bsoncxx::v_noabi::document::element.
bsoncxx::array
Declares entities representing a BSON array.
bsoncxx::v_noabi::array
Declares entities representing a BSON array.
bsoncxx::v_noabi::array::operator==
bool operator==(element const &lhs, v_noabi::types::bson_value::view const &rhs)
Convenience methods to compare for equality against a bson_value.
Definition element.hpp:95
bsoncxx::v_noabi
Declares entities whose ABI stability is NOT guaranteed.
bsoncxx::v_noabi::to_v1
v1::element::view to_v1(v_noabi::array::element const &v)
Convert to the bsoncxx::v1 equivalent of v.
Definition element.hpp:132
bsoncxx
The top-level namespace within which all bsoncxx library entities are declared.
view.hpp
Provides bsoncxx::v1::element::view.
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
view-fwd.hpp
Declares bsoncxx::v_noabi::array::view.
view-fwd.hpp
Declares bsoncxx::v_noabi::types::bson_value::view.