| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 bool Get(const std::string& path, Value** out_value) const; | 282 bool Get(const std::string& path, Value** out_value) const; |
| 283 /*DEPRECATED*/bool Get(const std::wstring& path, Value** out_value) const; | 283 /*DEPRECATED*/bool Get(const std::wstring& path, Value** out_value) const; |
| 284 | 284 |
| 285 // These are convenience forms of Get(). The value will be retrieved | 285 // These are convenience forms of Get(). The value will be retrieved |
| 286 // and the return value will be true if the path is valid and the value at | 286 // and the return value will be true if the path is valid and the value at |
| 287 // the end of the path can be returned in the form specified. | 287 // the end of the path can be returned in the form specified. |
| 288 bool GetBoolean(const std::string& path, bool* out_value) const; | 288 bool GetBoolean(const std::string& path, bool* out_value) const; |
| 289 bool GetInteger(const std::string& path, int* out_value) const; | 289 bool GetInteger(const std::string& path, int* out_value) const; |
| 290 bool GetReal(const std::string& path, double* out_value) const; | 290 bool GetReal(const std::string& path, double* out_value) const; |
| 291 bool GetString(const std::string& path, std::string* out_value) const; | 291 bool GetString(const std::string& path, std::string* out_value) const; |
| 292 bool GetStringAsUTF16(const std::string& path, string16* out_value) const; | 292 bool GetString(const std::string& path, string16* out_value) const; |
| 293 bool GetStringASCII(const std::string& path, std::string* out_value) const; | 293 bool GetStringASCII(const std::string& path, std::string* out_value) const; |
| 294 bool GetBinary(const std::string& path, BinaryValue** out_value) const; | 294 bool GetBinary(const std::string& path, BinaryValue** out_value) const; |
| 295 bool GetDictionary(const std::string& path, | 295 bool GetDictionary(const std::string& path, |
| 296 DictionaryValue** out_value) const; | 296 DictionaryValue** out_value) const; |
| 297 bool GetList(const std::string& path, ListValue** out_value) const; | 297 bool GetList(const std::string& path, ListValue** out_value) const; |
| 298 /*DEPRECATED*/bool GetBoolean(const std::wstring& path, | 298 /*DEPRECATED*/bool GetBoolean(const std::wstring& path, |
| 299 bool* out_value) const; | 299 bool* out_value) const; |
| 300 /*DEPRECATED*/bool GetInteger(const std::wstring& path, int* out_value) const; | 300 /*DEPRECATED*/bool GetInteger(const std::wstring& path, int* out_value) const; |
| 301 /*DEPRECATED*/bool GetReal(const std::wstring& path, double* out_value) const; | 301 /*DEPRECATED*/bool GetReal(const std::wstring& path, double* out_value) const; |
| 302 // Use |GetStringAsUTF16()| instead: | |
| 303 /*DEPRECATED*/bool GetString(const std::string& path, | |
| 304 string16* out_value) const; | |
| 305 /*DEPRECATED*/bool GetString(const std::wstring& path, | 302 /*DEPRECATED*/bool GetString(const std::wstring& path, |
| 306 std::string* out_value) const; | 303 std::string* out_value) const; |
| 307 /*DEPRECATED*/bool GetString(const std::wstring& path, | 304 /*DEPRECATED*/bool GetString(const std::wstring& path, |
| 308 std::wstring* out_value) const; | 305 std::wstring* out_value) const; |
| 309 /*DEPRECATED*/bool GetStringAsUTF16(const std::wstring& path, | |
| 310 string16* out_value) const; | |
| 311 /*DEPRECATED*/bool GetBinary(const std::wstring& path, | 306 /*DEPRECATED*/bool GetBinary(const std::wstring& path, |
| 312 BinaryValue** out_value) const; | 307 BinaryValue** out_value) const; |
| 313 /*DEPRECATED*/bool GetDictionary(const std::wstring& path, | 308 /*DEPRECATED*/bool GetDictionary(const std::wstring& path, |
| 314 DictionaryValue** out_value) const; | 309 DictionaryValue** out_value) const; |
| 315 /*DEPRECATED*/bool GetList(const std::wstring& path, | 310 /*DEPRECATED*/bool GetList(const std::wstring& path, |
| 316 ListValue** out_value) const; | 311 ListValue** out_value) const; |
| 317 | 312 |
| 318 // Like Get(), but without special treatment of '.'. This allows e.g. URLs to | 313 // Like Get(), but without special treatment of '.'. This allows e.g. URLs to |
| 319 // be used as paths. | 314 // be used as paths. |
| 320 bool GetWithoutPathExpansion(const std::string& key, | 315 bool GetWithoutPathExpansion(const std::string& key, |
| 321 Value** out_value) const; | 316 Value** out_value) const; |
| 322 bool GetIntegerWithoutPathExpansion(const std::string& key, | 317 bool GetIntegerWithoutPathExpansion(const std::string& key, |
| 323 int* out_value) const; | 318 int* out_value) const; |
| 324 bool GetStringWithoutPathExpansion(const std::string& key, | 319 bool GetStringWithoutPathExpansion(const std::string& key, |
| 325 std::string* out_value) const; | 320 std::string* out_value) const; |
| 326 bool GetStringAsUTF16WithoutPathExpansion(const std::string& key, | 321 bool GetStringWithoutPathExpansion(const std::string& key, |
| 327 string16* out_value) const; | 322 string16* out_value) const; |
| 328 bool GetDictionaryWithoutPathExpansion(const std::string& key, | 323 bool GetDictionaryWithoutPathExpansion(const std::string& key, |
| 329 DictionaryValue** out_value) const; | 324 DictionaryValue** out_value) const; |
| 330 bool GetListWithoutPathExpansion(const std::string& key, | 325 bool GetListWithoutPathExpansion(const std::string& key, |
| 331 ListValue** out_value) const; | 326 ListValue** out_value) const; |
| 332 /*DEPRECATED*/bool GetWithoutPathExpansion(const std::wstring& key, | 327 /*DEPRECATED*/bool GetWithoutPathExpansion(const std::wstring& key, |
| 333 Value** out_value) const; | 328 Value** out_value) const; |
| 334 /*DEPRECATED*/bool GetIntegerWithoutPathExpansion(const std::wstring& key, | 329 /*DEPRECATED*/bool GetIntegerWithoutPathExpansion(const std::wstring& key, |
| 335 int* out_value) const; | 330 int* out_value) const; |
| 336 /*DEPRECATED*/bool GetStringWithoutPathExpansion( | 331 /*DEPRECATED*/bool GetStringWithoutPathExpansion( |
| 337 const std::wstring& key, std::string* out_value) const; | 332 const std::wstring& key, std::string* out_value) const; |
| 338 /*DEPRECATED*/bool GetStringWithoutPathExpansion( | 333 /*DEPRECATED*/bool GetStringWithoutPathExpansion( |
| 339 const std::wstring& key, std::wstring* out_value) const; | 334 const std::wstring& key, std::wstring* out_value) const; |
| 340 /*DEPRECATED*/bool GetStringAsUTF16WithoutPathExpansion( | |
| 341 const std::wstring& key, string16* out_value) const; | |
| 342 /*DEPRECATED*/bool GetDictionaryWithoutPathExpansion( | 335 /*DEPRECATED*/bool GetDictionaryWithoutPathExpansion( |
| 343 const std::wstring& key, DictionaryValue** out_value) const; | 336 const std::wstring& key, DictionaryValue** out_value) const; |
| 344 /*DEPRECATED*/bool GetListWithoutPathExpansion(const std::wstring& key, | 337 /*DEPRECATED*/bool GetListWithoutPathExpansion(const std::wstring& key, |
| 345 ListValue** out_value) const; | 338 ListValue** out_value) const; |
| 346 | 339 |
| 347 // Removes the Value with the specified path from this dictionary (or one | 340 // Removes the Value with the specified path from this dictionary (or one |
| 348 // of its child dictionaries, if the path is more than just a local key). | 341 // of its child dictionaries, if the path is more than just a local key). |
| 349 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 342 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be |
| 350 // passed out via out_value. If |out_value| is NULL, the removed value will | 343 // passed out via out_value. If |out_value| is NULL, the removed value will |
| 351 // be deleted. This method returns true if |path| is a valid path; otherwise | 344 // be deleted. This method returns true if |path| is a valid path; otherwise |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // Note that the list always owns the Value passed out via |out_value|. | 445 // Note that the list always owns the Value passed out via |out_value|. |
| 453 bool Get(size_t index, Value** out_value) const; | 446 bool Get(size_t index, Value** out_value) const; |
| 454 | 447 |
| 455 // Convenience forms of Get(). Modifies |out_value| (and returns true) | 448 // Convenience forms of Get(). Modifies |out_value| (and returns true) |
| 456 // only if the index is valid and the Value at that index can be returned | 449 // only if the index is valid and the Value at that index can be returned |
| 457 // in the specified form. | 450 // in the specified form. |
| 458 bool GetBoolean(size_t index, bool* out_value) const; | 451 bool GetBoolean(size_t index, bool* out_value) const; |
| 459 bool GetInteger(size_t index, int* out_value) const; | 452 bool GetInteger(size_t index, int* out_value) const; |
| 460 bool GetReal(size_t index, double* out_value) const; | 453 bool GetReal(size_t index, double* out_value) const; |
| 461 bool GetString(size_t index, std::string* out_value) const; | 454 bool GetString(size_t index, std::string* out_value) const; |
| 462 bool GetString(size_t index, std::wstring* out_value) const; | 455 bool GetString(size_t index, string16* out_value) const; |
| 463 bool GetStringAsUTF16(size_t index, string16* out_value) const; | 456 #if !defined(WCHAR_T_IS_UTF16) |
| 457 /*DEPRECATED*/bool GetString(size_t index, std::wstring* out_value) const; |
| 458 #endif |
| 464 bool GetBinary(size_t index, BinaryValue** out_value) const; | 459 bool GetBinary(size_t index, BinaryValue** out_value) const; |
| 465 bool GetDictionary(size_t index, DictionaryValue** out_value) const; | 460 bool GetDictionary(size_t index, DictionaryValue** out_value) const; |
| 466 bool GetList(size_t index, ListValue** out_value) const; | 461 bool GetList(size_t index, ListValue** out_value) const; |
| 467 | 462 |
| 468 // Removes the Value with the specified index from this list. | 463 // Removes the Value with the specified index from this list. |
| 469 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be | 464 // If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be |
| 470 // passed out via |out_value|. If |out_value| is NULL, the removed value will | 465 // passed out via |out_value|. If |out_value| is NULL, the removed value will |
| 471 // be deleted. This method returns true if |index| is valid; otherwise | 466 // be deleted. This method returns true if |index| is valid; otherwise |
| 472 // it will return false and the ListValue object will be unchanged. | 467 // it will return false and the ListValue object will be unchanged. |
| 473 bool Remove(size_t index, Value** out_value); | 468 bool Remove(size_t index, Value** out_value); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // This method deserializes the subclass-specific format into a Value object. | 509 // This method deserializes the subclass-specific format into a Value object. |
| 515 // If the return value is non-NULL, the caller takes ownership of returned | 510 // If the return value is non-NULL, the caller takes ownership of returned |
| 516 // Value. If the return value is NULL, and if error_code is non-NULL, | 511 // Value. If the return value is NULL, and if error_code is non-NULL, |
| 517 // error_code will be set with the underlying error. | 512 // error_code will be set with the underlying error. |
| 518 // If |error_message| is non-null, it will be filled in with a formatted | 513 // If |error_message| is non-null, it will be filled in with a formatted |
| 519 // error message including the location of the error if appropriate. | 514 // error message including the location of the error if appropriate. |
| 520 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 515 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
| 521 }; | 516 }; |
| 522 | 517 |
| 523 #endif // BASE_VALUES_H_ | 518 #endif // BASE_VALUES_H_ |
| OLD | NEW |