| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 setting and other persistable data. It includes the ability to | 6 // storing setting and other persistable data. It includes the ability to |
| 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. | 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. |
| 8 // However, the API is optimized for the common case, namely storing a | 8 // However, the API is optimized for the common case, namely storing a |
| 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can | 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can |
| 10 // easily do things like: | 10 // easily do things like: |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 // DictionaryValue provides a key-value dictionary with (optional) "path" | 212 // DictionaryValue provides a key-value dictionary with (optional) "path" |
| 213 // parsing for recursive access; see the comment at the top of the file. Keys | 213 // parsing for recursive access; see the comment at the top of the file. Keys |
| 214 // are |std::string|s and should be UTF-8 encoded. | 214 // are |std::string|s and should be UTF-8 encoded. |
| 215 class BASE_EXPORT DictionaryValue : public Value { | 215 class BASE_EXPORT DictionaryValue : public Value { |
| 216 public: | 216 public: |
| 217 DictionaryValue(); | 217 DictionaryValue(); |
| 218 virtual ~DictionaryValue(); | 218 virtual ~DictionaryValue(); |
| 219 | 219 |
| 220 // Overridden from Value: | |
| 221 virtual bool GetAsDictionary(DictionaryValue** out_value) OVERRIDE; | |
| 222 virtual bool GetAsDictionary( | |
| 223 const DictionaryValue** out_value) const OVERRIDE; | |
| 224 | |
| 225 // Returns true if the current dictionary has a value for the given key. | 220 // Returns true if the current dictionary has a value for the given key. |
| 226 bool HasKey(const std::string& key) const; | 221 bool HasKey(const std::string& key) const; |
| 227 | 222 |
| 228 // Returns the number of Values in this dictionary. | 223 // Returns the number of Values in this dictionary. |
| 229 size_t size() const { return dictionary_.size(); } | 224 size_t size() const { return dictionary_.size(); } |
| 230 | 225 |
| 231 // Returns whether the dictionary is empty. | 226 // Returns whether the dictionary is empty. |
| 232 bool empty() const { return dictionary_.empty(); } | 227 bool empty() const { return dictionary_.empty(); } |
| 233 | 228 |
| 234 // Clears any current contents of this dictionary. | 229 // Clears any current contents of this dictionary. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 356 |
| 362 const std::string& key() const { return it_->first; } | 357 const std::string& key() const { return it_->first; } |
| 363 const Value& value() const { return *it_->second; } | 358 const Value& value() const { return *it_->second; } |
| 364 | 359 |
| 365 private: | 360 private: |
| 366 const DictionaryValue& target_; | 361 const DictionaryValue& target_; |
| 367 ValueMap::const_iterator it_; | 362 ValueMap::const_iterator it_; |
| 368 }; | 363 }; |
| 369 | 364 |
| 370 // Overridden from Value: | 365 // Overridden from Value: |
| 366 virtual bool GetAsDictionary(DictionaryValue** out_value) OVERRIDE; |
| 367 virtual bool GetAsDictionary(const DictionaryValue** out_value) |
| 368 const OVERRIDE; |
| 371 virtual DictionaryValue* DeepCopy() const OVERRIDE; | 369 virtual DictionaryValue* DeepCopy() const OVERRIDE; |
| 372 virtual bool Equals(const Value* other) const OVERRIDE; | 370 virtual bool Equals(const Value* other) const OVERRIDE; |
| 373 | 371 |
| 374 private: | 372 private: |
| 375 ValueMap dictionary_; | 373 ValueMap dictionary_; |
| 376 | 374 |
| 377 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); | 375 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); |
| 378 }; | 376 }; |
| 379 | 377 |
| 380 // This type of Value represents a list of other Value values. | 378 // This type of Value represents a list of other Value values. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 489 |
| 492 } // namespace base | 490 } // namespace base |
| 493 | 491 |
| 494 // http://crbug.com/88666 | 492 // http://crbug.com/88666 |
| 495 using base::DictionaryValue; | 493 using base::DictionaryValue; |
| 496 using base::ListValue; | 494 using base::ListValue; |
| 497 using base::StringValue; | 495 using base::StringValue; |
| 498 using base::Value; | 496 using base::Value; |
| 499 | 497 |
| 500 #endif // BASE_VALUES_H_ | 498 #endif // BASE_VALUES_H_ |
| OLD | NEW |