OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 5 // This file specifies a recursive data storage class called Value |
6 // intended for storing setting and other persistable data. | 6 // intended for storing setting and other persistable data. |
7 // It includes the ability to specify (recursive) lists and dictionaries, so | 7 // It includes the ability to specify (recursive) lists and dictionaries, so |
8 // it's fairly expressive. However, the API is optimized for the common case, | 8 // it's fairly expressive. However, the API is optimized for the common case, |
9 // namely storing a hierarchical tree of simple values. Given a | 9 // namely storing a hierarchical tree of simple values. Given a |
10 // DictionaryValue root, you can easily do things like: | 10 // DictionaryValue root, you can easily do things like: |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // This interface is implemented by classes that know how to serialize and | 424 // This interface is implemented by classes that know how to serialize and |
425 // deserialize Value objects. | 425 // deserialize Value objects. |
426 class ValueSerializer { | 426 class ValueSerializer { |
427 public: | 427 public: |
428 virtual ~ValueSerializer() {} | 428 virtual ~ValueSerializer() {} |
429 | 429 |
430 virtual bool Serialize(const Value& root) = 0; | 430 virtual bool Serialize(const Value& root) = 0; |
431 | 431 |
432 // This method deserializes the subclass-specific format into a Value object. | 432 // This method deserializes the subclass-specific format into a Value object. |
433 // If the return value is non-NULL, the caller takes ownership of returned | 433 // If the return value is non-NULL, the caller takes ownership of returned |
434 // Value. If the return value is NULL, and if error_message is non-NULL, | 434 // Value. If the return value is NULL, and if error_code is non-NULL, |
435 // error_message should be filled with a message describing the error. | 435 // error_code will be set with the underlying error. |
436 virtual Value* Deserialize(std::string* error_message) = 0; | 436 // If |error_message| is non-null, it will be filled in with a formatted |
| 437 // error message including the location of the error if appropriate. |
| 438 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
437 }; | 439 }; |
438 | 440 |
439 #endif // BASE_VALUES_H_ | 441 #endif // BASE_VALUES_H_ |
OLD | NEW |