OLD | NEW |
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 Loading... |
184 // in sizeof(Value) = 56 if DictStorage was stack allocated. Allocating it | 184 // in sizeof(Value) = 56 if DictStorage was stack allocated. Allocating it |
185 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC. | 185 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC. |
186 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_; | 186 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_; |
187 ManualConstructor<ListStorage> list_; | 187 ManualConstructor<ListStorage> list_; |
188 }; | 188 }; |
189 | 189 |
190 private: | 190 private: |
191 void InternalCopyFundamentalValue(const Value& that); | 191 void InternalCopyFundamentalValue(const Value& that); |
192 void InternalCopyConstructFrom(const Value& that); | 192 void InternalCopyConstructFrom(const Value& that); |
193 void InternalMoveConstructFrom(Value&& that); | 193 void InternalMoveConstructFrom(Value&& that); |
194 void InternalCopyAssignFrom(const Value& that); | 194 void InternalCopyAssignFromSameType(const Value& that); |
195 void InternalMoveAssignFrom(Value&& that); | 195 void InternalMoveAssignFromSameType(Value&& that); |
196 void InternalCleanup(); | 196 void InternalCleanup(); |
197 }; | 197 }; |
198 | 198 |
199 // DictionaryValue provides a key-value dictionary with (optional) "path" | 199 // DictionaryValue provides a key-value dictionary with (optional) "path" |
200 // parsing for recursive access; see the comment at the top of the file. Keys | 200 // parsing for recursive access; see the comment at the top of the file. Keys |
201 // are |std::string|s and should be UTF-8 encoded. | 201 // are |std::string|s and should be UTF-8 encoded. |
202 class BASE_EXPORT DictionaryValue : public Value { | 202 class BASE_EXPORT DictionaryValue : public Value { |
203 public: | 203 public: |
204 // Returns |value| if it is a dictionary, nullptr otherwise. | 204 // Returns |value| if it is a dictionary, nullptr otherwise. |
205 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value); | 205 static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 return out << static_cast<const Value&>(value); | 515 return out << static_cast<const Value&>(value); |
516 } | 516 } |
517 | 517 |
518 // 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. |
519 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 519 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
520 const Value::Type& type); | 520 const Value::Type& type); |
521 | 521 |
522 } // namespace base | 522 } // namespace base |
523 | 523 |
524 #endif // BASE_VALUES_H_ | 524 #endif // BASE_VALUES_H_ |
OLD | NEW |