| 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 settings and other persistable data. | 6 // storing settings and other persistable data. |
| 7 // | 7 // |
| 8 // A Value represents something that can be stored in JSON or passed to/from | 8 // A Value represents something that can be stored in JSON or passed to/from |
| 9 // JavaScript. As such, it is NOT a generalized variant type, since only the | 9 // JavaScript. As such, it is NOT a generalized variant type, since only the |
| 10 // types supported by JavaScript/JSON are supported. | 10 // types supported by JavaScript/JSON are supported. |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 462 |
| 463 // Convenience forms of Append. | 463 // Convenience forms of Append. |
| 464 void AppendBoolean(bool in_value); | 464 void AppendBoolean(bool in_value); |
| 465 void AppendInteger(int in_value); | 465 void AppendInteger(int in_value); |
| 466 void AppendDouble(double in_value); | 466 void AppendDouble(double in_value); |
| 467 void AppendString(StringPiece in_value); | 467 void AppendString(StringPiece in_value); |
| 468 void AppendString(const string16& in_value); | 468 void AppendString(const string16& in_value); |
| 469 void AppendStrings(const std::vector<std::string>& in_values); | 469 void AppendStrings(const std::vector<std::string>& in_values); |
| 470 void AppendStrings(const std::vector<string16>& in_values); | 470 void AppendStrings(const std::vector<string16>& in_values); |
| 471 | 471 |
| 472 // Appends a Value if it's not already present. Takes ownership of the | 472 // Appends a Value if it's not already present. Returns true if successful, |
| 473 // |in_value|. Returns true if successful, or false if the value was already | 473 // or false if the value was already |
| 474 // present. If the value was already present the |in_value| is deleted. | 474 bool AppendIfNotPresent(std::unique_ptr<Value> in_value); |
| 475 bool AppendIfNotPresent(Value* in_value); | |
| 476 | 475 |
| 477 // Insert a Value at index. | 476 // Insert a Value at index. |
| 478 // Returns true if successful, or false if the index was out of range. | 477 // Returns true if successful, or false if the index was out of range. |
| 479 bool Insert(size_t index, Value* in_value); | 478 bool Insert(size_t index, std::unique_ptr<Value> in_value); |
| 480 | 479 |
| 481 // Searches for the first instance of |value| in the list using the Equals | 480 // Searches for the first instance of |value| in the list using the Equals |
| 482 // method of the Value type. | 481 // method of the Value type. |
| 483 // Returns a const_iterator to the found item or to end() if none exists. | 482 // Returns a const_iterator to the found item or to end() if none exists. |
| 484 const_iterator Find(const Value& value) const; | 483 const_iterator Find(const Value& value) const; |
| 485 | 484 |
| 486 // Swaps contents with the |other| list. | 485 // Swaps contents with the |other| list. |
| 487 virtual void Swap(ListValue* other); | 486 virtual void Swap(ListValue* other); |
| 488 | 487 |
| 489 // Iteration. | 488 // Iteration. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 554 } |
| 556 | 555 |
| 557 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 556 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 558 const ListValue& value) { | 557 const ListValue& value) { |
| 559 return out << static_cast<const Value&>(value); | 558 return out << static_cast<const Value&>(value); |
| 560 } | 559 } |
| 561 | 560 |
| 562 } // namespace base | 561 } // namespace base |
| 563 | 562 |
| 564 #endif // BASE_VALUES_H_ | 563 #endif // BASE_VALUES_H_ |
| OLD | NEW |