| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/float_util.h" | 9 #include "base/float_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 ///////////////////// DictionaryValue //////////////////// | 346 ///////////////////// DictionaryValue //////////////////// |
| 347 | 347 |
| 348 DictionaryValue::DictionaryValue() | 348 DictionaryValue::DictionaryValue() |
| 349 : Value(TYPE_DICTIONARY) { | 349 : Value(TYPE_DICTIONARY) { |
| 350 } | 350 } |
| 351 | 351 |
| 352 DictionaryValue::~DictionaryValue() { | 352 DictionaryValue::~DictionaryValue() { |
| 353 Clear(); | 353 Clear(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 bool DictionaryValue::GetAsDictionary(DictionaryValue** out_value) { | |
| 357 if (out_value) | |
| 358 *out_value = this; | |
| 359 return true; | |
| 360 } | |
| 361 | |
| 362 bool DictionaryValue::GetAsDictionary(const DictionaryValue** out_value) const { | |
| 363 if (out_value) | |
| 364 *out_value = this; | |
| 365 return true; | |
| 366 } | |
| 367 | |
| 368 bool DictionaryValue::HasKey(const std::string& key) const { | 356 bool DictionaryValue::HasKey(const std::string& key) const { |
| 369 DCHECK(IsStringUTF8(key)); | 357 DCHECK(IsStringUTF8(key)); |
| 370 ValueMap::const_iterator current_entry = dictionary_.find(key); | 358 ValueMap::const_iterator current_entry = dictionary_.find(key); |
| 371 DCHECK((current_entry == dictionary_.end()) || current_entry->second); | 359 DCHECK((current_entry == dictionary_.end()) || current_entry->second); |
| 372 return current_entry != dictionary_.end(); | 360 return current_entry != dictionary_.end(); |
| 373 } | 361 } |
| 374 | 362 |
| 375 void DictionaryValue::Clear() { | 363 void DictionaryValue::Clear() { |
| 376 ValueMap::iterator dict_iterator = dictionary_.begin(); | 364 ValueMap::iterator dict_iterator = dictionary_.begin(); |
| 377 while (dict_iterator != dictionary_.end()) { | 365 while (dict_iterator != dictionary_.end()) { |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 static_cast<const DictionaryValue*>(merge_value)); | 675 static_cast<const DictionaryValue*>(merge_value)); |
| 688 continue; | 676 continue; |
| 689 } | 677 } |
| 690 } | 678 } |
| 691 // All other cases: Make a copy and hook it up. | 679 // All other cases: Make a copy and hook it up. |
| 692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); | 680 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); |
| 693 } | 681 } |
| 694 } | 682 } |
| 695 } | 683 } |
| 696 | 684 |
| 685 bool DictionaryValue::GetAsDictionary(DictionaryValue** out_value) { |
| 686 if (out_value) |
| 687 *out_value = this; |
| 688 return true; |
| 689 } |
| 690 |
| 691 bool DictionaryValue::GetAsDictionary(const DictionaryValue** out_value) const { |
| 692 if (out_value) |
| 693 *out_value = this; |
| 694 return true; |
| 695 } |
| 696 |
| 697 DictionaryValue* DictionaryValue::DeepCopy() const { | 697 DictionaryValue* DictionaryValue::DeepCopy() const { |
| 698 DictionaryValue* result = new DictionaryValue; | 698 DictionaryValue* result = new DictionaryValue; |
| 699 | 699 |
| 700 for (ValueMap::const_iterator current_entry(dictionary_.begin()); | 700 for (ValueMap::const_iterator current_entry(dictionary_.begin()); |
| 701 current_entry != dictionary_.end(); ++current_entry) { | 701 current_entry != dictionary_.end(); ++current_entry) { |
| 702 result->SetWithoutPathExpansion(current_entry->first, | 702 result->SetWithoutPathExpansion(current_entry->first, |
| 703 current_entry->second->DeepCopy()); | 703 current_entry->second->DeepCopy()); |
| 704 } | 704 } |
| 705 | 705 |
| 706 return result; | 706 return result; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 if (lhs_it != end() || rhs_it != other_list->end()) | 945 if (lhs_it != end() || rhs_it != other_list->end()) |
| 946 return false; | 946 return false; |
| 947 | 947 |
| 948 return true; | 948 return true; |
| 949 } | 949 } |
| 950 | 950 |
| 951 ValueSerializer::~ValueSerializer() { | 951 ValueSerializer::~ValueSerializer() { |
| 952 } | 952 } |
| 953 | 953 |
| 954 } // namespace base | 954 } // namespace base |
| OLD | NEW |