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