29 #ifndef CPL_JSON_STREAMIN_PARSER_H
30 #define CPL_JSON_STREAMIN_PARSER_H
34 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
40 class CPL_DLL CPLJSonStreamingParser
54 bool m_bExceptionOccurred;
59 std::vector<State> m_aState;
60 std::string m_osToken;
61 std::vector<bool> m_abFirstElement;
62 bool m_bInStringEscape;
64 std::string m_osUnicodeHex;
66 size_t m_nMaxStringSize;
75 std::vector<MemberState> m_aeObjectState;
77 enum State currentState() {
return m_aState.back(); }
78 void SkipSpace(
const char*& pStr,
size_t& nLength);
79 void AdvanceChar(
const char*& pStr,
size_t& nLength);
80 bool EmitException(
const char* pszMessage);
81 bool EmitUnexpectedChar(
char ch);
82 bool StartNewToken(
const char*& pStr,
size_t& nLength);
83 bool CheckAndEmitTrueFalseOrNull(
char ch);
84 bool CheckStackEmpty();
88 CPLJSonStreamingParser();
89 virtual ~CPLJSonStreamingParser();
91 void SetMaxDepth(
size_t nVal);
92 void SetMaxStringSize(
size_t nVal);
93 bool ExceptionOccurred()
const {
return m_bExceptionOccurred; }
95 static std::string GetSerializedString(
const char* pszStr);
98 virtual bool Parse(
const char* pStr,
size_t nLength,
bool bFinished);
100 virtual void String(
const char* ,
size_t ) {}
101 virtual void Number(
const char* ,
size_t ) {}
102 virtual void Boolean(
bool ) {}
103 virtual void Null() {}
105 virtual void StartObject() {}
106 virtual void EndObject() {}
107 virtual void StartObjectMember(
const char* ,
size_t ) {}
109 virtual void StartArray() {}
110 virtual void EndArray() {}
111 virtual void StartArrayMember() {}
113 virtual void Exception(
const char* ) {}
116 #endif // __cplusplus
120 #endif // CPL_JSON_STREAMIN_PARSER_H