| 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 // This file specifies a recursive data storage class called Value intended for | 5 // This file specifies a recursive data storage class called Value intended for |
| 6 // storing settings and other persistable data. | 6 // storing settings and other persistable data. |
| 7 // | 7 // |
| 8 // A Value represents something that can be stored in JSON or passed to/from | 8 // A Value represents something that can be stored in JSON or passed to/from |
| 9 // JavaScript. As such, it is NOT a generalized variant type, since only the | 9 // JavaScript. As such, it is NOT a generalized variant type, since only the |
| 10 // types supported by JavaScript/JSON are supported. | 10 // types supported by JavaScript/JSON are supported. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Note: Do not add more types. See the file-level comment above for why. | 154 // Note: Do not add more types. See the file-level comment above for why. |
| 155 | 155 |
| 156 // This creates a deep copy of the entire Value tree, and returns a pointer | 156 // This creates a deep copy of the entire Value tree, and returns a pointer |
| 157 // to the copy. The caller gets ownership of the copy, of course. | 157 // to the copy. The caller gets ownership of the copy, of course. |
| 158 // Subclasses return their own type directly in their overrides; | 158 // Subclasses return their own type directly in their overrides; |
| 159 // this works because C++ supports covariant return types. | 159 // this works because C++ supports covariant return types. |
| 160 Value* DeepCopy() const; | 160 Value* DeepCopy() const; |
| 161 // Preferred version of DeepCopy. TODO(estade): remove the above. | 161 // Preferred version of DeepCopy. TODO(estade): remove the above. |
| 162 std::unique_ptr<Value> CreateDeepCopy() const; | 162 std::unique_ptr<Value> CreateDeepCopy() const; |
| 163 | 163 |
| 164 // Comparison operators so that Values can easily be used with standard |
| 165 // library algorithms and associative containers. |
| 166 BASE_EXPORT friend bool operator==(const Value& lhs, const Value& rhs); |
| 167 BASE_EXPORT friend bool operator!=(const Value& lhs, const Value& rhs); |
| 168 BASE_EXPORT friend bool operator<(const Value& lhs, const Value& rhs); |
| 169 BASE_EXPORT friend bool operator>(const Value& lhs, const Value& rhs); |
| 170 BASE_EXPORT friend bool operator<=(const Value& lhs, const Value& rhs); |
| 171 BASE_EXPORT friend bool operator>=(const Value& lhs, const Value& rhs); |
| 172 |
| 164 // Compares if two Value objects have equal contents. | 173 // Compares if two Value objects have equal contents. |
| 174 // DEPRECATED, use operator==(const Value& lhs, const Value& rhs) instead. |
| 175 // TODO(crbug.com/646113): Delete this and migrate callsites. |
| 165 bool Equals(const Value* other) const; | 176 bool Equals(const Value* other) const; |
| 166 | 177 |
| 167 // Compares if two Value objects have equal contents. Can handle NULLs. | 178 // Compares if two Value objects have equal contents. Can handle NULLs. |
| 168 // NULLs are considered equal but different from Value::CreateNullValue(). | 179 // NULLs are considered equal but different from Value::CreateNullValue(). |
| 180 // DEPRECATED, use operator==(const Value& lhs, const Value& rhs) instead. |
| 181 // TODO(crbug.com/646113): Delete this and migrate callsites. |
| 169 static bool Equals(const Value* a, const Value* b); | 182 static bool Equals(const Value* a, const Value* b); |
| 170 | 183 |
| 171 protected: | 184 protected: |
| 172 // TODO(crbug.com/646113): Make these private once DictionaryValue and | 185 // TODO(crbug.com/646113): Make these private once DictionaryValue and |
| 173 // ListValue are properly inlined. | 186 // ListValue are properly inlined. |
| 174 Type type_; | 187 Type type_; |
| 175 | 188 |
| 176 union { | 189 union { |
| 177 bool bool_value_; | 190 bool bool_value_; |
| 178 int int_value_; | 191 int int_value_; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return out << static_cast<const Value&>(value); | 526 return out << static_cast<const Value&>(value); |
| 514 } | 527 } |
| 515 | 528 |
| 516 // Stream operator so that enum class Types can be used in log statements. | 529 // Stream operator so that enum class Types can be used in log statements. |
| 517 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 530 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
| 518 const Value::Type& type); | 531 const Value::Type& type); |
| 519 | 532 |
| 520 } // namespace base | 533 } // namespace base |
| 521 | 534 |
| 522 #endif // BASE_VALUES_H_ | 535 #endif // BASE_VALUES_H_ |
| OLD | NEW |