OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 return CreateNullValue(); | 126 return CreateNullValue(); |
127 } | 127 } |
128 | 128 |
129 bool Value::Equals(const Value* other) const { | 129 bool Value::Equals(const Value* other) const { |
130 // This method should only be getting called for null Values--all subclasses | 130 // This method should only be getting called for null Values--all subclasses |
131 // need to provide their own implementation;. | 131 // need to provide their own implementation;. |
132 DCHECK(IsType(TYPE_NULL)); | 132 DCHECK(IsType(TYPE_NULL)); |
133 return other->IsType(TYPE_NULL); | 133 return other->IsType(TYPE_NULL); |
134 } | 134 } |
135 | 135 |
136 // static | |
137 bool Value::Equals(const Value* a, const Value* b) { | |
Aaron Boodman
2010/11/23 20:35:13
Needs a unit test.
battre (please use the other)
2010/11/30 17:46:53
Done.
| |
138 if ((a == NULL) && (b == NULL)) return true; | |
139 if ((a == NULL) ^ (b == NULL)) return false; | |
140 return a->Equals(b); | |
141 } | |
142 | |
136 Value::Value(ValueType type) : type_(type) { | 143 Value::Value(ValueType type) : type_(type) { |
137 } | 144 } |
138 | 145 |
139 ///////////////////// FundamentalValue //////////////////// | 146 ///////////////////// FundamentalValue //////////////////// |
140 | 147 |
141 FundamentalValue::FundamentalValue(bool in_value) | 148 FundamentalValue::FundamentalValue(bool in_value) |
142 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { | 149 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { |
143 } | 150 } |
144 | 151 |
145 FundamentalValue::FundamentalValue(int in_value) | 152 FundamentalValue::FundamentalValue(int in_value) |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 return false; | 984 return false; |
978 } | 985 } |
979 if (lhs_it != end() || rhs_it != other_list->end()) | 986 if (lhs_it != end() || rhs_it != other_list->end()) |
980 return false; | 987 return false; |
981 | 988 |
982 return true; | 989 return true; |
983 } | 990 } |
984 | 991 |
985 ValueSerializer::~ValueSerializer() { | 992 ValueSerializer::~ValueSerializer() { |
986 } | 993 } |
OLD | NEW |