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

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

Issue 1571633002: Pass Manifest JSON paser error line and column number to console. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 4 years, 11 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 | « base/json/json_parser.cc ('k') | 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // returns NULL. 100 // returns NULL.
101 static scoped_ptr<Value> Read(const StringPiece& json, int options); 101 static scoped_ptr<Value> Read(const StringPiece& json, int options);
102 102
103 // Reads and parses |json| like Read(). |error_code_out| and |error_msg_out| 103 // Reads and parses |json| like Read(). |error_code_out| and |error_msg_out|
104 // are optional. If specified and NULL is returned, they will be populated 104 // are optional. If specified and NULL is returned, they will be populated
105 // an error code and a formatted error message (including error location if 105 // an error code and a formatted error message (including error location if
106 // appropriate). Otherwise, they will be unmodified. 106 // appropriate). Otherwise, they will be unmodified.
107 static scoped_ptr<Value> ReadAndReturnError(const StringPiece& json, 107 static scoped_ptr<Value> ReadAndReturnError(const StringPiece& json,
108 int options, // JSONParserOptions 108 int options, // JSONParserOptions
109 int* error_code_out, 109 int* error_code_out,
110 std::string* error_msg_out); 110 std::string* error_msg_out,
111 int* error_line_out = nullptr,
112 int* error_column_out = nullptr);
111 113
112 // Converts a JSON parse error code into a human readable message. 114 // Converts a JSON parse error code into a human readable message.
113 // Returns an empty string if error_code is JSON_NO_ERROR. 115 // Returns an empty string if error_code is JSON_NO_ERROR.
114 static std::string ErrorCodeToString(JsonParseError error_code); 116 static std::string ErrorCodeToString(JsonParseError error_code);
115 117
116 // Parses an input string into a Value that is owned by the caller. 118 // Parses an input string into a Value that is owned by the caller.
117 scoped_ptr<Value> ReadToValue(const std::string& json); 119 scoped_ptr<Value> ReadToValue(const std::string& json);
118 120
119 // Returns the error code if the last call to ReadToValue() failed. 121 // Returns the error code if the last call to ReadToValue() failed.
120 // Returns JSON_NO_ERROR otherwise. 122 // Returns JSON_NO_ERROR otherwise.
121 JsonParseError error_code() const; 123 JsonParseError error_code() const;
122 124
123 // Converts error_code_ to a human-readable string, including line and column 125 // Converts error_code_ to a human-readable string, including line and column
124 // numbers if appropriate. 126 // numbers if appropriate.
125 std::string GetErrorMessage() const; 127 std::string GetErrorMessage() const;
126 128
127 private: 129 private:
128 scoped_ptr<internal::JSONParser> parser_; 130 scoped_ptr<internal::JSONParser> parser_;
129 }; 131 };
130 132
131 } // namespace base 133 } // namespace base
132 134
133 #endif // BASE_JSON_JSON_READER_H_ 135 #endif // BASE_JSON_JSON_READER_H_
OLDNEW
« no previous file with comments | « base/json/json_parser.cc ('k') | base/json/json_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698