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 #ifndef CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ | 5 #ifndef CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ |
6 #define CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ | 6 #define CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 ~JSONStringValueSerializer(); | 33 ~JSONStringValueSerializer(); |
34 | 34 |
35 // Attempt to serialize the data structure represented by Value into | 35 // Attempt to serialize the data structure represented by Value into |
36 // JSON. If the return value is true, the result will have been written | 36 // JSON. If the return value is true, the result will have been written |
37 // into the string passed into the constructor. | 37 // into the string passed into the constructor. |
38 bool Serialize(const Value& root); | 38 bool Serialize(const Value& root); |
39 | 39 |
40 // Attempt to deserialize the data structure encoded in the string passed | 40 // Attempt to deserialize the data structure encoded in the string passed |
41 // in to the constructor into a structure of Value objects. If the return | 41 // in to the constructor into a structure of Value objects. If the return |
42 // value is NULL and |error_message| is non-null, |error-message| will contain | 42 // value is NULL and |error_message| is non-null, |error_message| will contain |
43 // a string describing the error. | 43 // a string describing the error. |
44 Value* Deserialize(std::string* error_message); | 44 Value* Deserialize(std::string* error_message); |
45 | 45 |
46 void set_pretty_print(bool new_value) { pretty_print_ = new_value; } | 46 void set_pretty_print(bool new_value) { pretty_print_ = new_value; } |
47 bool pretty_print() { return pretty_print_; } | 47 bool pretty_print() { return pretty_print_; } |
48 | 48 |
49 void set_allow_trailing_comma(bool new_value) { | 49 void set_allow_trailing_comma(bool new_value) { |
50 allow_trailing_comma_ = new_value; | 50 allow_trailing_comma_ = new_value; |
51 } | 51 } |
52 | 52 |
(...skipping 24 matching lines...) Expand all Loading... |
77 // the file thread. | 77 // the file thread. |
78 // | 78 // |
79 // Attempt to serialize the data structure represented by Value into | 79 // Attempt to serialize the data structure represented by Value into |
80 // JSON. If the return value is true, the result will have been written | 80 // JSON. If the return value is true, the result will have been written |
81 // into the file whose name was passed into the constructor. | 81 // into the file whose name was passed into the constructor. |
82 bool Serialize(const Value& root); | 82 bool Serialize(const Value& root); |
83 | 83 |
84 // Attempt to deserialize the data structure encoded in the file passed | 84 // Attempt to deserialize the data structure encoded in the file passed |
85 // in to the constructor into a structure of Value objects. If the return | 85 // in to the constructor into a structure of Value objects. If the return |
86 // value is NULL, and if |error_message| is non-null, |error_message| will | 86 // value is NULL, and if |error_message| is non-null, |error_message| will |
87 // contain a string describing the error. | 87 // contain a string describing the error. The caller takes ownership of the |
| 88 // returned value. |
88 Value* Deserialize(std::string* error_message); | 89 Value* Deserialize(std::string* error_message); |
89 | 90 |
90 private: | 91 private: |
91 std::wstring json_file_path_; | 92 std::wstring json_file_path_; |
92 | 93 |
93 DISALLOW_EVIL_CONSTRUCTORS(JSONFileValueSerializer); | 94 DISALLOW_EVIL_CONSTRUCTORS(JSONFileValueSerializer); |
94 }; | 95 }; |
95 | 96 |
96 #endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ | 97 #endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ |
97 | 98 |
OLD | NEW |