| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 376 // This type of Value represents a list of other Value values. | 376 // This type of Value represents a list of other Value values. | 
| 377 class BASE_EXPORT ListValue : public Value { | 377 class BASE_EXPORT ListValue : public Value { | 
| 378  public: | 378  public: | 
| 379   using const_iterator = ListStorage::const_iterator; | 379   using const_iterator = ListStorage::const_iterator; | 
| 380   using iterator = ListStorage::iterator; | 380   using iterator = ListStorage::iterator; | 
| 381 | 381 | 
| 382   // Returns |value| if it is a list, nullptr otherwise. | 382   // Returns |value| if it is a list, nullptr otherwise. | 
| 383   static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value); | 383   static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value); | 
| 384 | 384 | 
| 385   ListValue(); | 385   ListValue(); | 
|  | 386   explicit ListValue(const ListStorage& in_list); | 
|  | 387   explicit ListValue(ListStorage&& in_list) noexcept; | 
| 386 | 388 | 
| 387   // Clears the contents of this ListValue | 389   // Clears the contents of this ListValue | 
| 388   void Clear(); | 390   void Clear(); | 
| 389 | 391 | 
| 390   // Returns the number of Values in this list. | 392   // Returns the number of Values in this list. | 
| 391   size_t GetSize() const { return list_->size(); } | 393   size_t GetSize() const { return list_->size(); } | 
| 392 | 394 | 
| 393   // Returns the capacity of storage for Values in this list. | 395   // Returns the capacity of storage for Values in this list. | 
| 394   size_t capacity() const { return list_->capacity(); } | 396   size_t capacity() const { return list_->capacity(); } | 
| 395 | 397 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 423   bool GetInteger(size_t index, int* out_value) const; | 425   bool GetInteger(size_t index, int* out_value) const; | 
| 424   // Values of both type Type::INTEGER and Type::DOUBLE can be obtained as | 426   // Values of both type Type::INTEGER and Type::DOUBLE can be obtained as | 
| 425   // doubles. | 427   // doubles. | 
| 426   bool GetDouble(size_t index, double* out_value) const; | 428   bool GetDouble(size_t index, double* out_value) const; | 
| 427   bool GetString(size_t index, std::string* out_value) const; | 429   bool GetString(size_t index, std::string* out_value) const; | 
| 428   bool GetString(size_t index, string16* out_value) const; | 430   bool GetString(size_t index, string16* out_value) const; | 
| 429   bool GetBinary(size_t index, const Value** out_value) const; | 431   bool GetBinary(size_t index, const Value** out_value) const; | 
| 430   bool GetBinary(size_t index, Value** out_value); | 432   bool GetBinary(size_t index, Value** out_value); | 
| 431   bool GetDictionary(size_t index, const DictionaryValue** out_value) const; | 433   bool GetDictionary(size_t index, const DictionaryValue** out_value) const; | 
| 432   bool GetDictionary(size_t index, DictionaryValue** out_value); | 434   bool GetDictionary(size_t index, DictionaryValue** out_value); | 
|  | 435 | 
|  | 436   using Value::GetList; | 
| 433   bool GetList(size_t index, const ListValue** out_value) const; | 437   bool GetList(size_t index, const ListValue** out_value) const; | 
| 434   bool GetList(size_t index, ListValue** out_value); | 438   bool GetList(size_t index, ListValue** out_value); | 
| 435 | 439 | 
| 436   // Removes the Value with the specified index from this list. | 440   // Removes the Value with the specified index from this list. | 
| 437   // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 441   // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 
| 438   // passed out via |out_value|.  If |out_value| is NULL, the removed value will | 442   // passed out via |out_value|.  If |out_value| is NULL, the removed value will | 
| 439   // be deleted.  This method returns true if |index| is valid; otherwise | 443   // be deleted.  This method returns true if |index| is valid; otherwise | 
| 440   // it will return false and the ListValue object will be unchanged. | 444   // it will return false and the ListValue object will be unchanged. | 
| 441   bool Remove(size_t index, std::unique_ptr<Value>* out_value); | 445   bool Remove(size_t index, std::unique_ptr<Value>* out_value); | 
| 442 | 446 | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 534   return out << static_cast<const Value&>(value); | 538   return out << static_cast<const Value&>(value); | 
| 535 } | 539 } | 
| 536 | 540 | 
| 537 // Stream operator so that enum class Types can be used in log statements. | 541 // Stream operator so that enum class Types can be used in log statements. | 
| 538 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 542 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 
| 539                                      const Value::Type& type); | 543                                      const Value::Type& type); | 
| 540 | 544 | 
| 541 }  // namespace base | 545 }  // namespace base | 
| 542 | 546 | 
| 543 #endif  // BASE_VALUES_H_ | 547 #endif  // BASE_VALUES_H_ | 
| OLD | NEW | 
|---|