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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 void MergeDictionary(const DictionaryValue* dictionary); | 341 void MergeDictionary(const DictionaryValue* dictionary); |
342 | 342 |
343 // Swaps contents with the |other| dictionary. | 343 // Swaps contents with the |other| dictionary. |
344 virtual void Swap(DictionaryValue* other); | 344 virtual void Swap(DictionaryValue* other); |
345 | 345 |
346 // This class provides an iterator over both keys and values in the | 346 // This class provides an iterator over both keys and values in the |
347 // dictionary. It can't be used to modify the dictionary. | 347 // dictionary. It can't be used to modify the dictionary. |
348 class BASE_EXPORT Iterator { | 348 class BASE_EXPORT Iterator { |
349 public: | 349 public: |
350 explicit Iterator(const DictionaryValue& target); | 350 explicit Iterator(const DictionaryValue& target); |
| 351 ~Iterator(); |
351 | 352 |
352 bool IsAtEnd() const { return it_ == target_.dictionary_.end(); } | 353 bool IsAtEnd() const { return it_ == target_.dictionary_.end(); } |
353 void Advance() { ++it_; } | 354 void Advance() { ++it_; } |
354 | 355 |
355 const std::string& key() const { return it_->first; } | 356 const std::string& key() const { return it_->first; } |
356 const Value& value() const { return *it_->second; } | 357 const Value& value() const { return *it_->second; } |
357 | 358 |
358 private: | 359 private: |
359 const DictionaryValue& target_; | 360 const DictionaryValue& target_; |
360 ValueMap::const_iterator it_; | 361 ValueMap::const_iterator it_; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 | 528 |
528 } // namespace base | 529 } // namespace base |
529 | 530 |
530 // http://crbug.com/88666 | 531 // http://crbug.com/88666 |
531 using base::DictionaryValue; | 532 using base::DictionaryValue; |
532 using base::ListValue; | 533 using base::ListValue; |
533 using base::StringValue; | 534 using base::StringValue; |
534 using base::Value; | 535 using base::Value; |
535 | 536 |
536 #endif // BASE_VALUES_H_ | 537 #endif // BASE_VALUES_H_ |
OLD | NEW |