13#ifndef CPL_JSON_STREAMIN_PARSER_H
14#define CPL_JSON_STREAMIN_PARSER_H
18#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
25class CPL_DLL CPLJSonStreamingParser
28 CPLJSonStreamingParser();
29 virtual ~CPLJSonStreamingParser();
31 void SetMaxDepth(
size_t nVal);
32 void SetMaxStringSize(
size_t nVal);
34 bool ExceptionOccurred()
const
36 return m_bExceptionOccurred;
39 static std::string GetSerializedString(std::string_view sStr);
42 virtual bool Parse(std::string_view sStr,
bool bFinished);
45 bool EmitException(
const char *pszMessage);
48 virtual void String(std::string_view )
52 virtual void Number(std::string_view )
56 virtual void Boolean(
bool )
64 virtual void StartObject()
68 virtual void EndObject()
72 virtual void StartObjectMember(std::string_view )
76 virtual void StartArray()
80 virtual void EndArray()
84 virtual void StartArrayMember()
88 virtual void Exception(
const char * )
107 bool m_bExceptionOccurred =
false;
108 bool m_bElementFound =
false;
109 bool m_bStopParsing =
false;
111 int m_nLineCounter = 1;
112 int m_nCharCounter = 1;
113 std::vector<State> m_aState{};
114 std::string m_osToken{};
115 enum class ArrayState
121 std::vector<ArrayState> m_abArrayState{};
122 bool m_bInStringEscape =
false;
123 bool m_bInUnicode =
false;
124 std::string m_osUnicodeHex{};
125 size_t m_nMaxDepth = 1024;
126 size_t m_nMaxStringSize = 10000000;
136 std::vector<MemberState> m_aeObjectState{};
138 enum State currentState()
140 return m_aState.back();
143 void SkipSpace(
const char *&pStr,
size_t &nLength);
144 void AdvanceChar(
const char *&pStr,
size_t &nLength);
145 bool EmitUnexpectedChar(
char ch,
const char *pszExpecting =
nullptr);
146 bool StartNewToken(
const char *&pStr,
size_t &nLength);
147 bool CheckAndEmitTrueFalseOrNull(
char ch);
148 bool CheckStackEmpty();
149 void DecodeUnicode();
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:936