29#ifndef CPL_JSON_STREAMIN_PARSER_H
30#define CPL_JSON_STREAMIN_PARSER_H
34#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
40class CPL_DLL CPLJSonStreamingParser
56 bool m_bExceptionOccurred =
false;
57 bool m_bElementFound =
false;
59 int m_nLineCounter = 1;
60 int m_nCharCounter = 1;
61 std::vector<State> m_aState{};
62 std::string m_osToken{};
69 std::vector<ArrayState> m_abArrayState{};
70 bool m_bInStringEscape =
false;
71 bool m_bInUnicode =
false;
72 std::string m_osUnicodeHex{};
73 size_t m_nMaxDepth = 1024;
74 size_t m_nMaxStringSize = 10000000;
84 std::vector<MemberState> m_aeObjectState{};
86 enum State currentState()
88 return m_aState.back();
91 void SkipSpace(
const char *&pStr,
size_t &nLength);
92 void AdvanceChar(
const char *&pStr,
size_t &nLength);
93 bool EmitUnexpectedChar(
char ch,
const char *pszExpecting =
nullptr);
94 bool StartNewToken(
const char *&pStr,
size_t &nLength);
95 bool CheckAndEmitTrueFalseOrNull(
char ch);
96 bool CheckStackEmpty();
100 bool EmitException(
const char *pszMessage);
103 CPLJSonStreamingParser();
104 virtual ~CPLJSonStreamingParser();
106 void SetMaxDepth(
size_t nVal);
107 void SetMaxStringSize(
size_t nVal);
109 bool ExceptionOccurred()
const
111 return m_bExceptionOccurred;
114 static std::string GetSerializedString(
const char *pszStr);
116 virtual void Reset();
117 virtual bool Parse(
const char *pStr,
size_t nLength,
bool bFinished);
119 virtual void String(
const char * ,
size_t )
123 virtual void Number(
const char * ,
size_t )
127 virtual void Boolean(
bool )
135 virtual void StartObject()
139 virtual void EndObject()
143 virtual void StartObjectMember(
const char * ,
size_t )
147 virtual void StartArray()
151 virtual void EndArray()
155 virtual void StartArrayMember()
159 virtual void Exception(
const char * )
Core portability definitions for CPL.
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042