13#ifndef CPL_JSON_STREAMIN_PARSER_H
14#define CPL_JSON_STREAMIN_PARSER_H
18#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
24class CPL_DLL CPLJSonStreamingParser
40 bool m_bExceptionOccurred =
false;
41 bool m_bElementFound =
false;
42 bool m_bStopParsing =
false;
44 int m_nLineCounter = 1;
45 int m_nCharCounter = 1;
46 std::vector<State> m_aState{};
47 std::string m_osToken{};
54 std::vector<ArrayState> m_abArrayState{};
55 bool m_bInStringEscape =
false;
56 bool m_bInUnicode =
false;
57 std::string m_osUnicodeHex{};
58 size_t m_nMaxDepth = 1024;
59 size_t m_nMaxStringSize = 10000000;
69 std::vector<MemberState> m_aeObjectState{};
71 enum State currentState()
73 return m_aState.back();
76 void SkipSpace(
const char *&pStr,
size_t &nLength);
77 void AdvanceChar(
const char *&pStr,
size_t &nLength);
78 bool EmitUnexpectedChar(
char ch,
const char *pszExpecting =
nullptr);
79 bool StartNewToken(
const char *&pStr,
size_t &nLength);
80 bool CheckAndEmitTrueFalseOrNull(
char ch);
81 bool CheckStackEmpty();
85 bool EmitException(
const char *pszMessage);
89 CPLJSonStreamingParser();
90 virtual ~CPLJSonStreamingParser();
92 void SetMaxDepth(
size_t nVal);
93 void SetMaxStringSize(
size_t nVal);
95 bool ExceptionOccurred()
const
97 return m_bExceptionOccurred;
100 static std::string GetSerializedString(
const char *pszStr);
102 virtual void Reset();
103 virtual bool Parse(
const char *pStr,
size_t nLength,
bool bFinished);
105 virtual void String(
const char * ,
size_t )
109 virtual void Number(
const char * ,
size_t )
113 virtual void Boolean(
bool )
121 virtual void StartObject()
125 virtual void EndObject()
129 virtual void StartObjectMember(
const char * ,
size_t )
133 virtual void StartArray()
137 virtual void EndArray()
141 virtual void StartArrayMember()
145 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:1030