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

Side by Side Diff: base/values.h

Issue 1129083003: More base::Values-related bare pointer -> scoped_ptr conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad merge Created 5 years, 7 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
« no previous file with comments | « base/test/values_test_util.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 TYPE_DOUBLE, 57 TYPE_DOUBLE,
58 TYPE_STRING, 58 TYPE_STRING,
59 TYPE_BINARY, 59 TYPE_BINARY,
60 TYPE_DICTIONARY, 60 TYPE_DICTIONARY,
61 TYPE_LIST 61 TYPE_LIST
62 // Note: Do not add more types. See the file-level comment above for why. 62 // Note: Do not add more types. See the file-level comment above for why.
63 }; 63 };
64 64
65 virtual ~Value(); 65 virtual ~Value();
66 66
67 static Value* CreateNullValue(); 67 static scoped_ptr<Value> CreateNullValue();
68 68
69 // Returns the type of the value stored by the current Value object. 69 // Returns the type of the value stored by the current Value object.
70 // Each type will be implemented by only one subclass of Value, so it's 70 // Each type will be implemented by only one subclass of Value, so it's
71 // safe to use the Type to determine whether you can cast from 71 // safe to use the Type to determine whether you can cast from
72 // Value* to (Implementing Class)*. Also, a Value object never changes 72 // Value* to (Implementing Class)*. Also, a Value object never changes
73 // its type after construction. 73 // its type after construction.
74 Type GetType() const { return type_; } 74 Type GetType() const { return type_; }
75 75
76 // Returns true if the current object represents a given type. 76 // Returns true if the current object represents a given type.
77 bool IsType(Type type) const { return type == type_; } 77 bool IsType(Type type) const { return type == type_; }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 487
488 const_iterator begin() const { return list_.begin(); } 488 const_iterator begin() const { return list_.begin(); }
489 const_iterator end() const { return list_.end(); } 489 const_iterator end() const { return list_.end(); }
490 490
491 // Overridden from Value: 491 // Overridden from Value:
492 bool GetAsList(ListValue** out_value) override; 492 bool GetAsList(ListValue** out_value) override;
493 bool GetAsList(const ListValue** out_value) const override; 493 bool GetAsList(const ListValue** out_value) const override;
494 ListValue* DeepCopy() const override; 494 ListValue* DeepCopy() const override;
495 bool Equals(const Value* other) const override; 495 bool Equals(const Value* other) const override;
496 496
497 // Preferred version of DeepCopy. TODO(estade): remove DeepCopy.
498 scoped_ptr<ListValue> CreateDeepCopy() const;
499
497 private: 500 private:
498 ValueVector list_; 501 ValueVector list_;
499 502
500 DISALLOW_COPY_AND_ASSIGN(ListValue); 503 DISALLOW_COPY_AND_ASSIGN(ListValue);
501 }; 504 };
502 505
503 // This interface is implemented by classes that know how to serialize 506 // This interface is implemented by classes that know how to serialize
504 // Value objects. 507 // Value objects.
505 class BASE_EXPORT ValueSerializer { 508 class BASE_EXPORT ValueSerializer {
506 public: 509 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 549 }
547 550
548 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, 551 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out,
549 const ListValue& value) { 552 const ListValue& value) {
550 return out << static_cast<const Value&>(value); 553 return out << static_cast<const Value&>(value);
551 } 554 }
552 555
553 } // namespace base 556 } // namespace base
554 557
555 #endif // BASE_VALUES_H_ 558 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « base/test/values_test_util.cc ('k') | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698