OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 411 |
412 // Appends a Value if it's not already present. Takes ownership of the | 412 // Appends a Value if it's not already present. Takes ownership of the |
413 // |in_value|. Returns true if successful, or false if the value was already | 413 // |in_value|. Returns true if successful, or false if the value was already |
414 // present. If the value was already present the |in_value| is deleted. | 414 // present. If the value was already present the |in_value| is deleted. |
415 bool AppendIfNotPresent(Value* in_value); | 415 bool AppendIfNotPresent(Value* in_value); |
416 | 416 |
417 // Insert a Value at index. | 417 // Insert a Value at index. |
418 // Returns true if successful, or false if the index was out of range. | 418 // Returns true if successful, or false if the index was out of range. |
419 bool Insert(size_t index, Value* in_value); | 419 bool Insert(size_t index, Value* in_value); |
420 | 420 |
| 421 // Searches for the first instance of |value| in the list using the Equals |
| 422 // method of the Value type. |
| 423 // Returns a const_iterator to the found item or to end() if none exists. |
| 424 const_iterator Find(const Value& value) const; |
| 425 |
421 // Swaps contents with the |other| list. | 426 // Swaps contents with the |other| list. |
422 void Swap(ListValue* other) { | 427 void Swap(ListValue* other) { |
423 list_.swap(other->list_); | 428 list_.swap(other->list_); |
424 } | 429 } |
425 | 430 |
426 // Iteration. | 431 // Iteration. |
427 iterator begin() { return list_.begin(); } | 432 iterator begin() { return list_.begin(); } |
428 iterator end() { return list_.end(); } | 433 iterator end() { return list_.end(); } |
429 | 434 |
430 const_iterator begin() const { return list_.begin(); } | 435 const_iterator begin() const { return list_.begin(); } |
(...skipping 30 matching lines...) Expand all Loading... |
461 | 466 |
462 } // namespace base | 467 } // namespace base |
463 | 468 |
464 // http://crbug.com/88666 | 469 // http://crbug.com/88666 |
465 using base::DictionaryValue; | 470 using base::DictionaryValue; |
466 using base::ListValue; | 471 using base::ListValue; |
467 using base::StringValue; | 472 using base::StringValue; |
468 using base::Value; | 473 using base::Value; |
469 | 474 |
470 #endif // BASE_VALUES_H_ | 475 #endif // BASE_VALUES_H_ |
OLD | NEW |