| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 5 // This file specifies a recursive data storage class called Value |
| 6 // intended for storing setting and other persistable data. | 6 // intended for storing setting and other persistable data. |
| 7 // It includes the ability to specify (recursive) lists and dictionaries, so | 7 // It includes the ability to specify (recursive) lists and dictionaries, so |
| 8 // it's fairly expressive. However, the API is optimized for the common case, | 8 // it's fairly expressive. However, the API is optimized for the common case, |
| 9 // namely storing a hierarchical tree of simple values. Given a | 9 // namely storing a hierarchical tree of simple values. Given a |
| 10 // DictionaryValue root, you can easily do things like: | 10 // DictionaryValue root, you can easily do things like: |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // If the key at any step of the way doesn't exist, or exists but isn't | 217 // If the key at any step of the way doesn't exist, or exists but isn't |
| 218 // a DictionaryValue, a new DictionaryValue will be created and attached | 218 // a DictionaryValue, a new DictionaryValue will be created and attached |
| 219 // to the path in that location. | 219 // to the path in that location. |
| 220 // Note that the dictionary takes ownership of the value referenced by | 220 // Note that the dictionary takes ownership of the value referenced by |
| 221 // |in_value|. | 221 // |in_value|. |
| 222 bool Set(const std::wstring& path, Value* in_value); | 222 bool Set(const std::wstring& path, Value* in_value); |
| 223 | 223 |
| 224 // Convenience forms of Set(). These methods will replace any existing | 224 // Convenience forms of Set(). These methods will replace any existing |
| 225 // value at that path, even if it has a different type. | 225 // value at that path, even if it has a different type. |
| 226 bool SetBoolean(const std::wstring& path, bool in_value); | 226 bool SetBoolean(const std::wstring& path, bool in_value); |
| 227 bool SetBoolean(const wchar_t* path, bool in_value); |
| 227 bool SetInteger(const std::wstring& path, int in_value); | 228 bool SetInteger(const std::wstring& path, int in_value); |
| 229 bool SetInteger(const wchar_t* path, int in_value); |
| 228 bool SetReal(const std::wstring& path, double in_value); | 230 bool SetReal(const std::wstring& path, double in_value); |
| 229 bool SetString(const std::wstring& path, const std::string& in_value); | 231 bool SetString(const std::wstring& path, const std::string& in_value); |
| 232 bool SetString(const wchar_t* path, const std::string& in_value); |
| 230 bool SetString(const std::wstring& path, const std::wstring& in_value); | 233 bool SetString(const std::wstring& path, const std::wstring& in_value); |
| 234 bool SetString(const wchar_t* path, const std::wstring& in_value); |
| 231 | 235 |
| 232 // Gets the Value associated with the given path starting from this object. | 236 // Gets the Value associated with the given path starting from this object. |
| 233 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes | 237 // A path has the form "<key>" or "<key>.<key>.[...]", where "." indexes |
| 234 // into the next DictionaryValue down. If the path can be resolved | 238 // into the next DictionaryValue down. If the path can be resolved |
| 235 // successfully, the value for the last key in the path will be returned | 239 // successfully, the value for the last key in the path will be returned |
| 236 // through the "value" parameter, and the function will return true. | 240 // through the "value" parameter, and the function will return true. |
| 237 // Otherwise, it will return false and "value" will be untouched. | 241 // Otherwise, it will return false and "value" will be untouched. |
| 238 // Note that the dictionary always owns the value that's returned. | 242 // Note that the dictionary always owns the value that's returned. |
| 239 bool Get(const std::wstring& path, Value** out_value) const; | 243 bool Get(const std::wstring& path, Value** out_value) const; |
| 240 | 244 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 virtual bool Serialize(const Value& root) = 0; | 369 virtual bool Serialize(const Value& root) = 0; |
| 366 | 370 |
| 367 // This method deserializes the subclass-specific format into a Value object. | 371 // This method deserializes the subclass-specific format into a Value object. |
| 368 // If the return value is non-NULL, the caller takes ownership of returned | 372 // If the return value is non-NULL, the caller takes ownership of returned |
| 369 // Value. If the return value is NULL, and if error_message is non-NULL, | 373 // Value. If the return value is NULL, and if error_message is non-NULL, |
| 370 // error_message should be filled with a message describing the error. | 374 // error_message should be filled with a message describing the error. |
| 371 virtual Value* Deserialize(std::string* error_message) = 0; | 375 virtual Value* Deserialize(std::string* error_message) = 0; |
| 372 }; | 376 }; |
| 373 | 377 |
| 374 #endif // BASE_VALUES_H_ | 378 #endif // BASE_VALUES_H_ |
| OLD | NEW |