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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Convenience methods for creating Value objects for various | 69 // Convenience methods for creating Value objects for various |
70 // kinds of values without thinking about which class implements them. | 70 // kinds of values without thinking about which class implements them. |
71 // These can always be expected to return a valid Value*. | 71 // These can always be expected to return a valid Value*. |
72 static Value* CreateNullValue(); | 72 static Value* CreateNullValue(); |
73 static FundamentalValue* CreateBooleanValue(bool in_value); | 73 static FundamentalValue* CreateBooleanValue(bool in_value); |
74 static FundamentalValue* CreateIntegerValue(int in_value); | 74 static FundamentalValue* CreateIntegerValue(int in_value); |
75 static FundamentalValue* CreateDoubleValue(double in_value); | 75 static FundamentalValue* CreateDoubleValue(double in_value); |
76 static StringValue* CreateStringValue(const std::string& in_value); | 76 static StringValue* CreateStringValue(const std::string& in_value); |
77 static StringValue* CreateStringValue(const string16& in_value); | 77 static StringValue* CreateStringValue(const string16& in_value); |
78 | 78 |
79 // This one can return NULL if the input isn't valid. If the return value | |
80 // is non-null, the new object has taken ownership of the buffer pointer. | |
81 static BinaryValue* CreateBinaryValue(char* buffer, size_t size); | |
82 | |
83 // Returns the type of the value stored by the current Value object. | 79 // Returns the type of the value stored by the current Value object. |
84 // Each type will be implemented by only one subclass of Value, so it's | 80 // Each type will be implemented by only one subclass of Value, so it's |
85 // safe to use the ValueType to determine whether you can cast from | 81 // safe to use the ValueType to determine whether you can cast from |
86 // Value* to (Implementing Class)*. Also, a Value object never changes | 82 // Value* to (Implementing Class)*. Also, a Value object never changes |
87 // its type after construction. | 83 // its type after construction. |
88 ValueType GetType() const { return type_; } | 84 ValueType GetType() const { return type_; } |
89 | 85 |
90 // Returns true if the current object represents a given type. | 86 // Returns true if the current object represents a given type. |
91 bool IsType(ValueType type) const { return type == type_; } | 87 bool IsType(ValueType type) const { return type == type_; } |
92 | 88 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 459 |
464 } // namespace base | 460 } // namespace base |
465 | 461 |
466 // http://crbug.com/88666 | 462 // http://crbug.com/88666 |
467 using base::DictionaryValue; | 463 using base::DictionaryValue; |
468 using base::ListValue; | 464 using base::ListValue; |
469 using base::StringValue; | 465 using base::StringValue; |
470 using base::Value; | 466 using base::Value; |
471 | 467 |
472 #endif // BASE_VALUES_H_ | 468 #endif // BASE_VALUES_H_ |
OLD | NEW |