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