#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/json/json_parser.h"
#include <cmath>
#include <iterator>
#include <string_view>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/features.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
#include "base/third_party/icu/icu_utf.h"
namespace base {
namespace internal {
namespace {
static_assert …;
std::string ErrorCodeToString(JSONParser::JsonParseError error_code) { … }
const int32_t kExtendedASCIIStart = …;
constexpr base_icu::UChar32 kUnicodeReplacementPoint = …;
bool UnprefixedHexStringToInt(std::string_view input, int* output) { … }
enum class ChromiumJsonExtension { … };
const char kExtensionHistogramName[] = …;
}
const char kUnicodeReplacementString[] = …;
const char JSONParser::kSyntaxError[] = …;
const char JSONParser::kInvalidEscape[] = …;
const char JSONParser::kUnexpectedToken[] = …;
const char JSONParser::kTrailingComma[] = …;
const char JSONParser::kTooMuchNesting[] = …;
const char JSONParser::kUnexpectedDataAfterRoot[] = …;
const char JSONParser::kUnsupportedEncoding[] = …;
const char JSONParser::kUnquotedDictionaryKey[] = …;
const char JSONParser::kUnrepresentableNumber[] = …;
JSONParser::JSONParser(int options, size_t max_depth)
: … { … }
JSONParser::~JSONParser() = default;
std::optional<Value> JSONParser::Parse(std::string_view input) { … }
JSONParser::JsonParseError JSONParser::error_code() const { … }
std::string JSONParser::GetErrorMessage() const { … }
int JSONParser::error_line() const { … }
int JSONParser::error_column() const { … }
std::optional<std::string_view> JSONParser::PeekChars(size_t count) { … }
std::optional<char> JSONParser::PeekChar() { … }
std::optional<std::string_view> JSONParser::ConsumeChars(size_t count) { … }
std::optional<char> JSONParser::ConsumeChar() { … }
const char* JSONParser::pos() { … }
JSONParser::Token JSONParser::GetNextToken() { … }
void JSONParser::EatWhitespaceAndComments() { … }
bool JSONParser::EatComment() { … }
std::optional<Value> JSONParser::ParseNextToken() { … }
std::optional<Value> JSONParser::ParseToken(Token token) { … }
std::optional<Value> JSONParser::ConsumeDictionary() { … }
std::optional<Value> JSONParser::ConsumeList() { … }
std::optional<Value> JSONParser::ConsumeString() { … }
std::optional<std::string> JSONParser::ConsumeStringRaw() { … }
std::pair<JSONParser::StringResult, std::string_view>
JSONParser::ConsumeStringPart() { … }
bool JSONParser::DecodeUTF16(base_icu::UChar32* out_code_point) { … }
std::optional<Value> JSONParser::ConsumeNumber() { … }
bool JSONParser::ReadInt(bool allow_leading_zeros) { … }
std::optional<Value> JSONParser::ConsumeLiteral() { … }
bool JSONParser::ConsumeIfMatch(std::string_view match) { … }
void JSONParser::ReportError(JsonParseError code, int column_adjust) { … }
std::string JSONParser::FormatErrorMessage(int line, int column,
const std::string& description) { … }
}
}