| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 setting and other persistable data. It includes the ability to | 6 // storing setting and other persistable data. It includes the ability to |
| 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. | 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. |
| 8 // However, the API is optimized for the common case, namely storing a | 8 // However, the API is optimized for the common case, namely storing a |
| 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can | 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can |
| 10 // easily do things like: | 10 // easily do things like: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 static StringValue* CreateStringValue(const std::string& in_value); | 77 static StringValue* CreateStringValue(const std::string& in_value); |
| 78 static StringValue* CreateStringValue(const string16& in_value); | 78 static StringValue* CreateStringValue(const string16& in_value); |
| 79 | 79 |
| 80 // Returns the type of the value stored by the current Value object. | 80 // Returns the type of the value stored by the current Value object. |
| 81 // Each type will be implemented by only one subclass of Value, so it's | 81 // Each type will be implemented by only one subclass of Value, so it's |
| 82 // safe to use the Type to determine whether you can cast from | 82 // safe to use the Type to determine whether you can cast from |
| 83 // Value* to (Implementing Class)*. Also, a Value object never changes | 83 // Value* to (Implementing Class)*. Also, a Value object never changes |
| 84 // its type after construction. | 84 // its type after construction. |
| 85 Type GetType() const { return type_; } | 85 Type GetType() const { return type_; } |
| 86 | 86 |
| 87 // Returns true if the current object represents a given type. | 87 bool IsNull() const; |
| 88 bool IsType(Type type) const { return type == type_; } | 88 bool IsBoolean() const; |
| 89 bool IsInteger() const; |
| 90 bool IsDouble() const; |
| 91 bool IsString() const; |
| 92 bool IsBinary() const; |
| 93 bool IsDictionary() const; |
| 94 bool IsList() const; |
| 89 | 95 |
| 90 // These methods allow the convenient retrieval of settings. | 96 // These methods allow the convenient retrieval of settings. |
| 91 // If the current setting object can be converted into the given type, | 97 // If the current setting object can be converted into the given type, |
| 92 // the value is returned through the |out_value| parameter and true is | 98 // the value is returned through the |out_value| parameter and true is |
| 93 // returned; otherwise, false is returned and |out_value| is unchanged. | 99 // returned; otherwise, false is returned and |out_value| is unchanged. |
| 94 virtual bool GetAsBoolean(bool* out_value) const; | 100 virtual bool GetAsBoolean(bool* out_value) const; |
| 95 virtual bool GetAsInteger(int* out_value) const; | 101 virtual bool GetAsInteger(int* out_value) const; |
| 96 virtual bool GetAsDouble(double* out_value) const; | 102 virtual bool GetAsDouble(double* out_value) const; |
| 97 virtual bool GetAsString(std::string* out_value) const; | 103 virtual bool GetAsString(std::string* out_value) const; |
| 98 virtual bool GetAsString(string16* out_value) const; | 104 virtual bool GetAsString(string16* out_value) const; |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 467 |
| 462 } // namespace base | 468 } // namespace base |
| 463 | 469 |
| 464 // http://crbug.com/88666 | 470 // http://crbug.com/88666 |
| 465 using base::DictionaryValue; | 471 using base::DictionaryValue; |
| 466 using base::ListValue; | 472 using base::ListValue; |
| 467 using base::StringValue; | 473 using base::StringValue; |
| 468 using base::Value; | 474 using base::Value; |
| 469 | 475 |
| 470 #endif // BASE_VALUES_H_ | 476 #endif // BASE_VALUES_H_ |
| OLD | NEW |