Index: base/values.h |
diff --git a/base/values.h b/base/values.h |
index 0371b8e3db5a3f77a1e0269560fb67486528c1f7..950d492b8bf418e06f1d62367ed2c5274a91faf6 100644 |
--- a/base/values.h |
+++ b/base/values.h |
@@ -149,7 +149,7 @@ class BASE_EXPORT FundamentalValue : public Value { |
class BASE_EXPORT StringValue : public Value { |
public: |
// Initializes a StringValue with a UTF-8 narrow character string. |
- explicit StringValue(const std::string& in_value); |
+ explicit StringValue(StringPiece in_value); |
// Initializes a StringValue with a string16. |
explicit StringValue(const string16& in_value); |
dcheng
2016/08/25 07:39:34
I didn't bother with string16, since calling this
|
@@ -223,7 +223,7 @@ class BASE_EXPORT DictionaryValue : public Value { |
bool GetAsDictionary(const DictionaryValue** out_value) const override; |
// Returns true if the current dictionary has a value for the given key. |
- bool HasKey(const std::string& key) const; |
+ bool HasKey(StringPiece key) const; |
// Returns the number of Values in this dictionary. |
size_t size() const { return dictionary_.size(); } |
@@ -241,32 +241,31 @@ 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(const std::string& path, std::unique_ptr<Value> in_value); |
+ void Set(StringPiece path, std::unique_ptr<Value> in_value); |
// Deprecated version of the above. TODO(estade): remove. |
- void Set(const std::string& path, Value* in_value); |
+ void 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(const std::string& path, bool in_value); |
- void SetInteger(const std::string& path, int in_value); |
- void SetDouble(const std::string& path, double in_value); |
- void SetString(const std::string& path, const std::string& in_value); |
- void SetString(const std::string& path, const string16& in_value); |
+ 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); |
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to |
// be used as paths. |
- void SetWithoutPathExpansion(const std::string& key, |
+ void SetWithoutPathExpansion(StringPiece key, |
std::unique_ptr<Value> in_value); |
// Deprecated version of the above. TODO(estade): remove. |
- void SetWithoutPathExpansion(const std::string& key, Value* in_value); |
+ void SetWithoutPathExpansion(StringPiece key, Value* in_value); |
// Convenience forms of SetWithoutPathExpansion(). |
- void SetBooleanWithoutPathExpansion(const std::string& path, bool in_value); |
- void SetIntegerWithoutPathExpansion(const std::string& path, int in_value); |
- void SetDoubleWithoutPathExpansion(const std::string& path, double in_value); |
- void SetStringWithoutPathExpansion(const std::string& path, |
- const std::string& in_value); |
- void SetStringWithoutPathExpansion(const std::string& path, |
+ 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); |
// Gets the Value associated with the given path starting from this object. |
@@ -284,46 +283,41 @@ class BASE_EXPORT DictionaryValue : public Value { |
// and the return value will be true if the path is valid and the value at |
// the end of the path can be returned in the form specified. |
// |out_value| is optional and will only be set if non-NULL. |
- bool GetBoolean(const std::string& path, bool* out_value) const; |
- bool GetInteger(const std::string& path, int* out_value) const; |
+ bool GetBoolean(StringPiece path, bool* out_value) const; |
+ bool GetInteger(StringPiece path, int* out_value) const; |
// Values of both type TYPE_INTEGER and TYPE_DOUBLE can be obtained as |
// doubles. |
- bool GetDouble(const std::string& path, double* out_value) const; |
- bool GetString(const std::string& path, std::string* out_value) const; |
- bool GetString(const std::string& path, string16* out_value) const; |
- bool GetStringASCII(const std::string& path, std::string* out_value) const; |
- bool GetBinary(const std::string& path, const BinaryValue** out_value) const; |
- bool GetBinary(const std::string& path, BinaryValue** out_value); |
+ bool GetDouble(StringPiece path, double* out_value) const; |
+ bool GetString(StringPiece path, std::string* out_value) const; |
+ bool GetString(StringPiece path, string16* out_value) const; |
+ bool GetStringASCII(StringPiece path, std::string* out_value) const; |
+ bool GetBinary(StringPiece path, const BinaryValue** out_value) const; |
+ bool GetBinary(StringPiece path, BinaryValue** out_value); |
bool GetDictionary(StringPiece path, |
const DictionaryValue** out_value) const; |
bool GetDictionary(StringPiece path, DictionaryValue** out_value); |
- bool GetList(const std::string& path, const ListValue** out_value) const; |
- bool GetList(const std::string& path, ListValue** out_value); |
+ bool GetList(StringPiece path, const ListValue** out_value) const; |
+ bool GetList(StringPiece path, ListValue** out_value); |
// Like Get(), but without special treatment of '.'. This allows e.g. URLs to |
// be used as paths. |
- bool GetWithoutPathExpansion(const std::string& key, |
- const Value** out_value) const; |
- bool GetWithoutPathExpansion(const std::string& key, Value** out_value); |
- bool GetBooleanWithoutPathExpansion(const std::string& key, |
- bool* out_value) const; |
- bool GetIntegerWithoutPathExpansion(const std::string& key, |
- int* out_value) const; |
- bool GetDoubleWithoutPathExpansion(const std::string& key, |
- double* out_value) const; |
- bool GetStringWithoutPathExpansion(const std::string& key, |
+ bool GetWithoutPathExpansion(StringPiece key, const Value** out_value) const; |
+ bool GetWithoutPathExpansion(StringPiece key, Value** out_value); |
+ bool GetBooleanWithoutPathExpansion(StringPiece key, bool* out_value) const; |
+ bool GetIntegerWithoutPathExpansion(StringPiece key, int* out_value) const; |
+ bool GetDoubleWithoutPathExpansion(StringPiece key, double* out_value) const; |
+ bool GetStringWithoutPathExpansion(StringPiece key, |
std::string* out_value) const; |
- bool GetStringWithoutPathExpansion(const std::string& key, |
+ bool GetStringWithoutPathExpansion(StringPiece key, |
string16* out_value) const; |
bool GetDictionaryWithoutPathExpansion( |
- const std::string& key, |
+ StringPiece key, |
const DictionaryValue** out_value) const; |
- bool GetDictionaryWithoutPathExpansion(const std::string& key, |
+ bool GetDictionaryWithoutPathExpansion(StringPiece key, |
DictionaryValue** out_value); |
- bool GetListWithoutPathExpansion(const std::string& key, |
+ bool GetListWithoutPathExpansion(StringPiece key, |
const ListValue** out_value) const; |
- bool GetListWithoutPathExpansion(const std::string& key, |
- ListValue** out_value); |
+ bool GetListWithoutPathExpansion(StringPiece key, ListValue** out_value); |
// Removes the Value with the specified path from this dictionary (or one |
// of its child dictionaries, if the path is more than just a local key). |
@@ -331,18 +325,16 @@ class BASE_EXPORT DictionaryValue : public Value { |
// |out_value|. If |out_value| is NULL, the removed value will be deleted. |
// This method returns true if |path| is a valid path; otherwise it will |
// return false and the DictionaryValue object will be unchanged. |
- virtual bool Remove(const std::string& path, |
- std::unique_ptr<Value>* out_value); |
+ virtual bool Remove(StringPiece path, std::unique_ptr<Value>* out_value); |
// Like Remove(), but without special treatment of '.'. This allows e.g. URLs |
// to be used as paths. |
- virtual bool RemoveWithoutPathExpansion(const std::string& key, |
+ virtual bool RemoveWithoutPathExpansion(StringPiece key, |
std::unique_ptr<Value>* out_value); |
// Removes a path, clearing out all dictionaries on |path| that remain empty |
// after removing the value at |path|. |
- virtual bool RemovePath(const std::string& path, |
- std::unique_ptr<Value>* out_value); |
+ virtual bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value); |
// Makes a copy of |this| but doesn't include empty dictionaries and lists in |
// the copy. This never returns NULL, even if |this| itself is empty. |
@@ -472,7 +464,7 @@ class BASE_EXPORT ListValue : public Value { |
void AppendBoolean(bool in_value); |
void AppendInteger(int in_value); |
void AppendDouble(double in_value); |
- void AppendString(const std::string& in_value); |
+ void AppendString(StringPiece in_value); |
void AppendString(const string16& in_value); |
void AppendStrings(const std::vector<std::string>& in_values); |
void AppendStrings(const std::vector<string16>& in_values); |