| 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 23 matching lines...) Expand all Loading... |
| 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 true, the |root| parameter will be set to point to a new Value | 42 // value is true, the |root| parameter will be set to point to a new Value |
| 43 // object that corresponds to the values represented in the string. The | 43 // object that corresponds to the values represented in the string. The |
| 44 // caller takes ownership of the returned Value objects. | 44 // caller takes ownership of the returned Value objects. Otherwise, the root |
| 45 bool Deserialize(Value** root); | 45 // value will be changed and if |error_message| is non-null, it will contain |
| 46 // a string describing the error. |
| 47 bool Deserialize(Value** root, std::string* error_message); |
| 46 | 48 |
| 47 void set_pretty_print(bool new_value) { pretty_print_ = new_value; } | 49 void set_pretty_print(bool new_value) { pretty_print_ = new_value; } |
| 48 bool pretty_print() { return pretty_print_; } | 50 bool pretty_print() { return pretty_print_; } |
| 49 | 51 |
| 50 void set_allow_trailing_comma(bool new_value) { | 52 void set_allow_trailing_comma(bool new_value) { |
| 51 allow_trailing_comma_ = new_value; | 53 allow_trailing_comma_ = new_value; |
| 52 } | 54 } |
| 53 | 55 |
| 54 private: | 56 private: |
| 55 std::string* json_string_; | 57 std::string* json_string_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 79 // | 81 // |
| 80 // Attempt to serialize the data structure represented by Value into | 82 // Attempt to serialize the data structure represented by Value into |
| 81 // JSON. If the return value is true, the result will have been written | 83 // JSON. If the return value is true, the result will have been written |
| 82 // into the file whose name was passed into the constructor. | 84 // into the file whose name was passed into the constructor. |
| 83 bool Serialize(const Value& root); | 85 bool Serialize(const Value& root); |
| 84 | 86 |
| 85 // Attempt to deserialize the data structure encoded in the file passed | 87 // Attempt to deserialize the data structure encoded in the file passed |
| 86 // in to the constructor into a structure of Value objects. If the return | 88 // in to the constructor into a structure of Value objects. If the return |
| 87 // value is true, the |root| parameter will be set to point to a new Value | 89 // value is true, the |root| parameter will be set to point to a new Value |
| 88 // object that corresponds to the values represented in the file. The | 90 // object that corresponds to the values represented in the file. The |
| 89 // caller takes ownership of the returned Value objects. | 91 // caller takes ownership of the returned Value objects. Otherwise, the root |
| 90 bool Deserialize(Value** root); | 92 // value will be changed and if |error_message| is non-null, it will contain |
| 93 // a string describing the error. |
| 94 bool Deserialize(Value** root, std::string* error_message); |
| 91 | 95 |
| 92 private: | 96 private: |
| 93 std::wstring json_file_path_; | 97 std::wstring json_file_path_; |
| 94 | 98 |
| 95 DISALLOW_EVIL_CONSTRUCTORS(JSONFileValueSerializer); | 99 DISALLOW_EVIL_CONSTRUCTORS(JSONFileValueSerializer); |
| 96 }; | 100 }; |
| 97 | 101 |
| 98 #endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ | 102 #endif // CHROME_COMMON_JSON_VALUE_SERIALIZER_H__ |
| 99 | 103 |
| OLD | NEW |