Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2473)

Unified Diff: base/values.h

Issue 2850773002: Make base::DictionaryValue::Set* return pointers (Closed)
Patch Set: Add SetDictionary* and SetList* Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.h
diff --git a/base/values.h b/base/values.h
index 920c0a36a6bfdfd9b3fc74355988bb9a6513822d..8b86b1e0bd0c57c0aee73f57a4f25fd1ec0c5aa7 100644
--- a/base/values.h
+++ b/base/values.h
@@ -238,32 +238,41 @@ class BASE_EXPORT DictionaryValue : public Value {
// If the key at any step of the way doesn't exist, or exists but isn't
// a DictionaryValue, a new DictionaryValue will be created and attached
// to the path in that location. |in_value| must be non-null.
- void Set(StringPiece path, std::unique_ptr<Value> in_value);
+ // Returns a pointer to the inserted value.
+ Value* Set(StringPiece path, std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
- void Set(StringPiece path, Value* in_value);
+ Value* Set(StringPiece path, Value* in_value);
// Convenience forms of Set(). These methods will replace any existing
// value at that path, even if it has a different type.
- void SetBoolean(StringPiece path, bool in_value);
- void SetInteger(StringPiece path, int in_value);
- void SetDouble(StringPiece path, double in_value);
- void SetString(StringPiece path, StringPiece in_value);
- void SetString(StringPiece path, const string16& in_value);
+ Value* SetBoolean(StringPiece path, bool in_value);
+ Value* SetInteger(StringPiece path, int in_value);
+ Value* SetDouble(StringPiece path, double in_value);
+ Value* SetString(StringPiece path, StringPiece in_value);
+ Value* SetString(StringPiece path, const string16& in_value);
+ DictionaryValue* SetDictionary(StringPiece path,
+ std::unique_ptr<DictionaryValue> in_value);
+ ListValue* SetList(StringPiece path, std::unique_ptr<ListValue> in_value);
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to
// be used as paths.
- void SetWithoutPathExpansion(StringPiece key,
- std::unique_ptr<Value> in_value);
+ Value* SetWithoutPathExpansion(StringPiece key,
+ std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
- void SetWithoutPathExpansion(StringPiece key, Value* in_value);
+ Value* SetWithoutPathExpansion(StringPiece key, Value* in_value);
// Convenience forms of SetWithoutPathExpansion().
- void SetBooleanWithoutPathExpansion(StringPiece path, bool in_value);
- void SetIntegerWithoutPathExpansion(StringPiece path, int in_value);
- void SetDoubleWithoutPathExpansion(StringPiece path, double in_value);
- void SetStringWithoutPathExpansion(StringPiece path, StringPiece in_value);
- void SetStringWithoutPathExpansion(StringPiece path,
- const string16& in_value);
+ Value* SetBooleanWithoutPathExpansion(StringPiece path, bool in_value);
+ Value* SetIntegerWithoutPathExpansion(StringPiece path, int in_value);
+ Value* SetDoubleWithoutPathExpansion(StringPiece path, double in_value);
+ Value* SetStringWithoutPathExpansion(StringPiece path, StringPiece in_value);
+ Value* SetStringWithoutPathExpansion(StringPiece path,
+ const string16& in_value);
+ DictionaryValue* SetDictionaryWithoutPathExpansion(
+ StringPiece path,
+ std::unique_ptr<DictionaryValue> in_value);
+ ListValue* SetListWithoutPathExpansion(StringPiece path,
+ std::unique_ptr<ListValue> in_value);
// Gets the Value associated with the given path starting from this object.
// A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes
« no previous file with comments | « no previous file | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698