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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 bool GetListWithoutPathExpansion(StringPiece key, | 320 bool GetListWithoutPathExpansion(StringPiece key, |
321 const ListValue** out_value) const; | 321 const ListValue** out_value) const; |
322 bool GetListWithoutPathExpansion(StringPiece key, ListValue** out_value); | 322 bool GetListWithoutPathExpansion(StringPiece key, ListValue** out_value); |
323 | 323 |
324 // Removes the Value with the specified path from this dictionary (or one | 324 // Removes the Value with the specified path from this dictionary (or one |
325 // of its child dictionaries, if the path is more than just a local key). | 325 // of its child dictionaries, if the path is more than just a local key). |
326 // If |out_value| is non-NULL, the removed Value will be passed out via | 326 // If |out_value| is non-NULL, the removed Value will be passed out via |
327 // |out_value|. If |out_value| is NULL, the removed value will be deleted. | 327 // |out_value|. If |out_value| is NULL, the removed value will be deleted. |
328 // This method returns true if |path| is a valid path; otherwise it will | 328 // This method returns true if |path| is a valid path; otherwise it will |
329 // return false and the DictionaryValue object will be unchanged. | 329 // return false and the DictionaryValue object will be unchanged. |
330 virtual bool Remove(StringPiece path, std::unique_ptr<Value>* out_value); | 330 bool Remove(StringPiece path, std::unique_ptr<Value>* out_value); |
331 | 331 |
332 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs | 332 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs |
333 // to be used as paths. | 333 // to be used as paths. |
334 virtual bool RemoveWithoutPathExpansion(StringPiece key, | 334 virtual bool RemoveWithoutPathExpansion(StringPiece key, |
335 std::unique_ptr<Value>* out_value); | 335 std::unique_ptr<Value>* out_value); |
336 | 336 |
337 // Removes a path, clearing out all dictionaries on |path| that remain empty | 337 // Removes a path, clearing out all dictionaries on |path| that remain empty |
338 // after removing the value at |path|. | 338 // after removing the value at |path|. |
339 virtual bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value); | 339 bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value); |
340 | 340 |
341 // Makes a copy of |this| but doesn't include empty dictionaries and lists in | 341 // Makes a copy of |this| but doesn't include empty dictionaries and lists in |
342 // the copy. This never returns NULL, even if |this| itself is empty. | 342 // the copy. This never returns NULL, even if |this| itself is empty. |
343 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const; | 343 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const; |
344 | 344 |
345 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any | 345 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any |
346 // sub-dictionaries will be merged as well. In case of key collisions, the | 346 // sub-dictionaries will be merged as well. In case of key collisions, the |
347 // passed in dictionary takes precedence and data already present will be | 347 // passed in dictionary takes precedence and data already present will be |
348 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may | 348 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may |
349 // be freed any time after this call. | 349 // be freed any time after this call. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 558 } |
559 | 559 |
560 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 560 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
561 const ListValue& value) { | 561 const ListValue& value) { |
562 return out << static_cast<const Value&>(value); | 562 return out << static_cast<const Value&>(value); |
563 } | 563 } |
564 | 564 |
565 } // namespace base | 565 } // namespace base |
566 | 566 |
567 #endif // BASE_VALUES_H_ | 567 #endif // BASE_VALUES_H_ |
OLD | NEW |