// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_JSON_JSON_PARSER_H_ #define BASE_JSON_JSON_PARSER_H_ #include <stddef.h> #include <stdint.h> #include <memory> #include <optional> #include <string> #include <string_view> #include <utility> #include "base/base_export.h" #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/json/json_common.h" #include "base/third_party/icu/icu_utf.h" #include "base/values.h" namespace base { class Value; namespace internal { class JSONParserTest; // The implementation behind the JSONReader interface. This class is not meant // to be used directly; it encapsulates logic that need not be exposed publicly. // // This parser guarantees O(n) time through the input string. Iteration happens // on the byte level, with the functions ConsumeChars() and ConsumeChar(). The // conversion from byte to JSON token happens without advancing the parser in // GetNextToken/ParseToken, that is tokenization operates on the current parser // position without advancing. // // Built on top of these are a family of Consume functions that iterate // internally. Invariant: on entry of a Consume function, the parser is wound // to the first byte of a valid JSON token. On exit, it is on the first byte // after the token that was just consumed, which would likely be the first byte // of the next token. class BASE_EXPORT JSONParser { … }; // Used when decoding and an invalid utf-8 sequence is encountered. BASE_EXPORT extern const char kUnicodeReplacementString[]; } // namespace internal } // namespace base #endif // BASE_JSON_JSON_PARSER_H_