| Index: base/values.cc
|
| diff --git a/base/values.cc b/base/values.cc
|
| index d3f0f922db51ad6ec38e11830a6237a62f373da5..382e20c8e8f85b1bce26416c305e06fbf29f43c6 100644
|
| --- a/base/values.cc
|
| +++ b/base/values.cc
|
| @@ -97,6 +97,38 @@ StringValue* Value::CreateStringValue(const string16& in_value) {
|
| return new StringValue(in_value);
|
| }
|
|
|
| +bool Value::IsNull() const {
|
| + return type_ == TYPE_NULL;
|
| +}
|
| +
|
| +bool Value::IsBoolean() const {
|
| + return type_ == TYPE_BOOLEAN;
|
| +}
|
| +
|
| +bool Value::IsInteger() const {
|
| + return type_ == TYPE_INTEGER;
|
| +}
|
| +
|
| +bool Value::IsDouble() const {
|
| + return type_ == TYPE_DOUBLE;
|
| +}
|
| +
|
| +bool Value::IsString() const {
|
| + return type_ == TYPE_STRING;
|
| +}
|
| +
|
| +bool Value::IsBinary() const {
|
| + return type_ == TYPE_BINARY;
|
| +}
|
| +
|
| +bool Value::IsDictionary() const {
|
| + return type_ == TYPE_DICTIONARY;
|
| +}
|
| +
|
| +bool Value::IsList() const {
|
| + return type_ == TYPE_LIST;
|
| +}
|
| +
|
| bool Value::GetAsBoolean(bool* out_value) const {
|
| return false;
|
| }
|
| @@ -128,15 +160,15 @@ bool Value::GetAsList(const ListValue** out_value) const {
|
| Value* Value::DeepCopy() const {
|
| // This method should only be getting called for null Values--all subclasses
|
| // need to provide their own implementation;.
|
| - DCHECK(IsType(TYPE_NULL));
|
| + DCHECK(IsNull());
|
| return CreateNullValue();
|
| }
|
|
|
| bool Value::Equals(const Value* other) const {
|
| // This method should only be getting called for null Values--all subclasses
|
| // need to provide their own implementation;.
|
| - DCHECK(IsType(TYPE_NULL));
|
| - return other->IsType(TYPE_NULL);
|
| + DCHECK(IsNull());
|
| + return other->IsNull();
|
| }
|
|
|
| // static
|
| @@ -169,23 +201,23 @@ FundamentalValue::~FundamentalValue() {
|
| }
|
|
|
| bool FundamentalValue::GetAsBoolean(bool* out_value) const {
|
| - if (out_value && IsType(TYPE_BOOLEAN))
|
| + if (out_value && IsBoolean())
|
| *out_value = boolean_value_;
|
| - return (IsType(TYPE_BOOLEAN));
|
| + return (IsBoolean());
|
| }
|
|
|
| bool FundamentalValue::GetAsInteger(int* out_value) const {
|
| - if (out_value && IsType(TYPE_INTEGER))
|
| + if (out_value && IsInteger())
|
| *out_value = integer_value_;
|
| - return (IsType(TYPE_INTEGER));
|
| + return (IsInteger());
|
| }
|
|
|
| bool FundamentalValue::GetAsDouble(double* out_value) const {
|
| - if (out_value && IsType(TYPE_DOUBLE))
|
| + if (out_value && IsDouble())
|
| *out_value = double_value_;
|
| - else if (out_value && IsType(TYPE_INTEGER))
|
| + else if (out_value && IsInteger())
|
| *out_value = integer_value_;
|
| - return (IsType(TYPE_DOUBLE) || IsType(TYPE_INTEGER));
|
| + return (IsDouble() || IsInteger());
|
| }
|
|
|
| FundamentalValue* FundamentalValue::DeepCopy() const {
|
| @@ -482,7 +514,7 @@ bool DictionaryValue::GetBinary(const std::string& path,
|
| BinaryValue** out_value) const {
|
| Value* value;
|
| bool result = Get(path, &value);
|
| - if (!result || !value->IsType(TYPE_BINARY))
|
| + if (!result || !value->IsBinary())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -495,7 +527,7 @@ bool DictionaryValue::GetDictionary(const std::string& path,
|
| DictionaryValue** out_value) const {
|
| Value* value;
|
| bool result = Get(path, &value);
|
| - if (!result || !value->IsType(TYPE_DICTIONARY))
|
| + if (!result || !value->IsDictionary())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -508,7 +540,7 @@ bool DictionaryValue::GetList(const std::string& path,
|
| ListValue** out_value) const {
|
| Value* value;
|
| bool result = Get(path, &value);
|
| - if (!result || !value->IsType(TYPE_LIST))
|
| + if (!result || !value->IsList())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -573,7 +605,7 @@ bool DictionaryValue::GetDictionaryWithoutPathExpansion(
|
| DictionaryValue** out_value) const {
|
| Value* value;
|
| bool result = GetWithoutPathExpansion(key, &value);
|
| - if (!result || !value->IsType(TYPE_DICTIONARY))
|
| + if (!result || !value->IsDictionary())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -586,7 +618,7 @@ bool DictionaryValue::GetListWithoutPathExpansion(const std::string& key,
|
| ListValue** out_value) const {
|
| Value* value;
|
| bool result = GetWithoutPathExpansion(key, &value);
|
| - if (!result || !value->IsType(TYPE_LIST))
|
| + if (!result || !value->IsList())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -638,7 +670,7 @@ void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) {
|
| Value* merge_value;
|
| if (dictionary->GetWithoutPathExpansion(*key, &merge_value)) {
|
| // Check whether we have to merge dictionaries.
|
| - if (merge_value->IsType(Value::TYPE_DICTIONARY)) {
|
| + if (merge_value->IsDictionary()) {
|
| DictionaryValue* sub_dict;
|
| if (GetDictionaryWithoutPathExpansion(*key, &sub_dict)) {
|
| sub_dict->MergeDictionary(
|
| @@ -775,7 +807,7 @@ bool ListValue::GetString(size_t index, string16* out_value) const {
|
| bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const {
|
| Value* value;
|
| bool result = Get(index, &value);
|
| - if (!result || !value->IsType(TYPE_BINARY))
|
| + if (!result || !value->IsBinary())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -787,7 +819,7 @@ bool ListValue::GetBinary(size_t index, BinaryValue** out_value) const {
|
| bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const {
|
| Value* value;
|
| bool result = Get(index, &value);
|
| - if (!result || !value->IsType(TYPE_DICTIONARY))
|
| + if (!result || !value->IsDictionary())
|
| return false;
|
|
|
| if (out_value)
|
| @@ -799,7 +831,7 @@ bool ListValue::GetDictionary(size_t index, DictionaryValue** out_value) const {
|
| bool ListValue::GetList(size_t index, ListValue** out_value) const {
|
| Value* value;
|
| bool result = Get(index, &value);
|
| - if (!result || !value->IsType(TYPE_LIST))
|
| + if (!result || !value->IsList())
|
| return false;
|
|
|
| if (out_value)
|
|
|