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

Side by Side Diff: base/values.h

Issue 2683203004: Move Storage for ListValue and DictValue in Union (Closed)
Patch Set: 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_unittest.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>>;
brettw 2017/02/11 00:24:04 As I commented in the private thread, does the siz
jdoerrie 2017/02/14 17:06:56 Done. Wrapping the map in a unique_ptr results in
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<DictStorage> dictionary_;
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();
200
201 // Overridden from Value:
202 bool GetAsDictionary(DictionaryValue** out_value) override;
203 bool GetAsDictionary(const DictionaryValue** out_value) const override;
204 207
205 // Returns true if the current dictionary has a value for the given key. 208 // Returns true if the current dictionary has a value for the given key.
206 bool HasKey(StringPiece key) const; 209 bool HasKey(StringPiece key) const;
207 210
208 // Returns the number of Values in this dictionary. 211 // Returns the number of Values in this dictionary.
209 size_t size() const { return dictionary_.size(); } 212 size_t size() const { return dictionary_->size(); }
210 213
211 // Returns whether the dictionary is empty. 214 // Returns whether the dictionary is empty.
212 bool empty() const { return dictionary_.empty(); } 215 bool empty() const { return dictionary_->empty(); }
213 216
214 // Clears any current contents of this dictionary. 217 // Clears any current contents of this dictionary.
215 void Clear(); 218 void Clear();
216 219
217 // Sets the Value associated with the given path starting from this object. 220 // Sets the Value associated with the given path starting from this object.
218 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes 221 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes
219 // into the next DictionaryValue down. Obviously, "." can't be used 222 // into the next DictionaryValue down. Obviously, "." can't be used
220 // within a key, but there are no other restrictions on keys. 223 // 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 224 // 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 225 // 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 305 // 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). 306 // 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 307 // 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. 308 // |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 309 // This method returns true if |path| is a valid path; otherwise it will
307 // return false and the DictionaryValue object will be unchanged. 310 // return false and the DictionaryValue object will be unchanged.
308 bool Remove(StringPiece path, std::unique_ptr<Value>* out_value); 311 bool Remove(StringPiece path, std::unique_ptr<Value>* out_value);
309 312
310 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs 313 // Like Remove(), but without special treatment of '.'. This allows e.g. URLs
311 // to be used as paths. 314 // to be used as paths.
312 virtual bool RemoveWithoutPathExpansion(StringPiece key, 315 bool RemoveWithoutPathExpansion(StringPiece key,
313 std::unique_ptr<Value>* out_value); 316 std::unique_ptr<Value>* out_value);
314 317
315 // Removes a path, clearing out all dictionaries on |path| that remain empty 318 // Removes a path, clearing out all dictionaries on |path| that remain empty
316 // after removing the value at |path|. 319 // after removing the value at |path|.
317 bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value); 320 bool RemovePath(StringPiece path, std::unique_ptr<Value>* out_value);
318 321
319 // Makes a copy of |this| but doesn't include empty dictionaries and lists in 322 // 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. 323 // the copy. This never returns NULL, even if |this| itself is empty.
321 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const; 324 std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
322 325
323 // Merge |dictionary| into this dictionary. This is done recursively, i.e. any 326 // 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 327 // 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 328 // passed in dictionary takes precedence and data already present will be
326 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may 329 // replaced. Values within |dictionary| are deep-copied, so |dictionary| may
327 // be freed any time after this call. 330 // be freed any time after this call.
328 void MergeDictionary(const DictionaryValue* dictionary); 331 void MergeDictionary(const DictionaryValue* dictionary);
329 332
330 // Swaps contents with the |other| dictionary. 333 // Swaps contents with the |other| dictionary.
331 virtual void Swap(DictionaryValue* other); 334 void Swap(DictionaryValue* other);
332 335
333 // This class provides an iterator over both keys and values in the 336 // This class provides an iterator over both keys and values in the
334 // dictionary. It can't be used to modify the dictionary. 337 // dictionary. It can't be used to modify the dictionary.
335 class BASE_EXPORT Iterator { 338 class BASE_EXPORT Iterator {
336 public: 339 public:
337 explicit Iterator(const DictionaryValue& target); 340 explicit Iterator(const DictionaryValue& target);
338 Iterator(const Iterator& other); 341 Iterator(const Iterator& other);
339 ~Iterator(); 342 ~Iterator();
340 343
341 bool IsAtEnd() const { return it_ == target_.dictionary_.end(); } 344 bool IsAtEnd() const { return it_ == target_.dictionary_->end(); }
342 void Advance() { ++it_; } 345 void Advance() { ++it_; }
343 346
344 const std::string& key() const { return it_->first; } 347 const std::string& key() const { return it_->first; }
345 const Value& value() const { return *it_->second; } 348 const Value& value() const { return *it_->second; }
346 349
347 private: 350 private:
348 const DictionaryValue& target_; 351 const DictionaryValue& target_;
349 Storage::const_iterator it_; 352 DictStorage::const_iterator it_;
350 }; 353 };
351 354
352 // Overridden from Value: 355 DictionaryValue* DeepCopy() const;
353 DictionaryValue* DeepCopy() const override;
354 // Preferred version of DeepCopy. TODO(estade): remove the above. 356 // Preferred version of DeepCopy. TODO(estade): remove the above.
355 std::unique_ptr<DictionaryValue> CreateDeepCopy() const; 357 std::unique_ptr<DictionaryValue> CreateDeepCopy() const;
356 bool Equals(const Value* other) const override;
357
358 private:
359 Storage dictionary_;
360
361 DISALLOW_COPY_AND_ASSIGN(DictionaryValue);
jdoerrie 2017/02/10 18:45:44 Given that it is currently impossible to copy cons
362 }; 358 };
363 359
364 // This type of Value represents a list of other Value values. 360 // This type of Value represents a list of other Value values.
365 class BASE_EXPORT ListValue : public Value { 361 class BASE_EXPORT ListValue : public Value {
366 public: 362 public:
367 using Storage = std::vector<std::unique_ptr<Value>>; 363 using const_iterator = ListStorage::const_iterator;
368 using const_iterator = Storage::const_iterator; 364 using iterator = ListStorage::iterator;
369 using iterator = Storage::iterator;
370 365
371 // Returns |value| if it is a list, nullptr otherwise. 366 // Returns |value| if it is a list, nullptr otherwise.
372 static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value); 367 static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value);
373 368
374 ListValue(); 369 ListValue();
375 ~ListValue() override; 370 ~ListValue();
376 371
377 // Clears the contents of this ListValue 372 // Clears the contents of this ListValue
378 void Clear(); 373 void Clear();
379 374
380 // Returns the number of Values in this list. 375 // Returns the number of Values in this list.
381 size_t GetSize() const { return list_.size(); } 376 size_t GetSize() const { return list_->size(); }
382 377
383 // Returns whether the list is empty. 378 // Returns whether the list is empty.
384 bool empty() const { return list_.empty(); } 379 bool empty() const { return list_->empty(); }
385 380
386 // Sets the list item at the given index to be the Value specified by 381 // 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 382 // the value given. If the index beyond the current end of the list, null
388 // Values will be used to pad out the list. 383 // Values will be used to pad out the list.
389 // Returns true if successful, or false if the index was negative or 384 // Returns true if successful, or false if the index was negative or
390 // the value is a null pointer. 385 // the value is a null pointer.
391 bool Set(size_t index, Value* in_value); 386 bool Set(size_t index, Value* in_value);
392 // Preferred version of the above. TODO(estade): remove the above. 387 // Preferred version of the above. TODO(estade): remove the above.
393 bool Set(size_t index, std::unique_ptr<Value> in_value); 388 bool Set(size_t index, std::unique_ptr<Value> in_value);
394 389
(...skipping 20 matching lines...) Expand all
415 bool GetDictionary(size_t index, const DictionaryValue** out_value) const; 410 bool GetDictionary(size_t index, const DictionaryValue** out_value) const;
416 bool GetDictionary(size_t index, DictionaryValue** out_value); 411 bool GetDictionary(size_t index, DictionaryValue** out_value);
417 bool GetList(size_t index, const ListValue** out_value) const; 412 bool GetList(size_t index, const ListValue** out_value) const;
418 bool GetList(size_t index, ListValue** out_value); 413 bool GetList(size_t index, ListValue** out_value);
419 414
420 // Removes the Value with the specified index from this list. 415 // 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 416 // 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 417 // 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 418 // be deleted. This method returns true if |index| is valid; otherwise
424 // it will return false and the ListValue object will be unchanged. 419 // it will return false and the ListValue object will be unchanged.
425 virtual bool Remove(size_t index, std::unique_ptr<Value>* out_value); 420 bool Remove(size_t index, std::unique_ptr<Value>* out_value);
426 421
427 // Removes the first instance of |value| found in the list, if any, and 422 // 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 423 // deletes it. |index| is the location where |value| was found. Returns false
429 // if not found. 424 // if not found.
430 bool Remove(const Value& value, size_t* index); 425 bool Remove(const Value& value, size_t* index);
431 426
432 // Removes the element at |iter|. If |out_value| is NULL, the value will be 427 // 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. 428 // deleted, otherwise ownership of the value is passed back to the caller.
434 // Returns an iterator pointing to the location of the element that 429 // Returns an iterator pointing to the location of the element that
435 // followed the erased element. 430 // followed the erased element.
(...skipping 22 matching lines...) Expand all
458 // Insert a Value at index. 453 // Insert a Value at index.
459 // Returns true if successful, or false if the index was out of range. 454 // 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); 455 bool Insert(size_t index, std::unique_ptr<Value> in_value);
461 456
462 // Searches for the first instance of |value| in the list using the Equals 457 // Searches for the first instance of |value| in the list using the Equals
463 // method of the Value type. 458 // method of the Value type.
464 // Returns a const_iterator to the found item or to end() if none exists. 459 // Returns a const_iterator to the found item or to end() if none exists.
465 const_iterator Find(const Value& value) const; 460 const_iterator Find(const Value& value) const;
466 461
467 // Swaps contents with the |other| list. 462 // Swaps contents with the |other| list.
468 virtual void Swap(ListValue* other); 463 void Swap(ListValue* other);
469 464
470 // Iteration. 465 // Iteration.
471 iterator begin() { return list_.begin(); } 466 iterator begin() { return list_->begin(); }
472 iterator end() { return list_.end(); } 467 iterator end() { return list_->end(); }
473 468
474 const_iterator begin() const { return list_.begin(); } 469 const_iterator begin() const { return list_->begin(); }
475 const_iterator end() const { return list_.end(); } 470 const_iterator end() const { return list_->end(); }
476 471
477 // Overridden from Value: 472 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. 473 // Preferred version of DeepCopy. TODO(estade): remove DeepCopy.
484 std::unique_ptr<ListValue> CreateDeepCopy() const; 474 std::unique_ptr<ListValue> CreateDeepCopy() const;
485
486 private:
487 Storage list_;
488
489 DISALLOW_COPY_AND_ASSIGN(ListValue);
jdoerrie 2017/02/10 18:45:44 Same as above.
490 }; 475 };
491 476
492 // This interface is implemented by classes that know how to serialize 477 // This interface is implemented by classes that know how to serialize
493 // Value objects. 478 // Value objects.
494 class BASE_EXPORT ValueSerializer { 479 class BASE_EXPORT ValueSerializer {
495 public: 480 public:
496 virtual ~ValueSerializer(); 481 virtual ~ValueSerializer();
497 482
498 virtual bool Serialize(const Value& root) = 0; 483 virtual bool Serialize(const Value& root) = 0;
499 }; 484 };
(...skipping 30 matching lines...) Expand all
530 return out << static_cast<const Value&>(value); 515 return out << static_cast<const Value&>(value);
531 } 516 }
532 517
533 // Stream operator so that enum class Types can be used in log statements. 518 // Stream operator so that enum class Types can be used in log statements.
534 BASE_EXPORT std::ostream& operator<<(std::ostream& out, 519 BASE_EXPORT std::ostream& operator<<(std::ostream& out,
535 const Value::Type& type); 520 const Value::Type& type);
536 521
537 } // namespace base 522 } // namespace base
538 523
539 #endif // BASE_VALUES_H_ 524 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | base/values_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698