| 55 | }; |
| 56 | |
| 57 | inline const char* ErrorMsg(SonicError error) noexcept { |
| 58 | struct SonicErrorInfo { |
| 59 | SonicError err; |
| 60 | const char* msg; |
| 61 | }; |
| 62 | static const SonicErrorInfo kErrorMsg[kErrorNums] = { |
| 63 | {kErrorNone, "No errors"}, |
| 64 | {kParseErrorEof, "Parse: JSON is empty or truncated."}, |
| 65 | {kParseErrorInvalidChar, "Parse: JSON has invalid chars, e.g. 1.2x."}, |
| 66 | {kParseErrorInfinity, "Parse: JSON number is infinity."}, |
| 67 | {kParseErrorUnEscaped, |
| 68 | "Parse: JSON string has unescaped control chars (\\x00 ~ \\x1f)."}, |
| 69 | {kParseErrorEscapedFormat, |
| 70 | "Parse: JSON string has wrong escaped format, e.g.\"\\g\""}, |
| 71 | {kParseErrorEscapedUnicode, |
| 72 | "Parse: JSON string has wrong escaped unicode, e.g. \"\\uD800\""}, |
| 73 | {kParseErrorInvalidUTF8, |
| 74 | "Parse: JSON string has wrong escaped unicode, e.g. \"\\xff\\xff\""}, |
| 75 | {kParseErrorUnknownObjKey, |
| 76 | "ParseOnDemand: Not found the target keys in object."}, |
| 77 | {kParseErrorArrIndexOutOfRange, |
| 78 | "ParseOnDemand: the target array index out of range."}, |
| 79 | {kParseErrorMismatchType, |
| 80 | "ParseOnDemand: the target type is not matched."}, |
| 81 | {kSerErrorUnsupportedType, "Serialize: DOM has invalid node type."}, |
| 82 | {kSerErrorInfinity, "Serialize: DOM has inifinity number node."}, |
| 83 | {kSerErrorInvalidObjKey, |
| 84 | "Serialize: The type of object's key is not string."}, |
| 85 | {kErrorNoMem, "Memory is not enough to allocate."}, |
| 86 | {kParseErrorUnexpect, "Unexpected Errors"}, |
| 87 | }; |
| 88 | return kErrorMsg[error].msg; |
| 89 | } |
| 90 | |
| 91 | struct ParseResult { |
| 92 | public: |
no outgoing calls