OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 // This file specifies a recursive data storage class called Value |
6 // intended for storing setting and other persistable data. | 6 // intended for storing setting and other persistable data. |
7 // It includes the ability to specify (recursive) lists and dictionaries, so | 7 // It includes the ability to specify (recursive) lists and dictionaries, so |
8 // it's fairly expressive. However, the API is optimized for the common case, | 8 // it's fairly expressive. However, the API is optimized for the common case, |
9 // namely storing a hierarchical tree of simple values. Given a | 9 // namely storing a hierarchical tree of simple values. Given a |
10 // DictionaryValue root, you can easily do things like: | 10 // DictionaryValue root, you can easily do things like: |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 bool Remove(const std::wstring& path, Value** out_value); | 305 bool Remove(const std::wstring& path, Value** out_value); |
306 | 306 |
307 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs | 307 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs |
308 // to be used as paths. | 308 // to be used as paths. |
309 bool RemoveWithoutPathExpansion(const std::wstring& key, Value** out_value); | 309 bool RemoveWithoutPathExpansion(const std::wstring& key, Value** out_value); |
310 | 310 |
311 // Makes a copy of |this| but doesn't include empty dictionaries and lists in | 311 // Makes a copy of |this| but doesn't include empty dictionaries and lists in |
312 // the copy. This never returns NULL, even if |this| itself is empty. | 312 // the copy. This never returns NULL, even if |this| itself is empty. |
313 DictionaryValue* DeepCopyWithoutEmptyChildren(); | 313 DictionaryValue* DeepCopyWithoutEmptyChildren(); |
314 | 314 |
| 315 // Merge a given dictionary into this dictionary. This is done recursively, |
| 316 // i.e. any subdictionaries will be merged as well. In case of key collisions, |
| 317 // the passed in dictionary takes precedence and data already present will be |
| 318 // replaced. |
| 319 void MergeDictionary(const DictionaryValue* dictionary); |
| 320 |
315 // This class provides an iterator for the keys in the dictionary. | 321 // This class provides an iterator for the keys in the dictionary. |
316 // It can't be used to modify the dictionary. | 322 // It can't be used to modify the dictionary. |
317 // | 323 // |
318 // YOU SHOULD ALWAYS USE THE XXXWithoutPathExpansion() APIs WITH THESE, NOT | 324 // YOU SHOULD ALWAYS USE THE XXXWithoutPathExpansion() APIs WITH THESE, NOT |
319 // THE NORMAL XXX() APIs. This makes sure things will work correctly if any | 325 // THE NORMAL XXX() APIs. This makes sure things will work correctly if any |
320 // keys have '.'s in them. | 326 // keys have '.'s in them. |
321 class key_iterator | 327 class key_iterator |
322 : private std::iterator<std::input_iterator_tag, const std::wstring> { | 328 : private std::iterator<std::input_iterator_tag, const std::wstring> { |
323 public: | 329 public: |
324 explicit key_iterator(ValueMap::const_iterator itr) { itr_ = itr; } | 330 explicit key_iterator(ValueMap::const_iterator itr) { itr_ = itr; } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // This method deserializes the subclass-specific format into a Value object. | 442 // This method deserializes the subclass-specific format into a Value object. |
437 // If the return value is non-NULL, the caller takes ownership of returned | 443 // If the return value is non-NULL, the caller takes ownership of returned |
438 // Value. If the return value is NULL, and if error_code is non-NULL, | 444 // Value. If the return value is NULL, and if error_code is non-NULL, |
439 // error_code will be set with the underlying error. | 445 // error_code will be set with the underlying error. |
440 // If |error_message| is non-null, it will be filled in with a formatted | 446 // If |error_message| is non-null, it will be filled in with a formatted |
441 // error message including the location of the error if appropriate. | 447 // error message including the location of the error if appropriate. |
442 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 448 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
443 }; | 449 }; |
444 | 450 |
445 #endif // BASE_VALUES_H_ | 451 #endif // BASE_VALUES_H_ |
OLD | NEW |