OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 748 |
749 Value* entry = entry_iterator->second; | 749 Value* entry = entry_iterator->second; |
750 if (out_value) | 750 if (out_value) |
751 out_value->reset(entry); | 751 out_value->reset(entry); |
752 else | 752 else |
753 delete entry; | 753 delete entry; |
754 dictionary_.erase(entry_iterator); | 754 dictionary_.erase(entry_iterator); |
755 return true; | 755 return true; |
756 } | 756 } |
757 | 757 |
758 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() { | 758 DictionaryValue* DictionaryValue::DeepCopyWithoutEmptyChildren() const { |
759 Value* copy = CopyWithoutEmptyChildren(this); | 759 Value* copy = CopyWithoutEmptyChildren(this); |
760 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; | 760 return copy ? static_cast<DictionaryValue*>(copy) : new DictionaryValue; |
761 } | 761 } |
762 | 762 |
763 void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { | 763 void DictionaryValue::MergeDictionary(const DictionaryValue* dictionary) { |
764 for (DictionaryValue::Iterator it(*dictionary); !it.IsAtEnd(); it.Advance()) { | 764 for (DictionaryValue::Iterator it(*dictionary); !it.IsAtEnd(); it.Advance()) { |
765 const Value* merge_value = &it.value(); | 765 const Value* merge_value = &it.value(); |
766 // Check whether we have to merge dictionaries. | 766 // Check whether we have to merge dictionaries. |
767 if (merge_value->IsType(Value::TYPE_DICTIONARY)) { | 767 if (merge_value->IsType(Value::TYPE_DICTIONARY)) { |
768 DictionaryValue* sub_dict; | 768 DictionaryValue* sub_dict; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 | 1113 |
1114 std::ostream& operator<<(std::ostream& out, const Value& value) { | 1114 std::ostream& operator<<(std::ostream& out, const Value& value) { |
1115 std::string json; | 1115 std::string json; |
1116 JSONWriter::WriteWithOptions(&value, | 1116 JSONWriter::WriteWithOptions(&value, |
1117 JSONWriter::OPTIONS_PRETTY_PRINT, | 1117 JSONWriter::OPTIONS_PRETTY_PRINT, |
1118 &json); | 1118 &json); |
1119 return out << json; | 1119 return out << json; |
1120 } | 1120 } |
1121 | 1121 |
1122 } // namespace base | 1122 } // namespace base |
OLD | NEW |