Skip to content

Un-deprecate removeMember overloads, return void #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/json/value.h
Original file line number Diff line number Diff line change
@@ -521,13 +521,11 @@ Json::Value obj_value(Json::objectValue); // {}
/// \pre type() is objectValue or nullValue
/// \post type() is unchanged
/// \deprecated
JSONCPP_DEPRECATED("")
Value removeMember(const char* key);
void removeMember(const char* key);
/// Same as removeMember(const char*)
/// \param key may contain embedded nulls.
/// \deprecated
JSONCPP_DEPRECATED("")
Value removeMember(const JSONCPP_STRING& key);
void removeMember(const JSONCPP_STRING& key);
/// Same as removeMember(const char* begin, const char* end, Value* removed),
/// but 'key' is null-terminated.
bool removeMember(const char* key, Value* removed);
20 changes: 6 additions & 14 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
@@ -1187,27 +1187,19 @@ bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
{
return removeMember(key.data(), key.data() + key.length(), removed);
}
Value Value::removeMember(const char* key)
void Value::removeMember(const char* key)
{
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
"in Json::Value::removeMember(): requires objectValue");
if (type_ == nullValue)
return nullSingleton();
return;

Value removed; // null
removeMember(key, key + strlen(key), &removed);
return removed; // still null if removeMember() did nothing
CZString actualKey(key, unsigned(strlen(key)), CZString::noDuplication);
value_.map_->erase(actualKey);
}
Value Value::removeMember(const JSONCPP_STRING& key)
void Value::removeMember(const JSONCPP_STRING& key)
{
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
"in Json::Value::removeMember(): requires objectValue");
if (type_ == nullValue)
return nullSingleton();

Value removed; // null
removeMember(key.c_str(), key.c_str() + key.size(), &removed);
return removed; // still null if removeMember() did nothing
removeMember(key.c_str());
}

bool Value::removeIndex(ArrayIndex index, Value* removed) {