Skip to content

Commit 1bd0c94

Browse files
authored
CXX-2110 Remove all references to deprecated utf8 (#1250)
1 parent 43818b5 commit 1bd0c94

File tree

10 files changed

+7
-61
lines changed

10 files changed

+7
-61
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu
1717
- Inline namespace macros for bsoncxx and mongocxx namespace: `*_INLINE_NAMESPACE_*`.
1818
- The `<bsoncxx/types/value.hpp>` header.
1919
- The `<bsoncxx/util/functor.hpp>` header.
20+
- References to deprecated `utf8` which have equivalent `string` alternatives.
21+
- `k_utf8` in `bsoncxx::v_noabi::type`. Use `k_string` instead.
22+
- `b_utf8` in `bsoncxx::v_noabi::types`. Use `b_string` instead.
23+
- `get_utf8` in `bsoncxx::v_noabi::document::element`, `bsoncxx::v_noabi::array::element`, and `bsoncxx::v_noabi::types::bson_value::view`. Use `get_string` instead.
24+
- `k_cannot_append_utf8` and `k_need_element_type_k_utf8` in `bsoncxx::v_noabi::exception::error_code`. Use `k_cannot_append_string` and `k_need_element_type_k_string` instead.
2025

2126
## 3.11.0
2227

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/array/element.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class element : private document::element {
6565
using document::element::get_symbol;
6666
using document::element::get_timestamp;
6767
using document::element::get_undefined;
68-
using document::element::get_utf8;
6968

7069
using document::element::get_value;
7170

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class list {
125125
}
126126
for (size_t i = 0; i < init.size(); i += 2) {
127127
auto t = (begin(init) + i)->val.view().type();
128-
if (t != type::k_utf8) {
128+
if (t != type::k_string) {
129129
err_msg << " : all keys must be string type. ";
130130
err_msg << "Found type=" << to_string(t);
131131
return false;

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/document/element.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,6 @@ class element {
114114
///
115115
BSONCXX_ABI_EXPORT_CDECL(types::b_double) get_double() const;
116116

117-
///
118-
/// Getter for elements of the b_string type.
119-
///
120-
/// @deprecated use document::element::get_string() instead.
121-
///
122-
/// @throws bsoncxx::v_noabi::exception if this element is not a b_string.
123-
///
124-
/// @return the element's value.
125-
///
126-
BSONCXX_DEPRECATED BSONCXX_ABI_EXPORT_CDECL(types::b_string) get_utf8() const;
127-
128117
///
129118
/// Getter for elements of the b_string type.
130119
///

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/exception/error_code.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ enum class error_code : std::int32_t {
141141
k_cannot_append_minkey,
142142
/// @}
143143

144-
/// Failed to append a value of the given type.
145-
k_cannot_append_utf8 = k_cannot_append_string,
146-
147-
/// @deprecated Use `k_need_element_type_k_string` instead.
148-
k_need_element_type_k_utf8 = k_need_element_type_k_string,
149-
150144
// Add new constant string message to error_code.cpp as well!
151145
};
152146

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace v_noabi {
4343
enum class type : std::uint8_t {
4444
k_double = 0x01, ///< 64-bit binary floating point.
4545
k_string = 0x02, ///< UTF-8 string.
46-
k_utf8 = 0x02, ///< Equivalent to @ref k_string. @deprecated
4746
k_document = 0x03, ///< Embedded document.
4847
k_array = 0x04, ///< Array.
4948
k_binary = 0x05, ///< Binary data.
@@ -164,13 +163,6 @@ inline bool operator==(const b_string& lhs, const b_string& rhs) {
164163
return lhs.value == rhs.value;
165164
}
166165

167-
///
168-
/// Equivalent to @ref b_string.
169-
///
170-
/// @deprecated Use @ref b_string instead.
171-
///
172-
BSONCXX_DEPRECATED typedef b_string b_utf8;
173-
174166
///
175167
/// A BSON document value.
176168
///
@@ -874,8 +866,6 @@ using ::bsoncxx::v_noabi::to_string;
874866
namespace bsoncxx {
875867
namespace types {
876868

877-
using ::bsoncxx::v_noabi::types::b_utf8; // Deprecated.
878-
879869
using ::bsoncxx::v_noabi::types::operator==;
880870
using ::bsoncxx::v_noabi::types::operator!=;
881871

@@ -901,10 +891,6 @@ std::string to_string(v_noabi::binary_sub_type rhs);
901891

902892
namespace types {
903893

904-
/// @ref bsoncxx::v_noabi::types::b_utf8
905-
/// @deprecated Use @ref bsoncxx::types::b_string instead.
906-
struct b_utf8 {};
907-
908894
/// @ref bsoncxx::v_noabi::types::operator==(const v_noabi::types::b_double& lhs, const v_noabi::types::b_double& rhs)
909895
bool operator==(const v_noabi::types::b_double& lhs, const v_noabi::types::b_double& rhs);
910896

src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,6 @@ class view {
105105
///
106106
BSONCXX_ABI_EXPORT_CDECL(const b_double&) get_double() const;
107107

108-
///
109-
/// Returns the underlying BSON UTF-8 string value.
110-
///
111-
/// @deprecated use get_string instead.
112-
///
113-
/// @warning
114-
/// Calling the wrong get_<type> method will cause an exception to be thrown.
115-
///
116-
BSONCXX_DEPRECATED BSONCXX_ABI_EXPORT_CDECL(const b_string&) get_utf8() const;
117-
118108
///
119109
/// Returns the underlying BSON UTF-8 string value.
120110
///

src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/document/element.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,6 @@ stdx::string_view element::key() const {
103103
#include <bsoncxx/enums/type.hpp>
104104
#undef BSONCXX_ENUM
105105

106-
types::b_string element::get_utf8() const {
107-
if (_raw == nullptr) {
108-
throw bsoncxx::v_noabi::exception{
109-
error_code::k_unset_element,
110-
"cannot get string from an uninitialized element" +
111-
std::string(_key ? " with key \"" + std::string(_key.value().data()) + "\"" : "")};
112-
}
113-
114-
types::bson_value::view v{_raw, _length, _offset, _keylen};
115-
return v.get_string();
116-
}
117-
118106
types::bson_value::view element::get_value() const {
119107
switch (static_cast<int>(type())) {
120108
#define BSONCXX_ENUM(type, val) \

src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/types/bson_value/view.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ bsoncxx::v_noabi::type view::type() const {
114114
#include <bsoncxx/enums/type.hpp>
115115
#undef BSONCXX_ENUM
116116

117-
const types::b_string& view::get_utf8() const {
118-
BSONCXX_TYPE_CHECK(string);
119-
return _b_string;
120-
}
121-
122117
view::view(const std::uint8_t* raw,
123118
std::uint32_t length,
124119
std::uint32_t offset,

src/mongocxx/test/spec/unified_tests/runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ read_preference get_read_preference(const document::element& opts) {
517517
write_concern get_write_concern(const document::element& opts) {
518518
auto wc = write_concern{};
519519
if (auto w = opts["writeConcern"]["w"]) {
520-
if (w.type() == type::k_utf8) {
520+
if (w.type() == type::k_string) {
521521
const auto strval = w.get_string().value;
522522
if (0 == strval.compare("majority")) {
523523
wc.acknowledge_level(mongocxx::write_concern::level::k_majority);

0 commit comments

Comments
 (0)