OLD | NEW |
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 #ifndef BASE_JSON_JSON_PARSER_H_ | 5 #ifndef BASE_JSON_JSON_PARSER_H_ |
6 #define BASE_JSON_JSON_PARSER_H_ | 6 #define BASE_JSON_JSON_PARSER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/base_export.h" | 14 #include "base/base_export.h" |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
(...skipping 22 matching lines...) Expand all Loading... |
43 // of a token, such that the next iteration of the parser will be at the byte | 44 // of a token, such that the next iteration of the parser will be at the byte |
44 // immediately following the token, which would likely be the first byte of the | 45 // immediately following the token, which would likely be the first byte of the |
45 // next token. | 46 // next token. |
46 class BASE_EXPORT JSONParser { | 47 class BASE_EXPORT JSONParser { |
47 public: | 48 public: |
48 explicit JSONParser(int options); | 49 explicit JSONParser(int options); |
49 ~JSONParser(); | 50 ~JSONParser(); |
50 | 51 |
51 // Parses the input string according to the set options and returns the | 52 // Parses the input string according to the set options and returns the |
52 // result as a Value owned by the caller. | 53 // result as a Value owned by the caller. |
53 Value* Parse(const StringPiece& input); | 54 std::unique_ptr<Value> Parse(StringPiece input); |
54 | 55 |
55 // Returns the error code. | 56 // Returns the error code. |
56 JSONReader::JsonParseError error_code() const; | 57 JSONReader::JsonParseError error_code() const; |
57 | 58 |
58 // Returns the human-friendly error message. | 59 // Returns the human-friendly error message. |
59 std::string GetErrorMessage() const; | 60 std::string GetErrorMessage() const; |
60 | 61 |
61 // Returns the error line number if parse error happened. Otherwise always | 62 // Returns the error line number if parse error happened. Otherwise always |
62 // returns 0. | 63 // returns 0. |
63 int error_line() const; | 64 int error_line() const; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ConsumeNumbers); | 257 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ConsumeNumbers); |
257 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ErrorMessages); | 258 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ErrorMessages); |
258 | 259 |
259 DISALLOW_COPY_AND_ASSIGN(JSONParser); | 260 DISALLOW_COPY_AND_ASSIGN(JSONParser); |
260 }; | 261 }; |
261 | 262 |
262 } // namespace internal | 263 } // namespace internal |
263 } // namespace base | 264 } // namespace base |
264 | 265 |
265 #endif // BASE_JSON_JSON_PARSER_H_ | 266 #endif // BASE_JSON_JSON_PARSER_H_ |
OLD | NEW |