Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2336)

Side by Side Diff: base/values.h

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | base/values.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const DictionaryValue** out_value) const; 304 const DictionaryValue** out_value) const;
305 bool GetDictionaryWithoutPathExpansion(const std::string& key, 305 bool GetDictionaryWithoutPathExpansion(const std::string& key,
306 DictionaryValue** out_value); 306 DictionaryValue** out_value);
307 bool GetListWithoutPathExpansion(const std::string& key, 307 bool GetListWithoutPathExpansion(const std::string& key,
308 const ListValue** out_value) const; 308 const ListValue** out_value) const;
309 bool GetListWithoutPathExpansion(const std::string& key, 309 bool GetListWithoutPathExpansion(const std::string& key,
310 ListValue** out_value); 310 ListValue** out_value);
311 311
312 // Removes the Value with the specified path from this dictionary (or one 312 // Removes the Value with the specified path from this dictionary (or one
313 // of its child dictionaries, if the path is more than just a local key). 313 // of its child dictionaries, if the path is more than just a local key).
314 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be 314 // If |out_value| is non-NULL, the removed Value will be passed out via
315 // passed out via out_value. If |out_value| is NULL, the removed value will 315 // |out_value|. If |out_value| is NULL, the removed value will be deleted.
316 // be deleted. This method returns true if |path| is a valid path; otherwise 316 // This method returns true if |path| is a valid path; otherwise it will
317 // it will return false and the DictionaryValue object will be unchanged. 317 // return false and the DictionaryValue object will be unchanged.
318 virtual bool Remove(const std::string& path, Value** out_value); 318 virtual bool Remove(const std::string& path, scoped_ptr<Value>* out_value);
319 319
320 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs 320 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs
321 // to be used as paths. 321 // to be used as paths.
322 virtual bool RemoveWithoutPathExpansion(const std::string& key, 322 virtual bool RemoveWithoutPathExpansion(const std::string& key,
323 Value** out_value); 323 scoped_ptr<Value>* out_value);
324 324
325 // Makes a copy of |this| but doesn't include empty dictionaries and lists in 325 // Makes a copy of |this| but doesn't include empty dictionaries and lists in
326 // the copy. This never returns NULL, even if |this| itself is empty. 326 // the copy. This never returns NULL, even if |this| itself is empty.
327 DictionaryValue* DeepCopyWithoutEmptyChildren(); 327 DictionaryValue* DeepCopyWithoutEmptyChildren();
328 328
329 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any 329 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any
330 // sub-dictionaries will be merged as well. In case of key collisions, the 330 // sub-dictionaries will be merged as well. In case of key collisions, the
331 // passed in dictionary takes precedence and data already present will be 331 // passed in dictionary takes precedence and data already present will be
332 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may 332 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may
333 // be freed any time after this call. 333 // be freed any time after this call.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 bool GetDictionary(size_t index, const DictionaryValue** out_value) const; 407 bool GetDictionary(size_t index, const DictionaryValue** out_value) const;
408 bool GetDictionary(size_t index, DictionaryValue** out_value); 408 bool GetDictionary(size_t index, DictionaryValue** out_value);
409 bool GetList(size_t index, const ListValue** out_value) const; 409 bool GetList(size_t index, const ListValue** out_value) const;
410 bool GetList(size_t index, ListValue** out_value); 410 bool GetList(size_t index, ListValue** out_value);
411 411
412 // Removes the Value with the specified index from this list. 412 // Removes the Value with the specified index from this list.
413 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be 413 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be
414 // passed out via |out_value|. If |out_value| is NULL, the removed value will 414 // passed out via |out_value|. If |out_value| is NULL, the removed value will
415 // be deleted. This method returns true if |index| is valid; otherwise 415 // be deleted. This method returns true if |index| is valid; otherwise
416 // it will return false and the ListValue object will be unchanged. 416 // it will return false and the ListValue object will be unchanged.
417 virtual bool Remove(size_t index, Value** out_value); 417 virtual bool Remove(size_t index, scoped_ptr<Value>* out_value);
418 418
419 // Removes the first instance of |value| found in the list, if any, and 419 // Removes the first instance of |value| found in the list, if any, and
420 // deletes it. |index| is the location where |value| was found. Returns false 420 // deletes it. |index| is the location where |value| was found. Returns false
421 // if not found. 421 // if not found.
422 bool Remove(const Value& value, size_t* index); 422 bool Remove(const Value& value, size_t* index);
423 423
424 // Removes the element at |iter|. If |out_value| is NULL, the value will be 424 // Removes the element at |iter|. If |out_value| is NULL, the value will be
425 // deleted, otherwise ownership of the value is passed back to the caller. 425 // deleted, otherwise ownership of the value is passed back to the caller.
426 // Returns an iterator pointing to the location of the element that 426 // Returns an iterator pointing to the location of the element that
427 // followed the erased element. 427 // followed the erased element.
428 iterator Erase(iterator iter, Value** out_value); 428 iterator Erase(iterator iter, scoped_ptr<Value>* out_value);
429 429
430 // Appends a Value to the end of the list. 430 // Appends a Value to the end of the list.
431 void Append(Value* in_value); 431 void Append(Value* in_value);
432 432
433 // Convenience forms of Append. 433 // Convenience forms of Append.
434 void AppendBoolean(bool in_value); 434 void AppendBoolean(bool in_value);
435 void AppendInteger(int in_value); 435 void AppendInteger(int in_value);
436 void AppendDouble(double in_value); 436 void AppendDouble(double in_value);
437 void AppendString(const std::string& in_value); 437 void AppendString(const std::string& in_value);
438 void AppendString(const string16& in_value); 438 void AppendString(const string16& in_value);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 } // namespace base 521 } // namespace base
522 522
523 // http://crbug.com/88666 523 // http://crbug.com/88666
524 using base::DictionaryValue; 524 using base::DictionaryValue;
525 using base::ListValue; 525 using base::ListValue;
526 using base::StringValue; 526 using base::StringValue;
527 using base::Value; 527 using base::Value;
528 528
529 #endif // BASE_VALUES_H_ 529 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698