| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class Value; | 24 class Value; |
| 25 | 25 |
| 26 namespace internal { | 26 namespace internal { |
| 27 | 27 |
| 28 class JSONParserTest; | 28 class JSONParserTest; |
| 29 | 29 |
| 30 // The implementation behind the JSONReader interface. This class is not meant | 30 // The implementation behind the JSONReader interface. This class is not meant |
| 31 // to be used directly; it encapsulates logic that need not be exposed publicly. | 31 // to be used directly; it encapsulates logic that need not be exposed publicly. |
| 32 // | 32 // |
| 33 // This parser guarantees O(n) time through the input string. It also optimizes | 33 // This parser guarantees O(n) time through the input string. It also optimizes |
| 34 // base::StringValue by using StringPiece where possible when returning Value | 34 // base::Value by using StringPiece where possible when returning Value |
| 35 // objects by using "hidden roots," discussed in the implementation. | 35 // objects by using "hidden roots," discussed in the implementation. |
| 36 // | 36 // |
| 37 // Iteration happens on the byte level, with the functions CanConsume and | 37 // Iteration happens on the byte level, with the functions CanConsume and |
| 38 // NextChar. The conversion from byte to JSON token happens without advancing | 38 // NextChar. The conversion from byte to JSON token happens without advancing |
| 39 // the parser in GetNextToken/ParseToken, that is tokenization operates on | 39 // the parser in GetNextToken/ParseToken, that is tokenization operates on |
| 40 // the current parser position without advancing. | 40 // the current parser position without advancing. |
| 41 // | 41 // |
| 42 // Built on top of these are a family of Consume functions that iterate | 42 // Built on top of these are a family of Consume functions that iterate |
| 43 // internally. Invariant: on entry of a Consume function, the parser is wound | 43 // internally. Invariant: on entry of a Consume function, the parser is wound |
| 44 // to the first byte of a valid JSON token. On exit, it is on the last byte | 44 // to the first byte of a valid JSON token. On exit, it is on the last byte |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 DISALLOW_COPY_AND_ASSIGN(JSONParser); | 264 DISALLOW_COPY_AND_ASSIGN(JSONParser); |
| 265 }; | 265 }; |
| 266 | 266 |
| 267 // Used when decoding and an invalid utf-8 sequence is encountered. | 267 // Used when decoding and an invalid utf-8 sequence is encountered. |
| 268 BASE_EXPORT extern const char kUnicodeReplacementString[]; | 268 BASE_EXPORT extern const char kUnicodeReplacementString[]; |
| 269 | 269 |
| 270 } // namespace internal | 270 } // namespace internal |
| 271 } // namespace base | 271 } // namespace base |
| 272 | 272 |
| 273 #endif // BASE_JSON_JSON_PARSER_H_ | 273 #endif // BASE_JSON_JSON_PARSER_H_ |
| OLD | NEW |