mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 18:10:27 +01:00
Un-deprecate removeMember overloads, return void (#693)
* Un-deprecate removeMember overloads, return void Sometimes we just want to remove something we don't need anymore. Having to supply a return buffer for the removeMember function to return something we don't care about is a nuisance. There are removeMember overloads that don't need a return buffer but they are deprecated. This commit un-deprecates these overloads and modifies them to return nothing (void) instead of the object that was removed. Further discussion: https://github.com/open-source-parsers/jsoncpp/pull/689 WARNING: Changes the return type of the formerly deprecated removeMember overloads from Value to void. May break existing client code. * Minor stylistic fixes Don't explicitly return a void value from a void function. Also, convert size_t to unsigned in the CZString ctor to avoid a compiler warning.
This commit is contained in:
parent
42a161fc80
commit
a06b390187
@ -521,13 +521,11 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \pre type() is objectValue or nullValue
|
/// \pre type() is objectValue or nullValue
|
||||||
/// \post type() is unchanged
|
/// \post type() is unchanged
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
JSONCPP_DEPRECATED("")
|
void removeMember(const char* key);
|
||||||
Value removeMember(const char* key);
|
|
||||||
/// Same as removeMember(const char*)
|
/// Same as removeMember(const char*)
|
||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
JSONCPP_DEPRECATED("")
|
void removeMember(const JSONCPP_STRING& key);
|
||||||
Value removeMember(const JSONCPP_STRING& key);
|
|
||||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
||||||
/// but 'key' is null-terminated.
|
/// but 'key' is null-terminated.
|
||||||
bool removeMember(const char* key, Value* removed);
|
bool removeMember(const char* key, Value* removed);
|
||||||
|
@ -1187,27 +1187,19 @@ bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
|
|||||||
{
|
{
|
||||||
return removeMember(key.data(), key.data() + key.length(), 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,
|
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
||||||
"in Json::Value::removeMember(): requires objectValue");
|
"in Json::Value::removeMember(): requires objectValue");
|
||||||
if (type_ == nullValue)
|
if (type_ == nullValue)
|
||||||
return nullSingleton();
|
return;
|
||||||
|
|
||||||
Value removed; // null
|
CZString actualKey(key, unsigned(strlen(key)), CZString::noDuplication);
|
||||||
removeMember(key, key + strlen(key), &removed);
|
value_.map_->erase(actualKey);
|
||||||
return removed; // still null if removeMember() did nothing
|
|
||||||
}
|
}
|
||||||
Value Value::removeMember(const JSONCPP_STRING& key)
|
void Value::removeMember(const JSONCPP_STRING& key)
|
||||||
{
|
{
|
||||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
removeMember(key.c_str());
|
||||||
"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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user