Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: base/json/json_reader.h

Issue 1124223012: Change JSONReader::ReadToValue to return a scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromedriver Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/json/json_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // A JSON parser. Converts strings of JSON into a Value object (see 5 // A JSON parser. Converts strings of JSON into a Value object (see
6 // base/values.h). 6 // base/values.h).
7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627
8 // 8 //
9 // Known limitations/deviations from the RFC: 9 // Known limitations/deviations from the RFC:
10 // - Only knows how to parse ints within the range of a signed 32 bit int and 10 // - Only knows how to parse ints within the range of a signed 32 bit int and
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 static Value* ReadAndReturnError(const StringPiece& json, 108 static Value* ReadAndReturnError(const StringPiece& json,
109 int options, // JSONParserOptions 109 int options, // JSONParserOptions
110 int* error_code_out, 110 int* error_code_out,
111 std::string* error_msg_out); 111 std::string* error_msg_out);
112 112
113 // Converts a JSON parse error code into a human readable message. 113 // Converts a JSON parse error code into a human readable message.
114 // Returns an empty string if error_code is JSON_NO_ERROR. 114 // Returns an empty string if error_code is JSON_NO_ERROR.
115 static std::string ErrorCodeToString(JsonParseError error_code); 115 static std::string ErrorCodeToString(JsonParseError error_code);
116 116
117 // Parses an input string into a Value that is owned by the caller. 117 // Parses an input string into a Value that is owned by the caller.
118 Value* ReadToValue(const std::string& json); 118 scoped_ptr<Value> ReadToValue(const std::string& json);
119 119
120 // Returns the error code if the last call to ReadToValue() failed. 120 // Returns the error code if the last call to ReadToValue() failed.
121 // Returns JSON_NO_ERROR otherwise. 121 // Returns JSON_NO_ERROR otherwise.
122 JsonParseError error_code() const; 122 JsonParseError error_code() const;
123 123
124 // Converts error_code_ to a human-readable string, including line and column 124 // Converts error_code_ to a human-readable string, including line and column
125 // numbers if appropriate. 125 // numbers if appropriate.
126 std::string GetErrorMessage() const; 126 std::string GetErrorMessage() const;
127 127
128 private: 128 private:
129 scoped_ptr<internal::JSONParser> parser_; 129 scoped_ptr<internal::JSONParser> parser_;
130 }; 130 };
131 131
132 } // namespace base 132 } // namespace base
133 133
134 #endif // BASE_JSON_JSON_READER_H_ 134 #endif // BASE_JSON_JSON_READER_H_
OLDNEW
« no previous file with comments | « no previous file | base/json/json_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698