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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // If the current object can be converted into the given type, the value is | 141 // If the current object can be converted into the given type, the value is |
142 // returned through the |out_value| parameter and true is returned; | 142 // returned through the |out_value| parameter and true is returned; |
143 // otherwise, false is returned and |out_value| is unchanged. | 143 // otherwise, false is returned and |out_value| is unchanged. |
144 bool GetAsBoolean(bool* out_value) const; | 144 bool GetAsBoolean(bool* out_value) const; |
145 bool GetAsInteger(int* out_value) const; | 145 bool GetAsInteger(int* out_value) const; |
146 bool GetAsDouble(double* out_value) const; | 146 bool GetAsDouble(double* out_value) const; |
147 bool GetAsString(std::string* out_value) const; | 147 bool GetAsString(std::string* out_value) const; |
148 bool GetAsString(string16* out_value) const; | 148 bool GetAsString(string16* out_value) const; |
149 bool GetAsString(const Value** out_value) const; | 149 bool GetAsString(const Value** out_value) const; |
150 bool GetAsString(StringPiece* out_value) const; | 150 bool GetAsString(StringPiece* out_value) const; |
151 bool GetAsBinary(const Value** out_value) const; | |
152 // ListValue::From is the equivalent for std::unique_ptr conversions. | 151 // ListValue::From is the equivalent for std::unique_ptr conversions. |
153 bool GetAsList(ListValue** out_value); | 152 bool GetAsList(ListValue** out_value); |
154 bool GetAsList(const ListValue** out_value) const; | 153 bool GetAsList(const ListValue** out_value) const; |
155 // DictionaryValue::From is the equivalent for std::unique_ptr conversions. | 154 // DictionaryValue::From is the equivalent for std::unique_ptr conversions. |
156 bool GetAsDictionary(DictionaryValue** out_value); | 155 bool GetAsDictionary(DictionaryValue** out_value); |
157 bool GetAsDictionary(const DictionaryValue** out_value) const; | 156 bool GetAsDictionary(const DictionaryValue** out_value) const; |
158 // Note: Do not add more types. See the file-level comment above for why. | 157 // Note: Do not add more types. See the file-level comment above for why. |
159 | 158 |
160 // This creates a deep copy of the entire Value tree, and returns a pointer | 159 // This creates a deep copy of the entire Value tree, and returns a pointer |
161 // to the copy. The caller gets ownership of the copy, of course. | 160 // to the copy. The caller gets ownership of the copy, of course. |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 return out << static_cast<const Value&>(value); | 534 return out << static_cast<const Value&>(value); |
536 } | 535 } |
537 | 536 |
538 // Stream operator so that enum class Types can be used in log statements. | 537 // Stream operator so that enum class Types can be used in log statements. |
539 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 538 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
540 const Value::Type& type); | 539 const Value::Type& type); |
541 | 540 |
542 } // namespace base | 541 } // namespace base |
543 | 542 |
544 #endif // BASE_VALUES_H_ | 543 #endif // BASE_VALUES_H_ |
OLD | NEW |