OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 intended for | 5 // This file specifies a recursive data storage class called Value intended for |
6 // storing setting and other persistable data. It includes the ability to | 6 // storing setting and other persistable data. It includes the ability to |
7 // specify (recursive) lists and dictionaries, so it's fairly expressive. | 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. |
8 // However, the API is optimized for the common case, namely storing a | 8 // However, the API is optimized for the common case, namely storing a |
9 // hierarchical tree of simple values. Given a DictionaryValue root, you can | 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can |
10 // easily do things like: | 10 // easily do things like: |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // Sets the list item at the given index to be the Value specified by | 407 // Sets the list item at the given index to be the Value specified by |
408 // the value given. If the index beyond the current end of the list, null | 408 // the value given. If the index beyond the current end of the list, null |
409 // Values will be used to pad out the list. | 409 // Values will be used to pad out the list. |
410 // Returns true if successful, or false if the index was negative or | 410 // Returns true if successful, or false if the index was negative or |
411 // the value is a null pointer. | 411 // the value is a null pointer. |
412 bool Set(size_t index, Value* in_value); | 412 bool Set(size_t index, Value* in_value); |
413 | 413 |
414 // Gets the Value at the given index. Modifies |out_value| (and returns true) | 414 // Gets the Value at the given index. Modifies |out_value| (and returns true) |
415 // only if the index falls within the current list range. | 415 // only if the index falls within the current list range. |
416 // Note that the list always owns the Value passed out via |out_value|. | 416 // Note that the list always owns the Value passed out via |out_value|. |
417 bool Get(size_t index, Value** out_value) const; | 417 bool Get(size_t index, const Value** out_value) const; |
| 418 bool Get(size_t index, Value** out_value); |
418 | 419 |
419 // Convenience forms of Get(). Modifies |out_value| (and returns true) | 420 // Convenience forms of Get(). Modifies |out_value| (and returns true) |
420 // only if the index is valid and the Value at that index can be returned | 421 // only if the index is valid and the Value at that index can be returned |
421 // in the specified form. | 422 // in the specified form. |
422 bool GetBoolean(size_t index, bool* out_value) const; | 423 bool GetBoolean(size_t index, bool* out_value) const; |
423 bool GetInteger(size_t index, int* out_value) const; | 424 bool GetInteger(size_t index, int* out_value) const; |
424 bool GetDouble(size_t index, double* out_value) const; | 425 bool GetDouble(size_t index, double* out_value) const; |
425 bool GetString(size_t index, std::string* out_value) const; | 426 bool GetString(size_t index, std::string* out_value) const; |
426 bool GetString(size_t index, string16* out_value) const; | 427 bool GetString(size_t index, string16* out_value) const; |
427 bool GetBinary(size_t index, BinaryValue** out_value) const; | 428 bool GetBinary(size_t index, const BinaryValue** out_value) const; |
428 bool GetDictionary(size_t index, DictionaryValue** out_value) const; | 429 bool GetBinary(size_t index, BinaryValue** out_value); |
429 bool GetList(size_t index, ListValue** out_value) const; | 430 bool GetDictionary(size_t index, const DictionaryValue** out_value) const; |
| 431 bool GetDictionary(size_t index, DictionaryValue** out_value); |
| 432 bool GetList(size_t index, const ListValue** out_value) const; |
| 433 bool GetList(size_t index, ListValue** out_value); |
430 | 434 |
431 // Removes the Value with the specified index from this list. | 435 // Removes the Value with the specified index from this list. |
432 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 436 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be |
433 // passed out via |out_value|. If |out_value| is NULL, the removed value will | 437 // passed out via |out_value|. If |out_value| is NULL, the removed value will |
434 // be deleted. This method returns true if |index| is valid; otherwise | 438 // be deleted. This method returns true if |index| is valid; otherwise |
435 // it will return false and the ListValue object will be unchanged. | 439 // it will return false and the ListValue object will be unchanged. |
436 virtual bool Remove(size_t index, Value** out_value); | 440 virtual bool Remove(size_t index, Value** out_value); |
437 | 441 |
438 // Removes the first instance of |value| found in the list, if any, and | 442 // Removes the first instance of |value| found in the list, if any, and |
439 // deletes it. |index| is the location where |value| was found. Returns false | 443 // deletes it. |index| is the location where |value| was found. Returns false |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 506 |
503 } // namespace base | 507 } // namespace base |
504 | 508 |
505 // http://crbug.com/88666 | 509 // http://crbug.com/88666 |
506 using base::DictionaryValue; | 510 using base::DictionaryValue; |
507 using base::ListValue; | 511 using base::ListValue; |
508 using base::StringValue; | 512 using base::StringValue; |
509 using base::Value; | 513 using base::Value; |
510 | 514 |
511 #endif // BASE_VALUES_H_ | 515 #endif // BASE_VALUES_H_ |
OLD | NEW |