| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Returns true if the current object represents a given type. | 114 // Returns true if the current object represents a given type. |
| 115 bool IsType(Type type) const { return type == type_; } | 115 bool IsType(Type type) const { return type == type_; } |
| 116 bool is_bool() const { return type() == Type::BOOLEAN; } | 116 bool is_bool() const { return type() == Type::BOOLEAN; } |
| 117 bool is_int() const { return type() == Type::INTEGER; } | 117 bool is_int() const { return type() == Type::INTEGER; } |
| 118 bool is_double() const { return type() == Type::DOUBLE; } | 118 bool is_double() const { return type() == Type::DOUBLE; } |
| 119 bool is_string() const { return type() == Type::STRING; } | 119 bool is_string() const { return type() == Type::STRING; } |
| 120 bool is_blob() const { return type() == Type::BINARY; } | 120 bool is_blob() const { return type() == Type::BINARY; } |
| 121 bool is_dict() const { return type() == Type::DICTIONARY; } | 121 bool is_dict() const { return type() == Type::DICTIONARY; } |
| 122 bool is_list() const { return type() == Type::LIST; } | 122 bool is_list() const { return type() == Type::LIST; } |
| 123 | 123 |
| 124 bool IsValid() const; |
| 125 |
| 124 // These will all fatally assert if the type doesn't match. | 126 // These will all fatally assert if the type doesn't match. |
| 125 bool GetBool() const; | 127 bool GetBool() const; |
| 126 int GetInt() const; | 128 int GetInt() const; |
| 127 double GetDouble() const; // Implicitly converts from int if necessary. | 129 double GetDouble() const; // Implicitly converts from int if necessary. |
| 128 const std::string& GetString() const; | 130 const std::string& GetString() const; |
| 129 const std::vector<char>& GetBlob() const; | 131 const std::vector<char>& GetBlob() const; |
| 130 | 132 |
| 131 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. | 133 size_t GetSize() const; // DEPRECATED, use GetBlob().size() instead. |
| 132 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. | 134 const char* GetBuffer() const; // DEPRECATED, use GetBlob().data() instead. |
| 133 | 135 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return out << static_cast<const Value&>(value); | 532 return out << static_cast<const Value&>(value); |
| 531 } | 533 } |
| 532 | 534 |
| 533 // Stream operator so that enum class Types can be used in log statements. | 535 // Stream operator so that enum class Types can be used in log statements. |
| 534 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 536 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
| 535 const Value::Type& type); | 537 const Value::Type& type); |
| 536 | 538 |
| 537 } // namespace base | 539 } // namespace base |
| 538 | 540 |
| 539 #endif // BASE_VALUES_H_ | 541 #endif // BASE_VALUES_H_ |
| OLD | NEW |