diff --git a/CHANGELOG.md b/CHANGELOG.md index e93245617c..cb6a87e483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu ## 4.2.0 [Unreleased] +### Added + +* To support incremental migration, the following entities are defined as equivalent to their renamed counterparts. + - `bsoncxx::types::id`: equivalent to `bsoncxx::type`. + - `bsoncxx::types::binary_subtype`: equivalent to `bsoncxx::binary_sub_type`. + - `bsoncxx::types::view`: equivalent to `bsoncxx::types::bson_value::view`. + - `bsoncxx::types::value`: equivalent to `bsoncxx::types::bson_value::value`. + - `type_view()` in `bsoncxx::document::element` and `bsoncxx::array::element`: equivalent to `get_value()`. + - `type_value()` in `bsoncxx::document::element` and `bsoncxx::array::element`: equivalent to `get_owning_value()`. + ### Fixed - CMake option `ENABLE_TESTS` (`OFF` by default) is no longer overwritten by the auto-downloaded C Driver (`ON` by default) during CMake configuration. @@ -46,6 +56,13 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu return instance; } ``` +- These following entities will be renamed (and removed) in an upcoming major release. To support incremental migration, both old and new names are still provided. + - `bsoncxx::type` -> `bsoncxx::types::id`. + - `bsoncxx::binary_sub_type` -> `bsoncxx::types::binary_subtype`. + - `bsoncxx::types::bson_value::view` -> `bsoncxx::types::view` + - `bsoncxx::types::bson_value::value` -> `bsoncxx::types::value` + - `get_value()` -> `type_view()` in `bsoncxx::document::element` and `bsoncxx::array::element`. + - `get_owning_value()` -> `type_value()` in `bsoncxx::document::element` and `bsoncxx::array::element`. ### Removed @@ -69,7 +86,6 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu - Static pkg-config files are updated to depend on the static (not shared) libbson / libmongoc packages. - Fix build if macros `GCC`/`GNU`/`Clang`/`MSVC` are already defined. - ## 4.1.0 ### Fixed diff --git a/src/bsoncxx/include/bsoncxx/docs/top.hpp b/src/bsoncxx/include/bsoncxx/docs/top.hpp index fa23e0d442..054f4664fb 100644 --- a/src/bsoncxx/include/bsoncxx/docs/top.hpp +++ b/src/bsoncxx/include/bsoncxx/docs/top.hpp @@ -88,6 +88,8 @@ /// @namespace bsoncxx::types::bson_value /// Declares entities representing any BSON value type. /// +/// @deprecated Use @ref bsoncxx::types instead (renamed). +/// /// /// @namespace bsoncxx::vector diff --git a/src/bsoncxx/include/bsoncxx/docs/v_noabi.hpp b/src/bsoncxx/include/bsoncxx/docs/v_noabi.hpp index 0262be0c8d..e49a1f87e6 100644 --- a/src/bsoncxx/include/bsoncxx/docs/v_noabi.hpp +++ b/src/bsoncxx/include/bsoncxx/docs/v_noabi.hpp @@ -95,6 +95,8 @@ /// @dir bsoncxx/v_noabi/bsoncxx/types/bson_value /// Provides headers declaring entities in @ref bsoncxx::v_noabi::types::bson_value. /// +/// @deprecated Use @ref bsoncxx/types/view.hpp or @ref bsoncxx/types/value.hpp instead. +/// /// /// @dir bsoncxx/v_noabi/bsoncxx/vector @@ -153,6 +155,8 @@ /// @namespace bsoncxx::v_noabi::types::bson_value /// Declares entities representing any BSON value type. /// +/// @deprecated Use @ref bsoncxx::v_noabi::types instead (renamed). +/// /// /// @namespace bsoncxx::v_noabi::vector diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp index 79921b2b16..035cd49851 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp @@ -73,6 +73,10 @@ class element : private v_noabi::document::element { 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); diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp index 03ed760126..c89c23dd0b 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp @@ -155,6 +155,8 @@ class element { /// Getter for a types::bson_value::view variant wrapper of the value portion of the /// element. /// + /// @deprecated Use @ref type_view() const instead (renamed). + /// /// @return the element's value. /// BSONCXX_ABI_EXPORT_CDECL(v_noabi::types::bson_value::view) get_value() const; @@ -163,10 +165,26 @@ class element { /// Getter for a types::bson_value::value variant wrapper of the value portion of /// the element. The returned object will make a copy of the buffer from this object. /// + /// @deprecated Use @ref type_value() const instead (renamed). + /// /// @return an owning version of the element's value. /// BSONCXX_ABI_EXPORT_CDECL(v_noabi::types::bson_value::value) get_owning_value() const; + /// + /// Equivalent to @ref get_value() const. + /// + /// To support incremental migration to @ref bsoncxx::v1::element::view::type_view() const. + /// + BSONCXX_ABI_EXPORT_CDECL(v_noabi::types::bson_value::view) type_view() const; + + /// + /// Equivalent to @ref get_owning_value() const. + /// + /// To support incremental migration to @ref bsoncxx::v1::element::view::type_value() const. + /// + BSONCXX_ABI_EXPORT_CDECL(v_noabi::types::bson_value::value) type_value() const; + /// /// If this element is a document, finds the first element of the document /// with the provided key. If there is no such element, an invalid diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp index 514fa09998..f372074420 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/oid.hpp @@ -122,6 +122,13 @@ class oid { return reinterpret_cast(_oid.bytes()); } + /// + /// Equivalent to [`bson_oid_compare`](https://mongoc.org/libbson/current/bson_oid_compare.html). + /// + int compare(oid const& other) const { + return _oid.compare(other._oid); + } + /// /// @relates bsoncxx::v_noabi::oid /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types-fwd.hpp index 3bc465951d..326bff00f3 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types-fwd.hpp @@ -33,6 +33,20 @@ namespace bsoncxx { namespace v_noabi { namespace types { +/// +/// Equivalent to @ref bsoncxx::v_noabi::type. +/// +/// To support incremental migration to @ref bsoncxx::v1::types::id. +/// +using id = v_noabi::type; + +/// +/// Equivalent to @ref bsoncxx::v_noabi::binary_sub_type. +/// +/// To support incremental migration to @ref bsoncxx::v1::types::binary_subtype. +/// +using binary_subtype = v_noabi::binary_sub_type; + struct b_double; struct b_string; struct b_document; @@ -69,6 +83,9 @@ using v_noabi::type; namespace bsoncxx { namespace types { +using v_noabi::types::binary_subtype; +using v_noabi::types::id; + using v_noabi::types::b_array; using v_noabi::types::b_binary; using v_noabi::types::b_bool; @@ -100,6 +117,8 @@ using v_noabi::types::b_undefined; /// @file /// Declares entities used to represent BSON types. /// +/// @deprecated Use @ref bsoncxx/types/id-fwd.hpp or @ref bsoncxx/types/view-fwd.hpp instead. +/// /// @par Includes /// - @ref bsoncxx/v1/types/view-fwd.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp index 044e6af8d3..2f2c4dda6b 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp @@ -42,6 +42,8 @@ namespace v_noabi { /// /// @showenumvalues /// +/// @deprecated Use @ref bsoncxx::v_noabi::types::id instead (renamed). +/// enum class type : std::uint8_t { k_double = 0x01, ///< 64-bit binary floating point. k_string = 0x02, ///< UTF-8 string. @@ -71,6 +73,8 @@ enum class type : std::uint8_t { /// /// @showenumvalues /// +/// @deprecated Use @ref bsoncxx::v_noabi::types::binary_subtype instead (renamed). +/// enum class binary_sub_type : std::uint8_t { k_binary = 0x00, ///< Generic binary subtype. k_function = 0x01, ///< Function. @@ -1105,6 +1109,8 @@ using v_noabi::types::operator!=; /// @file /// Provides entities used to represent BSON types. /// +/// @deprecated Use @ref bsoncxx/types/id.hpp or @ref bsoncxx/types/view.hpp instead. +/// /// @par Includes /// - @ref bsoncxx/v1/types/view.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value-fwd.hpp index e3b78816e0..8de3efd0b9 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value-fwd.hpp @@ -27,7 +27,12 @@ class value; } // namespace bson_value -using bson_value::value; +/// +/// Equivalent to @ref bsoncxx::v_noabi::types::bson_value::value. +/// +/// To support incremental migration to @ref bsoncxx::v1::types::value. +/// +using value = bson_value::value; } // namespace types } // namespace v_noabi @@ -41,7 +46,7 @@ using v_noabi::types::bson_value::value; } // namespace bson_value -using bson_value::value; +using v_noabi::types::value; } // namespace types } // namespace bsoncxx @@ -52,6 +57,8 @@ using bson_value::value; /// @file /// Declares @ref bsoncxx::v_noabi::types::bson_value::value. /// +/// @deprecated Use @ref bsoncxx/types/value-fwd.hpp instead (renamed). +/// /// @par Includes /// - @ref bsoncxx/v1/types/value-fwd.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp index 4364d3bfb6..75f2bfda0b 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/value.hpp @@ -49,6 +49,8 @@ namespace bson_value { /// For accessors into this type and to extract the various BSON types out, /// please use bson_value::view. /// +/// @deprecated Use @ref bsoncxx::v_noabi::types::value instead (renamed). +/// /// @see /// - @ref bsoncxx::v_noabi::types::bson_value::view /// @@ -254,7 +256,7 @@ class value { /// @throws bsoncxx::v_noabi::exception if the type's value is not k_maxkey, k_minkey, or /// k_undefined. /// - /* explicit(false) */ BSONCXX_ABI_EXPORT_CDECL() value(type const id); + /* explicit(false) */ BSONCXX_ABI_EXPORT_CDECL() value(v_noabi::type const id); /// /// Constructs one of the following BSON values (each specified by the parenthesized type): @@ -297,6 +299,24 @@ class value { return _value; } + /// + /// Returns the type of the underlying BSON value stored in this object. + /// + /// @deprecated Use @ref type_id() const instead (renamed). + /// + v_noabi::type type() const { + return this->view().type(); + } + + /// + /// Equivalent to @ref type() const. + /// + /// To support incremental migration to @ref bsoncxx::v1::types::value. + /// + v_noabi::type type_id() const { + return this->view().type_id(); + } + /// /// Get a view over the bson_value owned by this object. /// @@ -310,6 +330,25 @@ class value { /* explicit(false) */ operator v_noabi::types::bson_value::view() const noexcept { return _value.view(); } + +#pragma push_macro("X") +#undef X +#define X(_name, _value) \ + v_noabi::types::b_##_name const& get_##_name() const { \ + return this->view().get_##_name(); \ + } + + /// + /// Return the underlying BSON type value. + /// + /// @warning + /// Calling the wrong get_ method will cause an exception to be thrown. + /// + /// @{ + BSONCXX_V1_TYPES_XMACRO(X) + /// @} + /// +#pragma pop_macro("X") }; /// @@ -400,6 +439,8 @@ using v_noabi::types::bson_value::operator!=; /// @file /// Provides @ref bsoncxx::v_noabi::types::bson_value::value. /// +/// @deprecated Use @ref bsoncxx/types/value.hpp instead (renamed). +/// /// @par Includes /// - @ref bsoncxx/v1/types/value.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view-fwd.hpp index 756b914b2e..b4a202430b 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view-fwd.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view-fwd.hpp @@ -27,7 +27,12 @@ class view; } // namespace bson_value -using bson_value::view; +/// +/// Equivalent to @ref bsoncxx::v_noabi::types::bson_value::view. +/// +/// To support incremental migration to @ref bsoncxx::v1::types::view. +/// +using view = v_noabi::types::bson_value::view; } // namespace types } // namespace v_noabi @@ -41,7 +46,7 @@ using v_noabi::types::bson_value::view; } // namespace bson_value -using bson_value::view; +using v_noabi::types::view; } // namespace types } // namespace bsoncxx @@ -52,6 +57,8 @@ using bson_value::view; /// @file /// Declares @ref bsoncxx::v_noabi::types::bson_value::view. /// +/// @deprecated Use @ref bsoncxx/types/view-fwd.hpp instead (renamed). +/// /// @par Includes /// - @ref bsoncxx/v1/types/view-fwd.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp index 905657427c..55000cf148 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp @@ -53,6 +53,8 @@ namespace bson_value { /// /// A non-owning variant that can contain any BSON type. /// +/// @deprecated Use @ref bsoncxx::v_noabi::types::view instead (renamed). +/// /// @warning /// Calling the wrong get_ method will cause an exception /// to be thrown. @@ -128,10 +130,21 @@ class view { /// /// Returns the type of the underlying BSON value stored in this object. /// + /// @deprecated Use @ref type_id() const instead (renamed). + /// v_noabi::type type() const { return _id; } + /// + /// Equivalent to @ref type() const. + /// + /// To support incremental migration to @ref bsoncxx::v1::types::view. + /// + v_noabi::type type_id() const { + return _id; + } + #pragma push_macro("X") #undef X #define X(_name, _value) BSONCXX_ABI_EXPORT_CDECL(v_noabi::types::b_##_name const&) get_##_name() const; @@ -240,6 +253,8 @@ using v_noabi::types::bson_value::operator!=; /// @file /// Provides @ref bsoncxx::v_noabi::types::bson_value::view. /// +/// @deprecated Use @ref bsoncxx/types/view.hpp instead (renamed). +/// /// @par Includes /// - @ref bsoncxx/v1/types/view.hpp /// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id-fwd.hpp new file mode 100644 index 0000000000..c87b279e79 --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id-fwd.hpp @@ -0,0 +1,24 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types-fwd.hpp. +/// +/// To support incremental migration to @ref bsoncxx/v1/types/id-fwd.hpp. +/// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id.hpp new file mode 100644 index 0000000000..79be27ec56 --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/id.hpp @@ -0,0 +1,24 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types.hpp. +/// +/// To support incremental migration to @ref bsoncxx/v1/types/id.hpp. +/// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value-fwd.hpp new file mode 100644 index 0000000000..9e43125f92 --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value-fwd.hpp @@ -0,0 +1,27 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types/bson_value/value-fwd.hpp. +/// +/// @par Includes +/// - @ref bsoncxx/v1/types/value-fwd.hpp +/// +/// To support incremental migration to @ref bsoncxx/v1/types/value-fwd.hpp. +/// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value.hpp new file mode 100644 index 0000000000..09b31bf153 --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/value.hpp @@ -0,0 +1,24 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types/bson_value/value.hpp. +/// +/// To support incremental migration to @ref bsoncxx/v1/types/value.hpp. +/// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view-fwd.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view-fwd.hpp new file mode 100644 index 0000000000..dec950d3cc --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view-fwd.hpp @@ -0,0 +1,27 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types/bson_value/view-fwd.hpp. +/// +/// @par Includes +/// - @ref bsoncxx/v1/types/view-fwd.hpp +/// +/// To support incremental migration to @ref bsoncxx/v1/types/view-fwd.hpp. +/// diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view.hpp new file mode 100644 index 0000000000..4b03e933ac --- /dev/null +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/view.hpp @@ -0,0 +1,24 @@ +// 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 + +/// +/// @file +/// Equivalent to @ref bsoncxx/types/bson_value/view.hpp. +/// +/// To support incremental migration to @ref bsoncxx/v1/types/view.hpp. +/// diff --git a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp index e69509d7d6..8f97d9767c 100644 --- a/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp +++ b/src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp @@ -94,6 +94,14 @@ v_noabi::types::bson_value::value element::get_owning_value() const { return {std::move(*value_opt)}; } +v_noabi::types::bson_value::view element::type_view() const { + return this->get_value(); +} + +v_noabi::types::bson_value::value element::type_value() const { + return this->get_owning_value(); +} + element element::operator[](stdx::string_view key) const try { return _view[key]; } catch (v1::exception const&) { // For backward compatibility, convert any exceptions into an invalid element. return {}; diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 1b481296b9..5e819aafe7 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -40,10 +40,10 @@ set(bsoncxx_test_sources_v_noabi v_noabi/bson_types.cpp v_noabi/bson_util_itoa.cpp v_noabi/bson_validate.cpp - v_noabi/bson_value.cpp v_noabi/decimal128.cpp v_noabi/json.cpp v_noabi/oid.cpp + v_noabi/types.cpp v_noabi/vector.cpp v_noabi/view_or_value.cpp ) diff --git a/src/bsoncxx/test/v_noabi/bson_value.cpp b/src/bsoncxx/test/v_noabi/types.cpp similarity index 100% rename from src/bsoncxx/test/v_noabi/bson_value.cpp rename to src/bsoncxx/test/v_noabi/types.cpp