| 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 12 matching lines...) Expand all Loading... |
| 23 #pragma once | 23 #pragma once |
| 24 | 24 |
| 25 #include <iterator> | 25 #include <iterator> |
| 26 #include <map> | 26 #include <map> |
| 27 #include <string> | 27 #include <string> |
| 28 #include <vector> | 28 #include <vector> |
| 29 | 29 |
| 30 #include "base/base_api.h" | 30 #include "base/base_api.h" |
| 31 #include "base/basictypes.h" | 31 #include "base/basictypes.h" |
| 32 #include "base/string16.h" | 32 #include "base/string16.h" |
| 33 #include "build/build_config.h" | |
| 34 | 33 |
| 35 // This file declares "using base::Value", etc. at the bottom, so that | 34 // This file declares "using base::Value", etc. at the bottom, so that |
| 36 // current code can use these classes without the base namespace. In | 35 // current code can use these classes without the base namespace. In |
| 37 // new code, please always use base::Value, etc. or add your own | 36 // new code, please always use base::Value, etc. or add your own |
| 38 // "using" declaration. | 37 // "using" declaration. |
| 39 // http://crbug.com/88666 | 38 // http://crbug.com/88666 |
| 40 namespace base { | 39 namespace base { |
| 41 | 40 |
| 42 class BinaryValue; | 41 class BinaryValue; |
| 43 class DictionaryValue; | 42 class DictionaryValue; |
| 44 class FundamentalValue; | 43 class FundamentalValue; |
| 45 class ListValue; | 44 class ListValue; |
| 46 class StringValue; | 45 class StringValue; |
| 47 class Value; | 46 class Value; |
| 48 | 47 |
| 49 typedef std::vector<Value*> ValueVector; | 48 typedef std::vector<Value*> ValueVector; |
| 50 typedef std::map<std::string, Value*> ValueMap; | 49 typedef std::map<std::string, Value*> ValueMap; |
| 51 | 50 |
| 52 // The Value class is the base class for Values. A Value can be | 51 // The Value class is the base class for Values. A Value can be instantiated |
| 53 // instantiated via the Create*Value() factory methods, or by directly | 52 // via the Create*Value() factory methods, or by directly creating instances of |
| 54 // creating instances of the subclasses. | 53 // the subclasses. |
| 55 class BASE_API Value { | 54 class BASE_API Value { |
| 56 public: | 55 public: |
| 57 enum ValueType { | 56 enum ValueType { |
| 58 TYPE_NULL = 0, | 57 TYPE_NULL = 0, |
| 59 TYPE_BOOLEAN, | 58 TYPE_BOOLEAN, |
| 60 TYPE_INTEGER, | 59 TYPE_INTEGER, |
| 61 TYPE_DOUBLE, | 60 TYPE_DOUBLE, |
| 62 TYPE_STRING, | 61 TYPE_STRING, |
| 63 TYPE_BINARY, | 62 TYPE_BINARY, |
| 64 TYPE_DICTIONARY, | 63 TYPE_DICTIONARY, |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 // 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, |
| 459 // error_code will be set with the underlying error. | 458 // error_code will be set with the underlying error. |
| 460 // 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 |
| 461 // error message including the location of the error if appropriate. | 460 // error message including the location of the error if appropriate. |
| 462 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; | 461 virtual Value* Deserialize(int* error_code, std::string* error_str) = 0; |
| 463 }; | 462 }; |
| 464 | 463 |
| 465 } // namespace base | 464 } // namespace base |
| 466 | 465 |
| 467 // http://crbug.com/88666 | 466 // http://crbug.com/88666 |
| 468 using base::BinaryValue; | |
| 469 using base::DictionaryValue; | 467 using base::DictionaryValue; |
| 470 using base::FundamentalValue; | 468 using base::FundamentalValue; |
| 471 using base::ListValue; | 469 using base::ListValue; |
| 472 using base::StringValue; | 470 using base::StringValue; |
| 473 using base::Value; | 471 using base::Value; |
| 474 | 472 |
| 475 #endif // BASE_VALUES_H_ | 473 #endif // BASE_VALUES_H_ |
| OLD | NEW |