OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 // This interface is implemented by classes that know how to serialize and | 352 // This interface is implemented by classes that know how to serialize and |
353 // deserialize Value objects. | 353 // deserialize Value objects. |
354 class ValueSerializer { | 354 class ValueSerializer { |
355 public: | 355 public: |
356 virtual ~ValueSerializer() {} | 356 virtual ~ValueSerializer() {} |
357 | 357 |
358 virtual bool Serialize(const Value& root) = 0; | 358 virtual bool Serialize(const Value& root) = 0; |
359 | 359 |
360 // This method deserializes the subclass-specific format into a Value object. | 360 // This method deserializes the subclass-specific format into a Value object. |
361 // The method should return true if and only if the root parameter is set | 361 // If the return value is non-NULL, the caller takes ownership of returned |
362 // to a complete Value representation of the serialized form. If the | 362 // Value. If the return value is NULL, and if error_message is non-NULL, |
363 // return value is true, the caller takes ownership of the objects pointed | 363 // error_message should be filled with a message describing the error. |
364 // to by root. If the return value is false, root should be unchanged and if | 364 virtual Value* Deserialize(std::string* error_message) = 0; |
365 // error_message is non-null, it should be filled with a message describing | |
366 // the error. | |
367 virtual bool Deserialize(Value** root, std::string* error_message) = 0; | |
368 }; | 365 }; |
369 | 366 |
370 #endif // BASE_VALUES_H_ | 367 #endif // BASE_VALUES_H_ |
OLD | NEW |