| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 TYPE_STRING, | 57 TYPE_STRING, |
| 58 TYPE_BINARY, | 58 TYPE_BINARY, |
| 59 TYPE_DICTIONARY, | 59 TYPE_DICTIONARY, |
| 60 TYPE_LIST | 60 TYPE_LIST |
| 61 // Note: Do not add more types. See the file-level comment above for why. | 61 // Note: Do not add more types. See the file-level comment above for why. |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 virtual ~Value(); | 64 virtual ~Value(); |
| 65 | 65 |
| 66 static Value* CreateNullValue(); | 66 static Value* CreateNullValue(); |
| 67 // DEPRECATED: Do not use the following 5 functions. Instead, use | |
| 68 // new FundamentalValue or new StringValue. | |
| 69 static FundamentalValue* CreateBooleanValue(bool in_value); | |
| 70 static FundamentalValue* CreateIntegerValue(int in_value); | |
| 71 static FundamentalValue* CreateDoubleValue(double in_value); | |
| 72 static StringValue* CreateStringValue(const std::string& in_value); | |
| 73 static StringValue* CreateStringValue(const string16& in_value); | |
| 74 | 67 |
| 75 // Returns the type of the value stored by the current Value object. | 68 // Returns the type of the value stored by the current Value object. |
| 76 // Each type will be implemented by only one subclass of Value, so it's | 69 // Each type will be implemented by only one subclass of Value, so it's |
| 77 // safe to use the Type to determine whether you can cast from | 70 // safe to use the Type to determine whether you can cast from |
| 78 // Value* to (Implementing Class)*. Also, a Value object never changes | 71 // Value* to (Implementing Class)*. Also, a Value object never changes |
| 79 // its type after construction. | 72 // its type after construction. |
| 80 Type GetType() const { return type_; } | 73 Type GetType() const { return type_; } |
| 81 | 74 |
| 82 // Returns true if the current object represents a given type. | 75 // Returns true if the current object represents a given type. |
| 83 bool IsType(Type type) const { return type == type_; } | 76 bool IsType(Type type) const { return type == type_; } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 526 } |
| 534 | 527 |
| 535 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 528 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 536 const ListValue& value) { | 529 const ListValue& value) { |
| 537 return out << static_cast<const Value&>(value); | 530 return out << static_cast<const Value&>(value); |
| 538 } | 531 } |
| 539 | 532 |
| 540 } // namespace base | 533 } // namespace base |
| 541 | 534 |
| 542 #endif // BASE_VALUES_H_ | 535 #endif // BASE_VALUES_H_ |
| OLD | NEW |