cesium-native 0.43.0
Loading...
Searching...
No Matches
Log.h
1#pragma once
2#include <rapidjson/document.h>
3#include <spdlog/fmt/fmt.h>
4
6template <>
7struct fmt::formatter<rapidjson::ParseErrorCode> : formatter<string_view> {
8 // parse is inherited from formatter<string_view>.
9
10 auto format(rapidjson::ParseErrorCode code, format_context& ctx) const {
11 string_view name = "unknown";
12 switch (code) {
13 case rapidjson::ParseErrorCode::kParseErrorNone:
14 name = "No error.";
15 break;
16 case rapidjson::ParseErrorCode::kParseErrorDocumentEmpty:
17 name = "The document is empty.";
18 break;
19 case rapidjson::ParseErrorCode::kParseErrorDocumentRootNotSingular:
20 name = "The document root must not follow by other values.";
21 break;
22 case rapidjson::ParseErrorCode::kParseErrorValueInvalid:
23 name = "Invalid value.";
24 break;
25 case rapidjson::ParseErrorCode::kParseErrorObjectMissName:
26 name = "Missing a name for object member.";
27 break;
28 case rapidjson::ParseErrorCode::kParseErrorObjectMissColon:
29 name = "Missing a colon after a name of object member.";
30 break;
31 case rapidjson::ParseErrorCode::kParseErrorObjectMissCommaOrCurlyBracket:
32 name = "Missing a comma or '}' after an object member.";
33 break;
34 case rapidjson::ParseErrorCode::kParseErrorArrayMissCommaOrSquareBracket:
35 name = "Missing a comma or ']' after an array element.";
36 break;
37 case rapidjson::ParseErrorCode::kParseErrorStringUnicodeEscapeInvalidHex:
38 name = "Incorrect hex digit after \\u escape in string.";
39 break;
40 case rapidjson::ParseErrorCode::kParseErrorStringUnicodeSurrogateInvalid:
41 name = "The surrogate pair in string is invalid.";
42 break;
43 case rapidjson::ParseErrorCode::kParseErrorStringEscapeInvalid:
44 name = "Invalid escape character in string.";
45 break;
46 case rapidjson::ParseErrorCode::kParseErrorStringMissQuotationMark:
47 name = "Missing a closing quotation mark in string.";
48 break;
49 case rapidjson::ParseErrorCode::kParseErrorStringInvalidEncoding:
50 name = "Invalid encoding in string.";
51 break;
52 case rapidjson::ParseErrorCode::kParseErrorNumberTooBig:
53 name = "Number too big to be stored in double.";
54 break;
55 case rapidjson::ParseErrorCode::kParseErrorNumberMissFraction:
56 name = "Miss fraction part in number.";
57 break;
58 case rapidjson::ParseErrorCode::kParseErrorNumberMissExponent:
59 name = "Miss exponent in number.";
60 break;
61 case rapidjson::ParseErrorCode::kParseErrorTermination:
62 name = "Parsing was terminated.";
63 break;
64 case rapidjson::ParseErrorCode::kParseErrorUnspecificSyntaxError:
65 name = "Unspecific syntax error.";
66 break;
67 default:
68 break;
69 }
70 return formatter<string_view>::format(name, ctx);
71 }
72};