| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // These will all fatally assert if the type doesn't match. | 130 // These will all fatally assert if the type doesn't match. |
| 131 bool GetBool() const; | 131 bool GetBool() const; |
| 132 int GetInt() const; | 132 int GetInt() const; |
| 133 double GetDouble() const; // Implicitly converts from int if necessary. | 133 double GetDouble() const; // Implicitly converts from int if necessary. |
| 134 const std::string& GetString() const; | 134 const std::string& GetString() const; |
| 135 const BlobStorage& GetBlob() const; | 135 const BlobStorage& GetBlob() const; |
| 136 | 136 |
| 137 ListStorage& GetList(); | 137 ListStorage& GetList(); |
| 138 const ListStorage& GetList() const; | 138 const ListStorage& GetList() const; |
| 139 | 139 |
| 140 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. | |
| 141 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. | |
| 142 | |
| 143 // These methods allow the convenient retrieval of the contents of the Value. | 140 // These methods allow the convenient retrieval of the contents of the Value. |
| 144 // 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 |
| 145 // returned through the |out_value| parameter and true is returned; | 142 // returned through the |out_value| parameter and true is returned; |
| 146 // otherwise, false is returned and |out_value| is unchanged. | 143 // otherwise, false is returned and |out_value| is unchanged. |
| 147 bool GetAsBoolean(bool* out_value) const; | 144 bool GetAsBoolean(bool* out_value) const; |
| 148 bool GetAsInteger(int* out_value) const; | 145 bool GetAsInteger(int* out_value) const; |
| 149 bool GetAsDouble(double* out_value) const; | 146 bool GetAsDouble(double* out_value) const; |
| 150 bool GetAsString(std::string* out_value) const; | 147 bool GetAsString(std::string* out_value) const; |
| 151 bool GetAsString(string16* out_value) const; | 148 bool GetAsString(string16* out_value) const; |
| 152 bool GetAsString(const Value** out_value) const; | 149 bool GetAsString(const Value** out_value) const; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return out << static_cast<const Value&>(value); | 535 return out << static_cast<const Value&>(value); |
| 539 } | 536 } |
| 540 | 537 |
| 541 // Stream operator so that enum class Types can be used in log statements. | 538 // Stream operator so that enum class Types can be used in log statements. |
| 542 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 539 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
| 543 const Value::Type& type); | 540 const Value::Type& type); |
| 544 | 541 |
| 545 } // namespace base | 542 } // namespace base |
| 546 | 543 |
| 547 #endif // BASE_VALUES_H_ | 544 #endif // BASE_VALUES_H_ |
| OLD | NEW |