2#include <rapidjson/document.h>
3#include <spdlog/fmt/fmt.h>
7struct fmt::formatter<rapidjson::ParseErrorCode> : formatter<string_view> {
10 auto format(rapidjson::ParseErrorCode code, format_context& ctx)
const {
11 string_view name =
"unknown";
13 case rapidjson::ParseErrorCode::kParseErrorNone:
16 case rapidjson::ParseErrorCode::kParseErrorDocumentEmpty:
17 name =
"The document is empty.";
19 case rapidjson::ParseErrorCode::kParseErrorDocumentRootNotSingular:
20 name =
"The document root must not follow by other values.";
22 case rapidjson::ParseErrorCode::kParseErrorValueInvalid:
23 name =
"Invalid value.";
25 case rapidjson::ParseErrorCode::kParseErrorObjectMissName:
26 name =
"Missing a name for object member.";
28 case rapidjson::ParseErrorCode::kParseErrorObjectMissColon:
29 name =
"Missing a colon after a name of object member.";
31 case rapidjson::ParseErrorCode::kParseErrorObjectMissCommaOrCurlyBracket:
32 name =
"Missing a comma or '}' after an object member.";
34 case rapidjson::ParseErrorCode::kParseErrorArrayMissCommaOrSquareBracket:
35 name =
"Missing a comma or ']' after an array element.";
37 case rapidjson::ParseErrorCode::kParseErrorStringUnicodeEscapeInvalidHex:
38 name =
"Incorrect hex digit after \\u escape in string.";
40 case rapidjson::ParseErrorCode::kParseErrorStringUnicodeSurrogateInvalid:
41 name =
"The surrogate pair in string is invalid.";
43 case rapidjson::ParseErrorCode::kParseErrorStringEscapeInvalid:
44 name =
"Invalid escape character in string.";
46 case rapidjson::ParseErrorCode::kParseErrorStringMissQuotationMark:
47 name =
"Missing a closing quotation mark in string.";
49 case rapidjson::ParseErrorCode::kParseErrorStringInvalidEncoding:
50 name =
"Invalid encoding in string.";
52 case rapidjson::ParseErrorCode::kParseErrorNumberTooBig:
53 name =
"Number too big to be stored in double.";
55 case rapidjson::ParseErrorCode::kParseErrorNumberMissFraction:
56 name =
"Miss fraction part in number.";
58 case rapidjson::ParseErrorCode::kParseErrorNumberMissExponent:
59 name =
"Miss exponent in number.";
61 case rapidjson::ParseErrorCode::kParseErrorTermination:
62 name =
"Parsing was terminated.";
64 case rapidjson::ParseErrorCode::kParseErrorUnspecificSyntaxError:
65 name =
"Unspecific syntax error.";
70 return formatter<string_view>::format(name, ctx);