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

Side by Side Diff: base/values.h

Issue 2740373002: Cleaning up base::Value assignment. (Closed)
Patch Set: Always destroy in move. Created 3 years, 9 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 | « no previous file | base/values.cc » ('j') | base/values.cc » ('J')
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC. 184 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC.
185 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_; 185 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_;
186 ManualConstructor<ListStorage> list_; 186 ManualConstructor<ListStorage> list_;
187 }; 187 };
188 188
189 private: 189 private:
190 void InternalCopyFundamentalValue(const Value& that); 190 void InternalCopyFundamentalValue(const Value& that);
191 void InternalCopyConstructFrom(const Value& that); 191 void InternalCopyConstructFrom(const Value& that);
192 void InternalMoveConstructFrom(Value&& that); 192 void InternalMoveConstructFrom(Value&& that);
193 void InternalCopyAssignFromSameType(const Value& that); 193 void InternalCopyAssignFromSameType(const Value& that);
194 void InternalMoveAssignFromSameType(Value&& that);
195 void InternalCleanup(); 194 void InternalCleanup();
196 }; 195 };
197 196
198 // DictionaryValue provides a key-value dictionary with (optional) "path" 197 // DictionaryValue provides a key-value dictionary with (optional) "path"
199 // parsing for recursive access; see the comment at the top of the file. Keys 198 // parsing for recursive access; see the comment at the top of the file. Keys
200 // are |std::string|s and should be UTF-8 encoded. 199 // are |std::string|s and should be UTF-8 encoded.
201 class BASE_EXPORT DictionaryValue : public Value { 200 class BASE_EXPORT DictionaryValue : public Value {
202 public: 201 public:
203 // Returns |value| if it is a dictionary, nullptr otherwise. 202 // Returns |value| if it is a dictionary, nullptr otherwise.
204 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value); 203 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 return out << static_cast<const Value&>(value); 513 return out << static_cast<const Value&>(value);
515 } 514 }
516 515
517 // Stream operator so that enum class Types can be used in log statements. 516 // Stream operator so that enum class Types can be used in log statements.
518 BASE_EXPORT std::ostream& operator<<(std::ostream& out, 517 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
519 const Value::Type& type); 518 const Value::Type& type);
520 519
521 } // namespace base 520 } // namespace base
522 521
523 #endif // BASE_VALUES_H_ 522 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | base/values.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698