chromium/base/json/json_parser.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#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 {

// Values 1000 and above are used by JSONFileValueSerializer::JsonFileError.
static_assert;

std::string ErrorCodeToString(JSONParser::JsonParseError error_code) {}

const int32_t kExtendedASCIIStart =;
constexpr base_icu::UChar32 kUnicodeReplacementPoint =;

// UnprefixedHexStringToInt acts like |HexStringToInt|, but enforces that the
// input consists purely of hex digits. I.e. no "0x" nor "OX" prefix is
// permitted.
bool UnprefixedHexStringToInt(std::string_view input, int* output) {}

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class ChromiumJsonExtension {};

const char kExtensionHistogramName[] =;

}  // namespace

// This is U+FFFD.
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 {}

// JSONParser private //////////////////////////////////////////////////////////

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() {}

// Entry is at the first X in \uXXXX.
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) {}

// static
std::string JSONParser::FormatErrorMessage(int line, int column,
                                           const std::string& description) {}

}  // namespace internal
}  // namespace base