| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 bool GetDictionary(size_t index, DictionaryValue** out_value) const; | 327 bool GetDictionary(size_t index, DictionaryValue** out_value) const; |
| 328 bool GetList(size_t index, ListValue** out_value) const; | 328 bool GetList(size_t index, ListValue** out_value) const; |
| 329 | 329 |
| 330 // Removes the Value with the specified index from this list. | 330 // Removes the Value with the specified index from this list. |
| 331 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 331 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be |
| 332 // passed out via |out_value|. If |out_value| is NULL, the removed value will | 332 // passed out via |out_value|. If |out_value| is NULL, the removed value will |
| 333 // be deleted. This method returns true if |index| is valid; otherwise | 333 // be deleted. This method returns true if |index| is valid; otherwise |
| 334 // it will return false and the ListValue object will be unchanged. | 334 // it will return false and the ListValue object will be unchanged. |
| 335 bool Remove(size_t index, Value** out_value); | 335 bool Remove(size_t index, Value** out_value); |
| 336 | 336 |
| 337 // Removes the first instance of |value| found in the list, if any. | 337 // Removes the first instance of |value| found in the list, if any, returning |
| 338 void Remove(const Value& value); | 338 // the index that it was located at (-1 for not present). |
| 339 int Remove(const Value& value); |
| 339 | 340 |
| 340 // Appends a Value to the end of the list. | 341 // Appends a Value to the end of the list. |
| 341 void Append(Value* in_value); | 342 void Append(Value* in_value); |
| 342 | 343 |
| 344 // Insert a Value at index. |
| 345 // Returns true if successful, or false if the index was out of range. |
| 346 bool Insert(size_t index, Value* in_value); |
| 347 |
| 343 // Iteration | 348 // Iteration |
| 344 typedef ValueVector::iterator iterator; | 349 typedef ValueVector::iterator iterator; |
| 345 typedef ValueVector::const_iterator const_iterator; | 350 typedef ValueVector::const_iterator const_iterator; |
| 346 | 351 |
| 347 ListValue::iterator begin() { return list_.begin(); } | 352 ListValue::iterator begin() { return list_.begin(); } |
| 348 ListValue::iterator end() { return list_.end(); } | 353 ListValue::iterator end() { return list_.end(); } |
| 349 | 354 |
| 350 ListValue::const_iterator begin() const { return list_.begin(); } | 355 ListValue::const_iterator begin() const { return list_.begin(); } |
| 351 ListValue::const_iterator end() const { return list_.end(); } | 356 ListValue::const_iterator end() const { return list_.end(); } |
| 352 | 357 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 365 virtual bool Serialize(const Value& root) = 0; | 370 virtual bool Serialize(const Value& root) = 0; |
| 366 | 371 |
| 367 // This method deserializes the subclass-specific format into a Value object. | 372 // This method deserializes the subclass-specific format into a Value object. |
| 368 // If the return value is non-NULL, the caller takes ownership of returned | 373 // If the return value is non-NULL, the caller takes ownership of returned |
| 369 // Value. If the return value is NULL, and if error_message is non-NULL, | 374 // Value. If the return value is NULL, and if error_message is non-NULL, |
| 370 // error_message should be filled with a message describing the error. | 375 // error_message should be filled with a message describing the error. |
| 371 virtual Value* Deserialize(std::string* error_message) = 0; | 376 virtual Value* Deserialize(std::string* error_message) = 0; |
| 372 }; | 377 }; |
| 373 | 378 |
| 374 #endif // BASE_VALUES_H_ | 379 #endif // BASE_VALUES_H_ |
| OLD | NEW |