| 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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 bool GetAsList(const ListValue** out_value) const override; | 485 bool GetAsList(const ListValue** out_value) const override; |
| 486 ListValue* DeepCopy() const override; | 486 ListValue* DeepCopy() const override; |
| 487 bool Equals(const Value* other) const override; | 487 bool Equals(const Value* other) const override; |
| 488 | 488 |
| 489 private: | 489 private: |
| 490 ValueVector list_; | 490 ValueVector list_; |
| 491 | 491 |
| 492 DISALLOW_COPY_AND_ASSIGN(ListValue); | 492 DISALLOW_COPY_AND_ASSIGN(ListValue); |
| 493 }; | 493 }; |
| 494 | 494 |
| 495 // This interface is implemented by classes that know how to serialize and | 495 // This interface is implemented by classes that know how to serialize |
| 496 // deserialize Value objects. | 496 // Value objects. |
| 497 class BASE_EXPORT ValueSerializer { | 497 class BASE_EXPORT ValueSerializer { |
| 498 public: | 498 public: |
| 499 virtual ~ValueSerializer(); | 499 virtual ~ValueSerializer(); |
| 500 | 500 |
| 501 virtual bool Serialize(const Value& root) = 0; | 501 virtual bool Serialize(const Value& root) = 0; |
| 502 }; |
| 503 |
| 504 // This interface is implemented by classes that know how to deserialize Value |
| 505 // objects. |
| 506 class BASE_EXPORT ValueDeserializer { |
| 507 public: |
| 508 virtual ~ValueDeserializer(); |
| 502 | 509 |
| 503 // This method deserializes the subclass-specific format into a Value object. | 510 // This method deserializes the subclass-specific format into a Value object. |
| 504 // If the return value is non-NULL, the caller takes ownership of returned | 511 // If the return value is non-NULL, the caller takes ownership of returned |
| 505 // Value. If the return value is NULL, and if error_code is non-NULL, | 512 // Value. If the return value is NULL, and if error_code is non-NULL, |
| 506 // error_code will be set with the underlying error. | 513 // error_code will be set with the underlying error. |
| 507 // If |error_message| is non-null, it will be filled in with a formatted | 514 // If |error_message| is non-null, it will be filled in with a formatted |
| 508 // error message including the location of the error if appropriate. | 515 // error message including the location of the error if appropriate. |
| 509 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 516 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
| 510 }; | 517 }; |
| 511 | 518 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 531 } | 538 } |
| 532 | 539 |
| 533 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 540 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 534 const ListValue& value) { | 541 const ListValue& value) { |
| 535 return out << static_cast<const Value&>(value); | 542 return out << static_cast<const Value&>(value); |
| 536 } | 543 } |
| 537 | 544 |
| 538 } // namespace base | 545 } // namespace base |
| 539 | 546 |
| 540 #endif // BASE_VALUES_H_ | 547 #endif // BASE_VALUES_H_ |
| OLD | NEW |