| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 size_t size_; | 202 size_t size_; |
| 203 | 203 |
| 204 DISALLOW_COPY_AND_ASSIGN(BinaryValue); | 204 DISALLOW_COPY_AND_ASSIGN(BinaryValue); |
| 205 }; | 205 }; |
| 206 | 206 |
| 207 // DictionaryValue provides a key-value dictionary with (optional) "path" | 207 // DictionaryValue provides a key-value dictionary with (optional) "path" |
| 208 // parsing for recursive access; see the comment at the top of the file. Keys | 208 // parsing for recursive access; see the comment at the top of the file. Keys |
| 209 // are |std::string|s and should be UTF-8 encoded. | 209 // are |std::string|s and should be UTF-8 encoded. |
| 210 class BASE_EXPORT DictionaryValue : public Value { | 210 class BASE_EXPORT DictionaryValue : public Value { |
| 211 public: | 211 public: |
| 212 // Returns |value| if it is a dictionary, nullptr otherwise. |
| 213 static scoped_ptr<DictionaryValue> From(scoped_ptr<Value> value); |
| 214 |
| 212 DictionaryValue(); | 215 DictionaryValue(); |
| 213 ~DictionaryValue() override; | 216 ~DictionaryValue() override; |
| 214 | 217 |
| 215 // Overridden from Value: | 218 // Overridden from Value: |
| 216 bool GetAsDictionary(DictionaryValue** out_value) override; | 219 bool GetAsDictionary(DictionaryValue** out_value) override; |
| 217 bool GetAsDictionary(const DictionaryValue** out_value) const override; | 220 bool GetAsDictionary(const DictionaryValue** out_value) const override; |
| 218 | 221 |
| 219 // Returns true if the current dictionary has a value for the given key. | 222 // Returns true if the current dictionary has a value for the given key. |
| 220 bool HasKey(const std::string& key) const; | 223 bool HasKey(const std::string& key) const; |
| 221 | 224 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 383 |
| 381 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); | 384 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); |
| 382 }; | 385 }; |
| 383 | 386 |
| 384 // This type of Value represents a list of other Value values. | 387 // This type of Value represents a list of other Value values. |
| 385 class BASE_EXPORT ListValue : public Value { | 388 class BASE_EXPORT ListValue : public Value { |
| 386 public: | 389 public: |
| 387 typedef ValueVector::iterator iterator; | 390 typedef ValueVector::iterator iterator; |
| 388 typedef ValueVector::const_iterator const_iterator; | 391 typedef ValueVector::const_iterator const_iterator; |
| 389 | 392 |
| 393 // Returns |value| if it is a list, nullptr otherwise. |
| 394 static scoped_ptr<ListValue> From(scoped_ptr<Value> value); |
| 395 |
| 390 ListValue(); | 396 ListValue(); |
| 391 ~ListValue() override; | 397 ~ListValue() override; |
| 392 | 398 |
| 393 // Clears the contents of this ListValue | 399 // Clears the contents of this ListValue |
| 394 void Clear(); | 400 void Clear(); |
| 395 | 401 |
| 396 // Returns the number of Values in this list. | 402 // Returns the number of Values in this list. |
| 397 size_t GetSize() const { return list_.size(); } | 403 size_t GetSize() const { return list_.size(); } |
| 398 | 404 |
| 399 // Returns whether the list is empty. | 405 // Returns whether the list is empty. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 556 } |
| 551 | 557 |
| 552 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 558 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 553 const ListValue& value) { | 559 const ListValue& value) { |
| 554 return out << static_cast<const Value&>(value); | 560 return out << static_cast<const Value&>(value); |
| 555 } | 561 } |
| 556 | 562 |
| 557 } // namespace base | 563 } // namespace base |
| 558 | 564 |
| 559 #endif // BASE_VALUES_H_ | 565 #endif // BASE_VALUES_H_ |
| OLD | NEW |