OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/values.h" | 5 #include "base/values.h" |
6 | 6 |
7 #include "base/float_util.h" | 7 #include "base/float_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 bool Value::GetAsList(ListValue** out_value) { | 128 bool Value::GetAsList(ListValue** out_value) { |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 bool Value::GetAsList(const ListValue** out_value) const { | 132 bool Value::GetAsList(const ListValue** out_value) const { |
133 return false; | 133 return false; |
134 } | 134 } |
135 | 135 |
| 136 bool Value::GetAsDictionary(DictionaryValue** out_value) { |
| 137 return false; |
| 138 } |
| 139 |
| 140 bool Value::GetAsDictionary(const DictionaryValue** out_value) const { |
| 141 return false; |
| 142 } |
| 143 |
136 Value* Value::DeepCopy() const { | 144 Value* Value::DeepCopy() const { |
137 // This method should only be getting called for null Values--all subclasses | 145 // This method should only be getting called for null Values--all subclasses |
138 // need to provide their own implementation;. | 146 // need to provide their own implementation;. |
139 DCHECK(IsType(TYPE_NULL)); | 147 DCHECK(IsType(TYPE_NULL)); |
140 return CreateNullValue(); | 148 return CreateNullValue(); |
141 } | 149 } |
142 | 150 |
143 bool Value::Equals(const Value* other) const { | 151 bool Value::Equals(const Value* other) const { |
144 // This method should only be getting called for null Values--all subclasses | 152 // This method should only be getting called for null Values--all subclasses |
145 // need to provide their own implementation;. | 153 // need to provide their own implementation;. |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 643 |
636 Value* entry = entry_iterator->second; | 644 Value* entry = entry_iterator->second; |
637 if (out_value) | 645 if (out_value) |
638 *out_value = entry; | 646 *out_value = entry; |
639 else | 647 else |
640 delete entry; | 648 delete entry; |
641 dictionary_.erase(entry_iterator); | 649 dictionary_.erase(entry_iterator); |
642 return true; | 650 return true; |
643 } | 651 } |
644 | 652 |
| 653 bool DictionaryValue::GetAsDictionary(DictionaryValue** out_value) { |
| 654 if (out_value) |
| 655 *out_value = this; |
| 656 return true; |
| 657 } |
| 658 |
| 659 bool DictionaryValue::GetAsDictionary( |
| 660 const DictionaryValue** out_value) const { |
| 661 if (out_value) |
| 662 *out_value = this; |
| 663 return true; |
| 664 } |
| 665 |
645 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() { | 666 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() { |
646 Value* copy = CopyWithoutEmptyChildren(this); | 667 Value* copy = CopyWithoutEmptyChildren(this); |
647 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; | 668 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; |
648 } | 669 } |
649 | 670 |
650 void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { | 671 void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { |
651 for (DictionaryValue::key_iterator key(dictionary->begin_keys()); | 672 for (DictionaryValue::key_iterator key(dictionary->begin_keys()); |
652 key != dictionary->end_keys(); ++key) { | 673 key != dictionary->end_keys(); ++key) { |
653 Value* merge_value; | 674 Value* merge_value; |
654 if (dictionary->GetWithoutPathExpansion(*key, &merge_value)) { | 675 if (dictionary->GetWithoutPathExpansion(*key, &merge_value)) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 if (lhs_it != end() || rhs_it != other_list->end()) | 939 if (lhs_it != end() || rhs_it != other_list->end()) |
919 return false; | 940 return false; |
920 | 941 |
921 return true; | 942 return true; |
922 } | 943 } |
923 | 944 |
924 ValueSerializer::~ValueSerializer() { | 945 ValueSerializer::~ValueSerializer() { |
925 } | 946 } |
926 | 947 |
927 } // namespace base | 948 } // namespace base |
OLD | NEW |