OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // it will return false and the ListValue object will be unchanged. | 394 // it will return false and the ListValue object will be unchanged. |
395 bool Remove(size_t index, Value** out_value); | 395 bool Remove(size_t index, Value** out_value); |
396 | 396 |
397 // Removes the first instance of |value| found in the list, if any, and | 397 // Removes the first instance of |value| found in the list, if any, and |
398 // deletes it. Returns the index that it was located at (-1 for not present). | 398 // deletes it. Returns the index that it was located at (-1 for not present). |
399 int Remove(const Value& value); | 399 int Remove(const Value& value); |
400 | 400 |
401 // Appends a Value to the end of the list. | 401 // Appends a Value to the end of the list. |
402 void Append(Value* in_value); | 402 void Append(Value* in_value); |
403 | 403 |
| 404 // Appends a Value if it's not already present. |
| 405 // Returns true if successful, or false if the value was already present. |
| 406 bool AppendIfNotPresent(Value* in_value); |
| 407 |
404 // Insert a Value at index. | 408 // Insert a Value at index. |
405 // Returns true if successful, or false if the index was out of range. | 409 // Returns true if successful, or false if the index was out of range. |
406 bool Insert(size_t index, Value* in_value); | 410 bool Insert(size_t index, Value* in_value); |
407 | 411 |
408 // Iteration | 412 // Iteration |
409 typedef ValueVector::iterator iterator; | 413 typedef ValueVector::iterator iterator; |
410 typedef ValueVector::const_iterator const_iterator; | 414 typedef ValueVector::const_iterator const_iterator; |
411 | 415 |
412 ListValue::iterator begin() { return list_.begin(); } | 416 ListValue::iterator begin() { return list_.begin(); } |
413 ListValue::iterator end() { return list_.end(); } | 417 ListValue::iterator end() { return list_.end(); } |
(...skipping 18 matching lines...) Expand all Loading... |
432 // This method deserializes the subclass-specific format into a Value object. | 436 // 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 | 437 // If the return value is non-NULL, the caller takes ownership of returned |
434 // Value. If the return value is NULL, and if error_code is non-NULL, | 438 // Value. If the return value is NULL, and if error_code is non-NULL, |
435 // error_code will be set with the underlying error. | 439 // error_code will be set with the underlying error. |
436 // If |error_message| is non-null, it will be filled in with a formatted | 440 // 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. | 441 // error message including the location of the error if appropriate. |
438 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 442 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
439 }; | 443 }; |
440 | 444 |
441 #endif // BASE_VALUES_H_ | 445 #endif // BASE_VALUES_H_ |
OLD | NEW |