diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/base/json/json_reader.h | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/base/json/json_reader.h')
-rw-r--r-- | chromium/base/json/json_reader.h | 73 |
1 files changed, 4 insertions, 69 deletions
diff --git a/chromium/base/json/json_reader.h b/chromium/base/json/json_reader.h index 511fffe32e7..007f843d736 100644 --- a/chromium/base/json/json_reader.h +++ b/chromium/base/json/json_reader.h @@ -49,10 +49,6 @@ namespace base { -namespace internal { -class JSONParser; -} - enum JSONParserOptions { // Parses the input strictly according to RFC 8259, except for where noted // above. @@ -70,22 +66,6 @@ enum JSONParserOptions { class BASE_EXPORT JSONReader { public: - // Error codes during parsing. - enum JsonParseError { - JSON_NO_ERROR = 0, - JSON_INVALID_ESCAPE, - JSON_SYNTAX_ERROR, - JSON_UNEXPECTED_TOKEN, - JSON_TRAILING_COMMA, - JSON_TOO_MUCH_NESTING, - JSON_UNEXPECTED_DATA_AFTER_ROOT, - JSON_UNSUPPORTED_ENCODING, - JSON_UNQUOTED_DICTIONARY_KEY, - JSON_TOO_LARGE, - JSON_UNREPRESENTABLE_NUMBER, - JSON_PARSE_ERROR_COUNT - }; - struct BASE_EXPORT ValueWithError { ValueWithError(); ValueWithError(ValueWithError&& other); @@ -96,7 +76,7 @@ class BASE_EXPORT JSONReader { // Contains default values if |value| exists, or the error status if |value| // is base::nullopt. - JsonParseError error_code = JSON_NO_ERROR; + int error_code = ValueDeserializer::kErrorCodeNoError; std::string error_message; int error_line = 0; int error_column = 0; @@ -104,24 +84,6 @@ class BASE_EXPORT JSONReader { DISALLOW_COPY_AND_ASSIGN(ValueWithError); }; - // String versions of parse error codes. - static const char kInvalidEscape[]; - static const char kSyntaxError[]; - static const char kUnexpectedToken[]; - static const char kTrailingComma[]; - static const char kTooMuchNesting[]; - static const char kUnexpectedDataAfterRoot[]; - static const char kUnsupportedEncoding[]; - static const char kUnquotedDictionaryKey[]; - static const char kInputTooLarge[]; - static const char kUnrepresentableNumber[]; - - // Constructs a reader. - JSONReader(int options = JSON_PARSE_RFC, - size_t max_depth = internal::kAbsoluteMaxDepth); - - ~JSONReader(); - // Reads and parses |json|, returning a Value. // If |json| is not a properly formed JSON string, returns base::nullopt. static Optional<Value> Read(StringPiece json, @@ -145,36 +107,9 @@ class BASE_EXPORT JSONReader { StringPiece json, int options = JSON_PARSE_RFC); - // Deprecated. Use the ReadAndReturnValueWithError() method above. - // Reads and parses |json| like Read(). |error_code_out| and |error_msg_out| - // are optional. If specified and nullptr is returned, they will be populated - // an error code and a formatted error message (including error location if - // appropriate). Otherwise, they will be unmodified. - static std::unique_ptr<Value> ReadAndReturnErrorDeprecated( - StringPiece json, - int options, // JSONParserOptions - int* error_code_out, - std::string* error_msg_out, - int* error_line_out = nullptr, - int* error_column_out = nullptr); - - // Converts a JSON parse error code into a human readable message. - // Returns an empty string if error_code is JSON_NO_ERROR. - static std::string ErrorCodeToString(JsonParseError error_code); - - // Non-static version of Read() above. - Optional<Value> ReadToValue(StringPiece json); - - // Deprecated. Use the ReadToValue() method above. - // Non-static version of Read() above. - std::unique_ptr<Value> ReadToValueDeprecated(StringPiece json); - - // Converts error_code_ to a human-readable string, including line and column - // numbers if appropriate. - std::string GetErrorMessage() const; - - private: - std::unique_ptr<internal::JSONParser> parser_; + // This class contains only static methods. + JSONReader() = delete; + DISALLOW_COPY_AND_ASSIGN(JSONReader); }; } // namespace base |