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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 static_cast<const DictionaryValue*>(merge_value)); | 687 static_cast<const DictionaryValue*>(merge_value)); |
688 continue; | 688 continue; |
689 } | 689 } |
690 } | 690 } |
691 // All other cases: Make a copy and hook it up. | 691 // All other cases: Make a copy and hook it up. |
692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); | 692 SetWithoutPathExpansion(*key, merge_value->DeepCopy()); |
693 } | 693 } |
694 } | 694 } |
695 } | 695 } |
696 | 696 |
| 697 void DictionaryValue::Swap(DictionaryValue* other) { |
| 698 dictionary_.swap(other->dictionary_); |
| 699 } |
| 700 |
697 DictionaryValue* DictionaryValue::DeepCopy() const { | 701 DictionaryValue* DictionaryValue::DeepCopy() const { |
698 DictionaryValue* result = new DictionaryValue; | 702 DictionaryValue* result = new DictionaryValue; |
699 | 703 |
700 for (ValueMap::const_iterator current_entry(dictionary_.begin()); | 704 for (ValueMap::const_iterator current_entry(dictionary_.begin()); |
701 current_entry != dictionary_.end(); ++current_entry) { | 705 current_entry != dictionary_.end(); ++current_entry) { |
702 result->SetWithoutPathExpansion(current_entry->first, | 706 result->SetWithoutPathExpansion(current_entry->first, |
703 current_entry->second->DeepCopy()); | 707 current_entry->second->DeepCopy()); |
704 } | 708 } |
705 | 709 |
706 return result; | 710 return result; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 return false; | 905 return false; |
902 | 906 |
903 list_.insert(list_.begin() + index, in_value); | 907 list_.insert(list_.begin() + index, in_value); |
904 return true; | 908 return true; |
905 } | 909 } |
906 | 910 |
907 ListValue::const_iterator ListValue::Find(const Value& value) const { | 911 ListValue::const_iterator ListValue::Find(const Value& value) const { |
908 return std::find_if(list_.begin(), list_.end(), ValueEquals(&value)); | 912 return std::find_if(list_.begin(), list_.end(), ValueEquals(&value)); |
909 } | 913 } |
910 | 914 |
| 915 void ListValue::Swap(ListValue* other) { |
| 916 list_.swap(other->list_); |
| 917 } |
| 918 |
911 bool ListValue::GetAsList(ListValue** out_value) { | 919 bool ListValue::GetAsList(ListValue** out_value) { |
912 if (out_value) | 920 if (out_value) |
913 *out_value = this; | 921 *out_value = this; |
914 return true; | 922 return true; |
915 } | 923 } |
916 | 924 |
917 bool ListValue::GetAsList(const ListValue** out_value) const { | 925 bool ListValue::GetAsList(const ListValue** out_value) const { |
918 if (out_value) | 926 if (out_value) |
919 *out_value = this; | 927 *out_value = this; |
920 return true; | 928 return true; |
(...skipping 24 matching lines...) Expand all Loading... |
945 if (lhs_it != end() || rhs_it != other_list->end()) | 953 if (lhs_it != end() || rhs_it != other_list->end()) |
946 return false; | 954 return false; |
947 | 955 |
948 return true; | 956 return true; |
949 } | 957 } |
950 | 958 |
951 ValueSerializer::~ValueSerializer() { | 959 ValueSerializer::~ValueSerializer() { |
952 } | 960 } |
953 | 961 |
954 } // namespace base | 962 } // namespace base |
OLD | NEW |