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 <algorithm> | 7 #include <algorithm> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/float_util.h" | 10 #include "base/float_util.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 | 15 |
| 16 namespace base { |
| 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 // Make a deep copy of |node|, but don't include empty lists or dictionaries | 20 // Make a deep copy of |node|, but don't include empty lists or dictionaries |
19 // in the copy. It's possible for this function to return NULL and it | 21 // in the copy. It's possible for this function to return NULL and it |
20 // expects |node| to always be non-NULL. | 22 // expects |node| to always be non-NULL. |
21 Value* CopyWithoutEmptyChildren(const Value* node) { | 23 Value* CopyWithoutEmptyChildren(const Value* node) { |
22 DCHECK(node); | 24 DCHECK(node); |
23 switch (node->GetType()) { | 25 switch (node->GetType()) { |
24 case Value::TYPE_LIST: { | 26 case Value::TYPE_LIST: { |
25 const ListValue* list = static_cast<const ListValue*>(node); | 27 const ListValue* list = static_cast<const ListValue*>(node); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 bool operator ()(const Value* second) const { | 71 bool operator ()(const Value* second) const { |
70 return first_->Equals(second); | 72 return first_->Equals(second); |
71 } | 73 } |
72 | 74 |
73 private: | 75 private: |
74 const Value* first_; | 76 const Value* first_; |
75 }; | 77 }; |
76 | 78 |
77 } // namespace | 79 } // namespace |
78 | 80 |
79 namespace base { | |
80 | |
81 ///////////////////// Value //////////////////// | |
82 | |
83 Value::~Value() { | 81 Value::~Value() { |
84 } | 82 } |
85 | 83 |
86 // static | 84 // static |
87 Value* Value::CreateNullValue() { | 85 Value* Value::CreateNullValue() { |
88 return new Value(TYPE_NULL); | 86 return new Value(TYPE_NULL); |
89 } | 87 } |
90 | 88 |
91 // static | 89 // static |
92 FundamentalValue* Value::CreateBooleanValue(bool in_value) { | 90 FundamentalValue* Value::CreateBooleanValue(bool in_value) { |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1108 |
1111 std::ostream& operator<<(std::ostream& out, const Value& value) { | 1109 std::ostream& operator<<(std::ostream& out, const Value& value) { |
1112 std::string json; | 1110 std::string json; |
1113 JSONWriter::WriteWithOptions(&value, | 1111 JSONWriter::WriteWithOptions(&value, |
1114 JSONWriter::OPTIONS_PRETTY_PRINT, | 1112 JSONWriter::OPTIONS_PRETTY_PRINT, |
1115 &json); | 1113 &json); |
1116 return out << json; | 1114 return out << json; |
1117 } | 1115 } |
1118 | 1116 |
1119 } // namespace base | 1117 } // namespace base |
OLD | NEW |