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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // Note that the list always owns the Value passed out via out_value. | 314 // Note that the list always owns the Value passed out via out_value. |
315 bool Get(size_t index, Value** out_value) const; | 315 bool Get(size_t index, Value** out_value) const; |
316 | 316 |
317 // Convenience forms of Get(). Modifies value (and returns true) only if | 317 // Convenience forms of Get(). Modifies value (and returns true) only if |
318 // the index is valid and the Value at that index can be returned in | 318 // the index is valid and the Value at that index can be returned in |
319 // the specified form. | 319 // the specified form. |
320 bool GetDictionary(size_t index, DictionaryValue** out_value) const; | 320 bool GetDictionary(size_t index, DictionaryValue** out_value) const; |
321 | 321 |
322 // Removes the Value with the specified index from this list. | 322 // Removes the Value with the specified index from this list. |
323 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 323 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be |
324 // passed out via out_value. If |out_value| is NULL, the removed value will | 324 // passed out via |out_value|. If |out_value| is NULL, the removed value will |
325 // be deleted. This method returns true if |index| is valid; otherwise | 325 // be deleted. This method returns true if |index| is valid; otherwise |
326 // it will return false and the ListValue object will be unchanged. | 326 // it will return false and the ListValue object will be unchanged. |
327 bool Remove(size_t index, Value** out_value); | 327 bool Remove(size_t index, Value** out_value); |
328 | 328 |
329 // Appends a Value to the end of the list. | 329 // Appends a Value to the end of the list. |
330 void Append(Value* in_value); | 330 void Append(Value* in_value); |
331 | 331 |
332 // Iteration | 332 // Iteration |
333 typedef ValueVector::iterator iterator; | 333 typedef ValueVector::iterator iterator; |
334 typedef ValueVector::const_iterator const_iterator; | 334 typedef ValueVector::const_iterator const_iterator; |
(...skipping 23 matching lines...) Expand all Loading... |
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 // If the return value is non-NULL, the caller takes ownership of returned | 361 // If the return value is non-NULL, the caller takes ownership of returned |
362 // Value. If the return value is NULL, and if error_message is non-NULL, | 362 // Value. If the return value is NULL, and if error_message is non-NULL, |
363 // error_message should be filled with a message describing the error. | 363 // error_message should be filled with a message describing the error. |
364 virtual Value* Deserialize(std::string* error_message) = 0; | 364 virtual Value* Deserialize(std::string* error_message) = 0; |
365 }; | 365 }; |
366 | 366 |
367 #endif // BASE_VALUES_H_ | 367 #endif // BASE_VALUES_H_ |
OLD | NEW |