diff options
-rw-r--r-- | base/values.cc | 59 | ||||
-rw-r--r-- | base/values.h | 18 |
2 files changed, 77 insertions, 0 deletions
diff --git a/base/values.cc b/base/values.cc index 1063eff..8453bb4 100644 --- a/base/values.cc +++ b/base/values.cc @@ -443,6 +443,31 @@ void DictionaryValue::SetWithoutPathExpansion(const std::string& key, } } +void DictionaryValue::SetBooleanWithoutPathExpansion( + const std::string& path, bool in_value) { + SetWithoutPathExpansion(path, CreateBooleanValue(in_value)); +} + +void DictionaryValue::SetIntegerWithoutPathExpansion( + const std::string& path, int in_value) { + SetWithoutPathExpansion(path, CreateIntegerValue(in_value)); +} + +void DictionaryValue::SetDoubleWithoutPathExpansion( + const std::string& path, double in_value) { + SetWithoutPathExpansion(path, CreateDoubleValue(in_value)); +} + +void DictionaryValue::SetStringWithoutPathExpansion( + const std::string& path, const std::string& in_value) { + SetWithoutPathExpansion(path, CreateStringValue(in_value)); +} + +void DictionaryValue::SetStringWithoutPathExpansion( + const std::string& path, const string16& in_value) { + SetWithoutPathExpansion(path, CreateStringValue(in_value)); +} + bool DictionaryValue::Get( const std::string& path, const Value** out_value) const { DCHECK(IsStringUTF8(path)); @@ -987,6 +1012,40 @@ void ListValue::Append(Value* in_value) { list_.push_back(in_value); } +void ListValue::AppendBoolean(bool in_value) { + Append(CreateBooleanValue(in_value)); +} + +void ListValue::AppendInteger(int in_value) { + Append(CreateIntegerValue(in_value)); +} + +void ListValue::AppendDouble(double in_value) { + Append(CreateDoubleValue(in_value)); +} + +void ListValue::AppendString(const std::string& in_value) { + Append(CreateStringValue(in_value)); +} + +void ListValue::AppendString(const string16& in_value) { + Append(CreateStringValue(in_value)); +} + +void ListValue::AppendStrings(const std::vector<std::string>& in_values) { + for (std::vector<std::string>::const_iterator it = in_values.begin(); + it != in_values.end(); ++it) { + AppendString(*it); + } +} + +void ListValue::AppendStrings(const std::vector<string16>& in_values) { + for (std::vector<string16>::const_iterator it = in_values.begin(); + it != in_values.end(); ++it) { + AppendString(*it); + } +} + bool ListValue::AppendIfNotPresent(Value* in_value) { DCHECK(in_value); for (ValueVector::const_iterator i(list_.begin()); i != list_.end(); ++i) { diff --git a/base/values.h b/base/values.h index 02a3566..ae9f407 100644 --- a/base/values.h +++ b/base/values.h @@ -256,6 +256,15 @@ class BASE_EXPORT DictionaryValue : public Value { // be used as paths. void SetWithoutPathExpansion(const std::string& 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, + const string16& 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 // into the next DictionaryValue down. If the path can be resolved @@ -452,6 +461,15 @@ class BASE_EXPORT ListValue : public Value { // Appends a Value to the end of the list. void Append(Value* in_value); + // Convenience forms of Append. + void AppendBoolean(bool in_value); + void AppendInteger(int in_value); + void AppendDouble(double in_value); + void AppendString(const std::string& 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); + // Appends a Value if it's not already present. Takes ownership of the // |in_value|. Returns true if successful, or false if the value was already // present. If the value was already present the |in_value| is deleted. |