OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 virtual bool GetAsString(std::string* out_value) const; | 93 virtual bool GetAsString(std::string* out_value) const; |
94 virtual bool GetAsString(string16* out_value) const; | 94 virtual bool GetAsString(string16* out_value) const; |
95 | 95 |
96 // This creates a deep copy of the entire Value tree, and returns a pointer | 96 // This creates a deep copy of the entire Value tree, and returns a pointer |
97 // to the copy. The caller gets ownership of the copy, of course. | 97 // to the copy. The caller gets ownership of the copy, of course. |
98 virtual Value* DeepCopy() const; | 98 virtual Value* DeepCopy() const; |
99 | 99 |
100 // Compares if two Value objects have equal contents. | 100 // Compares if two Value objects have equal contents. |
101 virtual bool Equals(const Value* other) const; | 101 virtual bool Equals(const Value* other) const; |
102 | 102 |
103 // Compares if two Value objects have equal contents. Can hanndle NULLs. | |
Mattias Nissler (ping if slow)
2010/12/01 10:36:36
s/hanndle/handle/
You might want to mention that N
battre (please use the other)
2010/12/01 17:44:38
Done.
| |
104 static bool Equals(const Value* a, const Value* b); | |
105 | |
103 protected: | 106 protected: |
104 // This isn't safe for end-users (they should use the Create*Value() | 107 // This isn't safe for end-users (they should use the Create*Value() |
105 // static methods above), but it's useful for subclasses. | 108 // static methods above), but it's useful for subclasses. |
106 explicit Value(ValueType type); | 109 explicit Value(ValueType type); |
107 | 110 |
108 private: | 111 private: |
109 Value(); | 112 Value(); |
110 | 113 |
111 ValueType type_; | 114 ValueType type_; |
112 | 115 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 // This method deserializes the subclass-specific format into a Value object. | 455 // This method deserializes the subclass-specific format into a Value object. |
453 // If the return value is non-NULL, the caller takes ownership of returned | 456 // If the return value is non-NULL, the caller takes ownership of returned |
454 // Value. If the return value is NULL, and if error_code is non-NULL, | 457 // Value. If the return value is NULL, and if error_code is non-NULL, |
455 // error_code will be set with the underlying error. | 458 // error_code will be set with the underlying error. |
456 // If |error_message| is non-null, it will be filled in with a formatted | 459 // If |error_message| is non-null, it will be filled in with a formatted |
457 // error message including the location of the error if appropriate. | 460 // error message including the location of the error if appropriate. |
458 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 461 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
459 }; | 462 }; |
460 | 463 |
461 #endif // BASE_VALUES_H_ | 464 #endif // BASE_VALUES_H_ |
OLD | NEW |