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
56 bool m_bExceptionOccurred =
false;
57 bool m_bElementFound =
false;
58 bool m_bStopParsing =
false;
60 int m_nLineCounter = 1;
61 int m_nCharCounter = 1;
62 std::vector<State> m_aState{};
63 std::string m_osToken{};
70 std::vector<ArrayState> m_abArrayState{};
71 bool m_bInStringEscape =
false;
72 bool m_bInUnicode =
false;
73 std::string m_osUnicodeHex{};
74 size_t m_nMaxDepth = 1024;
75 size_t m_nMaxStringSize = 10000000;
85 std::vector<MemberState> m_aeObjectState{};
87 enum State currentState()
89 return m_aState.back();
92 void SkipSpace(
const char *&pStr,
size_t &nLength);
93 void AdvanceChar(
const char *&pStr,
size_t &nLength);
94 bool EmitUnexpectedChar(
char ch,
const char *pszExpecting =
nullptr);
95 bool StartNewToken(
const char *&pStr,
size_t &nLength);
96 bool CheckAndEmitTrueFalseOrNull(
char ch);
97 bool CheckStackEmpty();
101 bool EmitException(
const char *pszMessage);
105 CPLJSonStreamingParser();
106 virtual ~CPLJSonStreamingParser();
108 void SetMaxDepth(
size_t nVal);
109 void SetMaxStringSize(
size_t nVal);
111 bool ExceptionOccurred()
const
113 return m_bExceptionOccurred;
116 static std::string GetSerializedString(
const char *pszStr);
118 virtual void Reset();
119 virtual bool Parse(
const char *pStr,
size_t nLength,
bool bFinished);
121 virtual void String(
const char * ,
size_t )
125 virtual void Number(
const char * ,
size_t )
129 virtual void Boolean(
bool )
137 virtual void StartObject()
141 virtual void EndObject()
145 virtual void StartObjectMember(
const char * ,
size_t )
149 virtual void StartArray()
153 virtual void EndArray()
157 virtual void StartArrayMember()
161 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