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" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return other->IsType(TYPE_NULL); | 167 return other->IsType(TYPE_NULL); |
168 } | 168 } |
169 | 169 |
170 // static | 170 // static |
171 bool Value::Equals(const Value* a, const Value* b) { | 171 bool Value::Equals(const Value* a, const Value* b) { |
172 if ((a == NULL) && (b == NULL)) return true; | 172 if ((a == NULL) && (b == NULL)) return true; |
173 if ((a == NULL) ^ (b == NULL)) return false; | 173 if ((a == NULL) ^ (b == NULL)) return false; |
174 return a->Equals(b); | 174 return a->Equals(b); |
175 } | 175 } |
176 | 176 |
177 Value::Value(Type type) : type_(type) { | 177 Value::Value(Type type) : type_(type) {} |
| 178 |
| 179 Value::Value(const Value& that) : type_(that.type_) {} |
| 180 |
| 181 Value& Value::operator=(const Value& that) { |
| 182 type_ = that.type_; |
| 183 return *this; |
178 } | 184 } |
179 | 185 |
180 ///////////////////// FundamentalValue //////////////////// | 186 ///////////////////// FundamentalValue //////////////////// |
181 | 187 |
182 FundamentalValue::FundamentalValue(bool in_value) | 188 FundamentalValue::FundamentalValue(bool in_value) |
183 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { | 189 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { |
184 } | 190 } |
185 | 191 |
186 FundamentalValue::FundamentalValue(int in_value) | 192 FundamentalValue::FundamentalValue(int in_value) |
187 : Value(TYPE_INTEGER), integer_value_(in_value) { | 193 : Value(TYPE_INTEGER), integer_value_(in_value) { |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1135 |
1130 std::ostream& operator<<(std::ostream& out, const Value& value) { | 1136 std::ostream& operator<<(std::ostream& out, const Value& value) { |
1131 std::string json; | 1137 std::string json; |
1132 JSONWriter::WriteWithOptions(&value, | 1138 JSONWriter::WriteWithOptions(&value, |
1133 JSONWriter::OPTIONS_PRETTY_PRINT, | 1139 JSONWriter::OPTIONS_PRETTY_PRINT, |
1134 &json); | 1140 &json); |
1135 return out << json; | 1141 return out << json; |
1136 } | 1142 } |
1137 | 1143 |
1138 } // namespace base | 1144 } // namespace base |
OLD | NEW |