| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 explicit Value(std::string&& in_string) noexcept; | 90 explicit Value(std::string&& in_string) noexcept; |
| 91 explicit Value(const char16* in_string); | 91 explicit Value(const char16* in_string); |
| 92 explicit Value(const string16& in_string); | 92 explicit Value(const string16& in_string); |
| 93 explicit Value(StringPiece in_string); | 93 explicit Value(StringPiece in_string); |
| 94 | 94 |
| 95 explicit Value(const std::vector<char>& in_blob); | 95 explicit Value(const std::vector<char>& in_blob); |
| 96 explicit Value(std::vector<char>&& in_blob) noexcept; | 96 explicit Value(std::vector<char>&& in_blob) noexcept; |
| 97 | 97 |
| 98 explicit Value(DictStorage&& in_dict) noexcept; | 98 explicit Value(DictStorage&& in_dict) noexcept; |
| 99 | 99 |
| 100 explicit Value(const ListStorage& in_list); |
| 101 explicit Value(ListStorage&& in_list) noexcept; |
| 102 |
| 100 Value& operator=(const Value& that); | 103 Value& operator=(const Value& that); |
| 101 Value& operator=(Value&& that) noexcept; | 104 Value& operator=(Value&& that) noexcept; |
| 102 | 105 |
| 103 ~Value(); | 106 ~Value(); |
| 104 | 107 |
| 105 // Returns the name for a given |type|. | 108 // Returns the name for a given |type|. |
| 106 static const char* GetTypeName(Type type); | 109 static const char* GetTypeName(Type type); |
| 107 | 110 |
| 108 // Returns the type of the value stored by the current Value object. | 111 // Returns the type of the value stored by the current Value object. |
| 109 // Each type will be implemented by only one subclass of Value, so it's | 112 // Each type will be implemented by only one subclass of Value, so it's |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 bool is_dict() const { return type() == Type::DICTIONARY; } | 126 bool is_dict() const { return type() == Type::DICTIONARY; } |
| 124 bool is_list() const { return type() == Type::LIST; } | 127 bool is_list() const { return type() == Type::LIST; } |
| 125 | 128 |
| 126 // These will all fatally assert if the type doesn't match. | 129 // These will all fatally assert if the type doesn't match. |
| 127 bool GetBool() const; | 130 bool GetBool() const; |
| 128 int GetInt() const; | 131 int GetInt() const; |
| 129 double GetDouble() const; // Implicitly converts from int if necessary. | 132 double GetDouble() const; // Implicitly converts from int if necessary. |
| 130 const std::string& GetString() const; | 133 const std::string& GetString() const; |
| 131 const std::vector<char>& GetBlob() const; | 134 const std::vector<char>& GetBlob() const; |
| 132 | 135 |
| 136 ListStorage& GetList(); |
| 137 const ListStorage& GetList() const; |
| 138 |
| 133 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. | 139 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. |
| 134 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. | 140 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. |
| 135 | 141 |
| 136 // These methods allow the convenient retrieval of the contents of the Value. | 142 // These methods allow the convenient retrieval of the contents of the Value. |
| 137 // If the current object can be converted into the given type, the value is | 143 // If the current object can be converted into the given type, the value is |
| 138 // returned through the |out_value| parameter and true is returned; | 144 // returned through the |out_value| parameter and true is returned; |
| 139 // otherwise, false is returned and |out_value| is unchanged. | 145 // otherwise, false is returned and |out_value| is unchanged. |
| 140 bool GetAsBoolean(bool* out_value) const; | 146 bool GetAsBoolean(bool* out_value) const; |
| 141 bool GetAsInteger(int* out_value) const; | 147 bool GetAsInteger(int* out_value) const; |
| 142 bool GetAsDouble(double* out_value) const; | 148 bool GetAsDouble(double* out_value) const; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 return out << static_cast<const Value&>(value); | 544 return out << static_cast<const Value&>(value); |
| 539 } | 545 } |
| 540 | 546 |
| 541 // Stream operator so that enum class Types can be used in log statements. | 547 // Stream operator so that enum class Types can be used in log statements. |
| 542 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 548 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
| 543 const Value::Type& type); | 549 const Value::Type& type); |
| 544 | 550 |
| 545 } // namespace base | 551 } // namespace base |
| 546 | 552 |
| 547 #endif // BASE_VALUES_H_ | 553 #endif // BASE_VALUES_H_ |
| OLD | NEW |