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

Side by Side Diff: base/values.h

Issue 2683203004: Move Storage for ListValue and DictValue in Union (Closed)
Patch Set: Rebase Created 3 years, 10 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 using StringValue = Value; 43 using StringValue = Value;
44 using BinaryValue = Value; 44 using BinaryValue = Value;
45 45
46 // The Value class is the base class for Values. A Value can be instantiated 46 // The Value class is the base class for Values. A Value can be instantiated
47 // via the Create*Value() factory methods, or by directly creating instances of 47 // via the Create*Value() factory methods, or by directly creating instances of
48 // the subclasses. 48 // the subclasses.
49 // 49 //
50 // See the file-level comment above for more information. 50 // See the file-level comment above for more information.
51 class BASE_EXPORT Value { 51 class BASE_EXPORT Value {
52 public: 52 public:
53 using DictStorage = std::map<std::string, std::unique_ptr<Value>>;
54 using ListStorage = std::vector<std::unique_ptr<Value>>;
55
53 enum class Type { 56 enum class Type {
54 NONE = 0, 57 NONE = 0,
55 BOOLEAN, 58 BOOLEAN,
56 INTEGER, 59 INTEGER,
57 DOUBLE, 60 DOUBLE,
58 STRING, 61 STRING,
59 BINARY, 62 BINARY,
60 DICTIONARY, 63 DICTIONARY,
61 LIST 64 LIST
62 // Note: Do not add more types. See the file-level comment above for why. 65 // Note: Do not add more types. See the file-level comment above for why.
(...skipping 29 matching lines...) Expand all
92 explicit Value(const char16* in_string); 95 explicit Value(const char16* in_string);
93 explicit Value(const string16& in_string); 96 explicit Value(const string16& in_string);
94 explicit Value(StringPiece in_string); 97 explicit Value(StringPiece in_string);
95 98
96 explicit Value(const std::vector<char>& in_blob); 99 explicit Value(const std::vector<char>& in_blob);
97 explicit Value(std::vector<char>&& in_blob); 100 explicit Value(std::vector<char>&& in_blob);
98 101
99 Value& operator=(const Value& that); 102 Value& operator=(const Value& that);
100 Value& operator=(Value&& that); 103 Value& operator=(Value&& that);
101 104
102 virtual ~Value(); 105 ~Value();
103 106
104 // Returns the name for a given |type|. 107 // Returns the name for a given |type|.
105 static const char* GetTypeName(Type type); 108 static const char* GetTypeName(Type type);
106 109
107 // Returns the type of the value stored by the current Value object. 110 // Returns the type of the value stored by the current Value object.
108 // Each type will be implemented by only one subclass of Value, so it's 111 // Each type will be implemented by only one subclass of Value, so it's
109 // safe to use the Type to determine whether you can cast from 112 // safe to use the Type to determine whether you can cast from
110 // Value* to (Implementing Class)*. Also, a Value object never changes 113 // Value* to (Implementing Class)*. Also, a Value object never changes
111 // its type after construction. 114 // its type after construction.
112 Type GetType() const { return type_; } // DEPRECATED, use type(). 115 Type GetType() const { return type_; } // DEPRECATED, use type().
(...skipping 16 matching lines...) Expand all
129 const std::string& GetString() const; 132 const std::string& GetString() const;
130 const std::vector<char>& GetBlob() const; 133 const std::vector<char>& GetBlob() const;
131 134
132 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. 135 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead.
133 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. 136 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead.
134 137
135 // These methods allow the convenient retrieval of the contents of the Value. 138 // These methods allow the convenient retrieval of the contents of the Value.
136 // If the current object can be converted into the given type, the value is 139 // If the current object can be converted into the given type, the value is
137 // returned through the |out_value| parameter and true is returned; 140 // returned through the |out_value| parameter and true is returned;
138 // otherwise, false is returned and |out_value| is unchanged. 141 // otherwise, false is returned and |out_value| is unchanged.
139 virtual bool GetAsBoolean(bool* out_value) const; 142 bool GetAsBoolean(bool* out_value) const;
140 virtual bool GetAsInteger(int* out_value) const; 143 bool GetAsInteger(int* out_value) const;
141 virtual bool GetAsDouble(double* out_value) const; 144 bool GetAsDouble(double* out_value) const;
142 virtual bool GetAsString(std::string* out_value) const; 145 bool GetAsString(std::string* out_value) const;
143 virtual bool GetAsString(string16* out_value) const; 146 bool GetAsString(string16* out_value) const;
144 virtual bool GetAsString(const StringValue** out_value) const; 147 bool GetAsString(const StringValue** out_value) const;
145 virtual bool GetAsString(StringPiece* out_value) const; 148 bool GetAsString(StringPiece* out_value) const;
146 virtual bool GetAsBinary(const BinaryValue** out_value) const; 149 bool GetAsBinary(const BinaryValue** out_value) const;
147 // ListValue::From is the equivalent for std::unique_ptr conversions. 150 // ListValue::From is the equivalent for std::unique_ptr conversions.
148 virtual bool GetAsList(ListValue** out_value); 151 bool GetAsList(ListValue** out_value);
149 virtual bool GetAsList(const ListValue** out_value) const; 152 bool GetAsList(const ListValue** out_value) const;
150 // DictionaryValue::From is the equivalent for std::unique_ptr conversions. 153 // DictionaryValue::From is the equivalent for std::unique_ptr conversions.
151 virtual bool GetAsDictionary(DictionaryValue** out_value); 154 bool GetAsDictionary(DictionaryValue** out_value);
152 virtual bool GetAsDictionary(const DictionaryValue** out_value) const; 155 bool GetAsDictionary(const DictionaryValue** out_value) const;
153 // Note: Do not add more types. See the file-level comment above for why. 156 // Note: Do not add more types. See the file-level comment above for why.
154 157
155 // This creates a deep copy of the entire Value tree, and returns a pointer 158 // This creates a deep copy of the entire Value tree, and returns a pointer
156 // to the copy. The caller gets ownership of the copy, of course. 159 // to the copy. The caller gets ownership of the copy, of course.
157 // Subclasses return their own type directly in their overrides; 160 // Subclasses return their own type directly in their overrides;
158 // this works because C++ supports covariant return types. 161 // this works because C++ supports covariant return types.
159 virtual Value* DeepCopy() const; 162 Value* DeepCopy() const;
160 // Preferred version of DeepCopy. TODO(estade): remove the above. 163 // Preferred version of DeepCopy. TODO(estade): remove the above.
161 std::unique_ptr<Value> CreateDeepCopy() const; 164 std::unique_ptr<Value> CreateDeepCopy() const;
162 165
163 // Compares if two Value objects have equal contents. 166 // Compares if two Value objects have equal contents.
164 virtual bool Equals(const Value* other) const; 167 bool Equals(const Value* other) const;
165 168
166 // Compares if two Value objects have equal contents. Can handle NULLs. 169 // Compares if two Value objects have equal contents. Can handle NULLs.
167 // NULLs are considered equal but different from Value::CreateNullValue(). 170 // NULLs are considered equal but different from Value::CreateNullValue().
168 static bool Equals(const Value* a, const Value* b); 171 static bool Equals(const Value* a, const Value* b);
169 172
170 private: 173 protected:
171 void InternalCopyFundamentalValue(const Value& that); 174 // TODO(crbug.com/646113): Make these private once DictionaryValue and
172 void InternalCopyConstructFrom(const Value& that); 175 // ListValue are properly inlined.
173 void InternalMoveConstructFrom(Value&& that);
174 void InternalCopyAssignFrom(const Value& that);
175 void InternalMoveAssignFrom(Value&& that);
176 void InternalCleanup();
177
178 Type type_; 176 Type type_;
179 177
180 union { 178 union {
181 bool bool_value_; 179 bool bool_value_;
182 int int_value_; 180 int int_value_;
183 double double_value_; 181 double double_value_;
184 ManualConstructor<std::string> string_value_; 182 ManualConstructor<std::string> string_value_;
185 ManualConstructor<std::vector<char>> binary_value_; 183 ManualConstructor<std::vector<char>> binary_value_;
184 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_;
brettw 2017/02/14 23:15:05 Can you add a comment here about why this one is h
jdoerrie 2017/02/15 15:29:08 Done.
185 ManualConstructor<ListStorage> list_;
186 }; 186 };
187
188 private:
189 void InternalCopyFundamentalValue(const Value& that);
190 void InternalCopyConstructFrom(const Value& that);
191 void InternalMoveConstructFrom(Value&& that);
192 void InternalCopyAssignFrom(const Value& that);
193 void InternalMoveAssignFrom(Value&& that);
194 void InternalCleanup();
187 }; 195 };
188 196
189 // DictionaryValue provides a key-value dictionary with (optional) "path" 197 // DictionaryValue provides a key-value dictionary with (optional) "path"
190 // 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
191 // are |std::string|s and should be UTF-8 encoded. 199 // are |std::string|s and should be UTF-8 encoded.
192 class BASE_EXPORT DictionaryValue : public Value { 200 class BASE_EXPORT DictionaryValue : public Value {
193 public: 201 public:
194 using Storage = std::map<std::string, std::unique_ptr<Value>>;
195 // Returns |value| if it is a dictionary, nullptr otherwise. 202 // Returns |value| if it is a dictionary, nullptr otherwise.
196 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value); 203 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value);
197 204
198 DictionaryValue(); 205 DictionaryValue();
199 ~DictionaryValue() override; 206 DictionaryValue(DictionaryValue&& that);
200 207 DictionaryValue& operator=(DictionaryValue&& that);
201 // Overridden from Value: 208 ~DictionaryValue();
202 bool GetAsDictionary(DictionaryValue** out_value) override;
203 bool GetAsDictionary(const DictionaryValue** out_value) const override;
204 209
205 // Returns true if the current dictionary has a value for the given key. 210 // Returns true if the current dictionary has a value for the given key.
206 bool HasKey(StringPiece key) const; 211 bool HasKey(StringPiece key) const;
207 212
208 // Returns the number of Values in this dictionary. 213 // Returns the number of Values in this dictionary.
209 size_t size() const { return dictionary_.size(); } 214 size_t size() const { return (*dict_ptr_)->size(); }
210 215
211 // Returns whether the dictionary is empty. 216 // Returns whether the dictionary is empty.
212 bool empty() const { return dictionary_.empty(); } 217 bool empty() const { return (*dict_ptr_)->empty(); }
213 218
214 // Clears any current contents of this dictionary. 219 // Clears any current contents of this dictionary.
215 void Clear(); 220 void Clear();
216 221
217 // Sets the Value associated with the given path starting from this object. 222 // Sets the Value associated with the given path starting from this object.
218 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes 223 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes
219 // into the next DictionaryValue down. Obviously, "." can't be used 224 // into the next DictionaryValue down. Obviously, "." can't be used
220 // within a key, but there are no other restrictions on keys. 225 // within a key, but there are no other restrictions on keys.
221 // If the key at any step of the way doesn't exist, or exists but isn't 226 // If the key at any step of the way doesn't exist, or exists but isn't
222 // a DictionaryValue, a new DictionaryValue will be created and attached 227 // a DictionaryValue, a new DictionaryValue will be created and attached
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // Removes the Value with the specified path from this dictionary (or one 307 // Removes the Value with the specified path from this dictionary (or one
303 // of its child dictionaries, if the path is more than just a local key). 308 // of its child dictionaries, if the path is more than just a local key).
304 // If |out_value| is non-NULL, the removed Value will be passed out via 309 // If |out_value| is non-NULL, the removed Value will be passed out via
305 // |out_value|. If |out_value| is NULL, the removed value will be deleted. 310 // |out_value|. If |out_value| is NULL, the removed value will be deleted.
306 // This method returns true if |path| is a valid path; otherwise it will 311 // This method returns true if |path| is a valid path; otherwise it will
307 // return false and the DictionaryValue object will be unchanged. 312 // return false and the DictionaryValue object will be unchanged.
308 bool Remove(StringPiece path, std::unique_ptr<Value>* out_value); 313 bool Remove(StringPiece path, std::unique_ptr<Value>* out_value);
309 314
310 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs 315 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs
311 // to be used as paths. 316 // to be used as paths.
312 virtual bool RemoveWithoutPathExpansion(StringPiece key, 317 bool RemoveWithoutPathExpansion(StringPiece key,
313 std::unique_ptr<Value>* out_value); 318 std::unique_ptr<Value>* out_value);
314 319
315 // Removes a path, clearing out all dictionaries on |path| that remain empty 320 // Removes a path, clearing out all dictionaries on |path| that remain empty
316 // after removing the value at |path|. 321 // after removing the value at |path|.
317 bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value); 322 bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value);
318 323
319 // Makes a copy of |this| but doesn't include empty dictionaries and lists in 324 // Makes a copy of |this| but doesn't include empty dictionaries and lists in
320 // the copy. This never returns NULL, even if |this| itself is empty. 325 // the copy. This never returns NULL, even if |this| itself is empty.
321 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const; 326 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
322 327
323 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any 328 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any
324 // sub-dictionaries will be merged as well. In case of key collisions, the 329 // sub-dictionaries will be merged as well. In case of key collisions, the
325 // passed in dictionary takes precedence and data already present will be 330 // passed in dictionary takes precedence and data already present will be
326 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may 331 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may
327 // be freed any time after this call. 332 // be freed any time after this call.
328 void MergeDictionary(const DictionaryValue* dictionary); 333 void MergeDictionary(const DictionaryValue* dictionary);
329 334
330 // Swaps contents with the |other| dictionary. 335 // Swaps contents with the |other| dictionary.
331 virtual void Swap(DictionaryValue* other); 336 void Swap(DictionaryValue* other);
332 337
333 // This class provides an iterator over both keys and values in the 338 // This class provides an iterator over both keys and values in the
334 // dictionary. It can't be used to modify the dictionary. 339 // dictionary. It can't be used to modify the dictionary.
335 class BASE_EXPORT Iterator { 340 class BASE_EXPORT Iterator {
336 public: 341 public:
337 explicit Iterator(const DictionaryValue& target); 342 explicit Iterator(const DictionaryValue& target);
338 Iterator(const Iterator& other); 343 Iterator(const Iterator& other);
339 ~Iterator(); 344 ~Iterator();
340 345
341 bool IsAtEnd() const { return it_ == target_.dictionary_.end(); } 346 bool IsAtEnd() const { return it_ == (*target_.dict_ptr_)->end(); }
342 void Advance() { ++it_; } 347 void Advance() { ++it_; }
343 348
344 const std::string& key() const { return it_->first; } 349 const std::string& key() const { return it_->first; }
345 const Value& value() const { return *it_->second; } 350 const Value& value() const { return *it_->second; }
346 351
347 private: 352 private:
348 const DictionaryValue& target_; 353 const DictionaryValue& target_;
349 Storage::const_iterator it_; 354 DictStorage::const_iterator it_;
350 }; 355 };
351 356
352 // Overridden from Value: 357 DictionaryValue* DeepCopy() const;
353 DictionaryValue* DeepCopy() const override;
354 // Preferred version of DeepCopy. TODO(estade): remove the above. 358 // Preferred version of DeepCopy. TODO(estade): remove the above.
355 std::unique_ptr<DictionaryValue> CreateDeepCopy() const; 359 std::unique_ptr<DictionaryValue> CreateDeepCopy() const;
356 bool Equals(const Value* other) const override;
357 360
358 private: 361 private:
359 Storage dictionary_;
360
361 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); 362 DISALLOW_COPY_AND_ASSIGN(DictionaryValue);
362 }; 363 };
363 364
364 // This type of Value represents a list of other Value values. 365 // This type of Value represents a list of other Value values.
365 class BASE_EXPORT ListValue : public Value { 366 class BASE_EXPORT ListValue : public Value {
366 public: 367 public:
367 using Storage = std::vector<std::unique_ptr<Value>>; 368 using const_iterator = ListStorage::const_iterator;
368 using const_iterator = Storage::const_iterator; 369 using iterator = ListStorage::iterator;
369 using iterator = Storage::iterator;
370 370
371 // Returns |value| if it is a list, nullptr otherwise. 371 // Returns |value| if it is a list, nullptr otherwise.
372 static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value); 372 static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value);
373 373
374 ListValue(); 374 ListValue();
375 ~ListValue() override; 375 ListValue(ListValue&& that);
376 ListValue& operator=(ListValue&& that);
377 ~ListValue();
376 378
377 // Clears the contents of this ListValue 379 // Clears the contents of this ListValue
378 void Clear(); 380 void Clear();
379 381
380 // Returns the number of Values in this list. 382 // Returns the number of Values in this list.
381 size_t GetSize() const { return list_.size(); } 383 size_t GetSize() const { return list_->size(); }
382 384
383 // Returns whether the list is empty. 385 // Returns whether the list is empty.
384 bool empty() const { return list_.empty(); } 386 bool empty() const { return list_->empty(); }
385 387
386 // Sets the list item at the given index to be the Value specified by 388 // Sets the list item at the given index to be the Value specified by
387 // the value given. If the index beyond the current end of the list, null 389 // the value given. If the index beyond the current end of the list, null
388 // Values will be used to pad out the list. 390 // Values will be used to pad out the list.
389 // Returns true if successful, or false if the index was negative or 391 // Returns true if successful, or false if the index was negative or
390 // the value is a null pointer. 392 // the value is a null pointer.
391 bool Set(size_t index, Value* in_value); 393 bool Set(size_t index, Value* in_value);
392 // Preferred version of the above. TODO(estade): remove the above. 394 // Preferred version of the above. TODO(estade): remove the above.
393 bool Set(size_t index, std::unique_ptr<Value> in_value); 395 bool Set(size_t index, std::unique_ptr<Value> in_value);
394 396
(...skipping 20 matching lines...) Expand all
415 bool GetDictionary(size_t index, const DictionaryValue** out_value) const; 417 bool GetDictionary(size_t index, const DictionaryValue** out_value) const;
416 bool GetDictionary(size_t index, DictionaryValue** out_value); 418 bool GetDictionary(size_t index, DictionaryValue** out_value);
417 bool GetList(size_t index, const ListValue** out_value) const; 419 bool GetList(size_t index, const ListValue** out_value) const;
418 bool GetList(size_t index, ListValue** out_value); 420 bool GetList(size_t index, ListValue** out_value);
419 421
420 // Removes the Value with the specified index from this list. 422 // Removes the Value with the specified index from this list.
421 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be 423 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be
422 // passed out via |out_value|. If |out_value| is NULL, the removed value will 424 // passed out via |out_value|. If |out_value| is NULL, the removed value will
423 // be deleted. This method returns true if |index| is valid; otherwise 425 // be deleted. This method returns true if |index| is valid; otherwise
424 // it will return false and the ListValue object will be unchanged. 426 // it will return false and the ListValue object will be unchanged.
425 virtual bool Remove(size_t index, std::unique_ptr<Value>* out_value); 427 bool Remove(size_t index, std::unique_ptr<Value>* out_value);
426 428
427 // Removes the first instance of |value| found in the list, if any, and 429 // Removes the first instance of |value| found in the list, if any, and
428 // deletes it. |index| is the location where |value| was found. Returns false 430 // deletes it. |index| is the location where |value| was found. Returns false
429 // if not found. 431 // if not found.
430 bool Remove(const Value& value, size_t* index); 432 bool Remove(const Value& value, size_t* index);
431 433
432 // Removes the element at |iter|. If |out_value| is NULL, the value will be 434 // Removes the element at |iter|. If |out_value| is NULL, the value will be
433 // deleted, otherwise ownership of the value is passed back to the caller. 435 // deleted, otherwise ownership of the value is passed back to the caller.
434 // Returns an iterator pointing to the location of the element that 436 // Returns an iterator pointing to the location of the element that
435 // followed the erased element. 437 // followed the erased element.
(...skipping 22 matching lines...) Expand all
458 // Insert a Value at index. 460 // Insert a Value at index.
459 // Returns true if successful, or false if the index was out of range. 461 // Returns true if successful, or false if the index was out of range.
460 bool Insert(size_t index, std::unique_ptr<Value> in_value); 462 bool Insert(size_t index, std::unique_ptr<Value> in_value);
461 463
462 // Searches for the first instance of |value| in the list using the Equals 464 // Searches for the first instance of |value| in the list using the Equals
463 // method of the Value type. 465 // method of the Value type.
464 // Returns a const_iterator to the found item or to end() if none exists. 466 // Returns a const_iterator to the found item or to end() if none exists.
465 const_iterator Find(const Value& value) const; 467 const_iterator Find(const Value& value) const;
466 468
467 // Swaps contents with the |other| list. 469 // Swaps contents with the |other| list.
468 virtual void Swap(ListValue* other); 470 void Swap(ListValue* other);
469 471
470 // Iteration. 472 // Iteration.
471 iterator begin() { return list_.begin(); } 473 iterator begin() { return list_->begin(); }
472 iterator end() { return list_.end(); } 474 iterator end() { return list_->end(); }
473 475
474 const_iterator begin() const { return list_.begin(); } 476 const_iterator begin() const { return list_->begin(); }
475 const_iterator end() const { return list_.end(); } 477 const_iterator end() const { return list_->end(); }
476 478
477 // Overridden from Value: 479 ListValue* DeepCopy() const;
478 bool GetAsList(ListValue** out_value) override;
479 bool GetAsList(const ListValue** out_value) const override;
480 ListValue* DeepCopy() const override;
481 bool Equals(const Value* other) const override;
482
483 // Preferred version of DeepCopy. TODO(estade): remove DeepCopy. 480 // Preferred version of DeepCopy. TODO(estade): remove DeepCopy.
484 std::unique_ptr<ListValue> CreateDeepCopy() const; 481 std::unique_ptr<ListValue> CreateDeepCopy() const;
485 482
486 private: 483 private:
487 Storage list_;
488
489 DISALLOW_COPY_AND_ASSIGN(ListValue); 484 DISALLOW_COPY_AND_ASSIGN(ListValue);
490 }; 485 };
491 486
492 // This interface is implemented by classes that know how to serialize 487 // This interface is implemented by classes that know how to serialize
493 // Value objects. 488 // Value objects.
494 class BASE_EXPORT ValueSerializer { 489 class BASE_EXPORT ValueSerializer {
495 public: 490 public:
496 virtual ~ValueSerializer(); 491 virtual ~ValueSerializer();
497 492
498 virtual bool Serialize(const Value& root) = 0; 493 virtual bool Serialize(const Value& root) = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 return out << static_cast<const Value&>(value); 525 return out << static_cast<const Value&>(value);
531 } 526 }
532 527
533 // Stream operator so that enum class Types can be used in log statements. 528 // Stream operator so that enum class Types can be used in log statements.
534 BASE_EXPORT std::ostream& operator<<(std::ostream& out, 529 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
535 const Value::Type& type); 530 const Value::Type& type);
536 531
537 } // namespace base 532 } // namespace base
538 533
539 #endif // BASE_VALUES_H_ 534 #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