1414
1515#pragma once
1616
17+ #include < bsoncxx/array/element-fwd.hpp>
18+
19+ //
20+
21+ #include < bsoncxx/v1/element/view.hpp>
22+
1723#include < cstddef>
1824#include < cstdint>
1925
20- #include < bsoncxx/array/element-fwd.hpp>
2126#include < bsoncxx/array/view-fwd.hpp>
2227#include < bsoncxx/types/bson_value/view-fwd.hpp>
2328
@@ -36,50 +41,41 @@ namespace array {
3641// / interrogated by calling type() and a specific value can be extracted through
3742// / get_X() accessors.
3843// /
39- class element : private document ::element {
44+ class element : private v_noabi :: document::element {
4045 public:
41- BSONCXX_ABI_EXPORT_CDECL () element();
42-
43- using document::element::operator bool ;
44-
45- using document::element::type;
46-
47- using document::element::get_array;
48- using document::element::get_binary;
49- using document::element::get_bool;
50- using document::element::get_code;
51- using document::element::get_codewscope;
52- using document::element::get_date;
53- using document::element::get_dbpointer;
54- using document::element::get_decimal128;
55- using document::element::get_document;
56- using document::element::get_double;
57- using document::element::get_int32;
58- using document::element::get_int64;
59- using document::element::get_maxkey;
60- using document::element::get_minkey;
61- using document::element::get_null;
62- using document::element::get_oid;
63- using document::element::get_regex;
64- using document::element::get_string;
65- using document::element::get_symbol;
66- using document::element::get_timestamp;
67- using document::element::get_undefined;
68-
69- using document::element::get_value;
70-
71- using document::element::operator [];
72-
73- using document::element::key;
74- using document::element::keylen;
75- using document::element::length;
76- using document::element::offset;
77- using document::element::raw;
78-
79- private:
80- friend ::bsoncxx::v_noabi::array::view;
81-
82- explicit element (std::uint8_t const * raw, std::uint32_t length, std::uint32_t offset, std::uint32_t keylen);
46+ element () : v_noabi::document::element() {}
47+
48+ /* explicit(false) */ element(v1::element::view const & v) : v_noabi::document::element{v} {}
49+
50+ using v_noabi::document::element::operator v1::element::view;
51+
52+ using v_noabi::document::element::operator bool ;
53+
54+ using v_noabi::document::element::raw;
55+
56+ using v_noabi::document::element::length;
57+
58+ using v_noabi::document::element::offset;
59+
60+ using v_noabi::document::element::keylen;
61+
62+ using v_noabi::document::element::type;
63+
64+ using v_noabi::document::element::key;
65+
66+ #pragma push_macro("X")
67+ #undef X
68+ #define X (_name, _value ) using v_noabi::document::element::get_##_name;
69+ BSONCXX_V1_TYPES_XMACRO (X)
70+ #pragma pop_macro("X")
71+
72+ using v_noabi::document::element::get_value;
73+
74+ using v_noabi::document::element::get_owning_value;
75+
76+ using v_noabi::document::element::operator [];
77+
78+ friend bool operator ==(element const & lhs, v_noabi::types::bson_value::view const & rhs);
8379};
8480
8581// /
@@ -90,16 +86,24 @@ class element : private document::element {
9086// / @{
9187
9288// / @relatesalso bsoncxx::v_noabi::array::element
93- BSONCXX_ABI_EXPORT_CDECL (bool ) operator ==(element const & elem, types::bson_value::view const & v);
89+ inline bool operator ==(element const & lhs, v_noabi::types::bson_value::view const & rhs) {
90+ return static_cast <v_noabi::document::element const &>(lhs) == rhs;
91+ }
9492
9593// / @relatesalso bsoncxx::v_noabi::array::element
96- BSONCXX_ABI_EXPORT_CDECL (bool ) operator ==(types::bson_value::view const & v, element const & elem);
94+ inline bool operator ==(v_noabi::types::bson_value::view const & lhs, element const & rhs) {
95+ return rhs == lhs;
96+ }
9797
9898// / @relatesalso bsoncxx::v_noabi::array::element
99- BSONCXX_ABI_EXPORT_CDECL (bool ) operator !=(element const & elem, types::bson_value::view const & v);
99+ inline bool operator !=(element const & lhs, v_noabi::types::bson_value::view const & rhs) {
100+ return !(lhs == rhs);
101+ }
100102
101103// / @relatesalso bsoncxx::v_noabi::array::element
102- BSONCXX_ABI_EXPORT_CDECL (bool ) operator !=(types::bson_value::view const & v, element const & elem);
104+ inline bool operator !=(v_noabi::types::bson_value::view const & lhs, element const & rhs) {
105+ return !(lhs == rhs);
106+ }
103107
104108// / @}
105109// /
@@ -108,11 +112,29 @@ BSONCXX_ABI_EXPORT_CDECL(bool) operator!=(types::bson_value::view const& v, elem
108112} // namespace v_noabi
109113} // namespace bsoncxx
110114
115+ namespace bsoncxx {
116+ namespace v_noabi {
117+
118+ // Ambiguous whether `v1::element::view` should be converted to `v_noabi::array::element` or
119+ // `v_noabi::document::element.` Require users to explicitly cast to the expected type instead.
120+ //
121+ // v_noabi::array::element from_v1(v1::element::view const& v);
122+
123+ // /
124+ // / Convert to the @ref bsoncxx::v1 equivalent of `v`.
125+ // /
126+ inline v1::element::view to_v1 (v_noabi::array::element const & v) {
127+ return v1::element::view{v};
128+ }
129+
130+ } // namespace v_noabi
131+ } // namespace bsoncxx
132+
111133namespace bsoncxx {
112134namespace array {
113135
114- using ::bsoncxx:: v_noabi::array::operator ==;
115- using ::bsoncxx:: v_noabi::array::operator !=;
136+ using v_noabi::array::operator ==;
137+ using v_noabi::array::operator !=;
116138
117139} // namespace array
118140} // namespace bsoncxx
@@ -123,3 +145,7 @@ using ::bsoncxx::v_noabi::array::operator!=;
123145// / @file
124146// / Provides @ref bsoncxx::v_noabi::array::element.
125147// /
148+ // / @par Includes
149+ // / - @ref bsoncxx/document/element.hpp
150+ // / - @ref bsoncxx/v1/element/view.hpp
151+ // /
0 commit comments