| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // NextChar. The conversion from byte to JSON token happens without advancing | 33 // NextChar. The conversion from byte to JSON token happens without advancing |
| 34 // the parser in GetNextToken/ParseToken, that is tokenization operates on | 34 // the parser in GetNextToken/ParseToken, that is tokenization operates on |
| 35 // the current parser position without advancing. | 35 // the current parser position without advancing. |
| 36 // | 36 // |
| 37 // Built on top of these are a family of Consume functions that iterate | 37 // Built on top of these are a family of Consume functions that iterate |
| 38 // internally. Invariant: on entry of a Consume function, the parser is wound | 38 // internally. Invariant: on entry of a Consume function, the parser is wound |
| 39 // to the first byte of a valid JSON token. On exit, it is on the last byte | 39 // to the first byte of a valid JSON token. On exit, it is on the last byte |
| 40 // of a token, such that the next iteration of the parser will be at the byte | 40 // of a token, such that the next iteration of the parser will be at the byte |
| 41 // immediately following the token, which would likely be the first byte of the | 41 // immediately following the token, which would likely be the first byte of the |
| 42 // next token. | 42 // next token. |
| 43 class BASE_EXPORT_PRIVATE JSONParser { | 43 class BASE_EXPORT JSONParser { |
| 44 public: | 44 public: |
| 45 explicit JSONParser(int options); | 45 explicit JSONParser(int options); |
| 46 ~JSONParser(); | 46 ~JSONParser(); |
| 47 | 47 |
| 48 // Parses the input string according to the set options and returns the | 48 // Parses the input string according to the set options and returns the |
| 49 // result as a Value owned by the caller. | 49 // result as a Value owned by the caller. |
| 50 Value* Parse(const StringPiece& input); | 50 Value* Parse(const StringPiece& input); |
| 51 | 51 |
| 52 // Returns the error code. | 52 // Returns the error code. |
| 53 JSONReader::JsonParseError error_code() const; | 53 JSONReader::JsonParseError error_code() const; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ConsumeNumbers); | 245 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ConsumeNumbers); |
| 246 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ErrorMessages); | 246 FRIEND_TEST_ALL_PREFIXES(JSONParserTest, ErrorMessages); |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(JSONParser); | 248 DISALLOW_COPY_AND_ASSIGN(JSONParser); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 } // namespace internal | 251 } // namespace internal |
| 252 } // namespace base | 252 } // namespace base |
| 253 | 253 |
| 254 #endif // BASE_JSON_JSON_PARSER_H_ | 254 #endif // BASE_JSON_JSON_PARSER_H_ |
| OLD | NEW |