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;
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;
83 std::vector<MemberState> m_aeObjectState{};
85 enum State currentState() {
return m_aState.back(); }
86 void SkipSpace(
const char*& pStr,
size_t& nLength);
87 void AdvanceChar(
const char*& pStr,
size_t& nLength);
88 bool EmitException(
const char* pszMessage);
89 bool EmitUnexpectedChar(
char ch,
const char* pszExpecting =
nullptr);
90 bool StartNewToken(
const char*& pStr,
size_t& nLength);
91 bool CheckAndEmitTrueFalseOrNull(
char ch);
92 bool CheckStackEmpty();
96 CPLJSonStreamingParser();
97 virtual ~CPLJSonStreamingParser();
99 void SetMaxDepth(
size_t nVal);
100 void SetMaxStringSize(
size_t nVal);
101 bool ExceptionOccurred()
const {
return m_bExceptionOccurred; }
103 static std::string GetSerializedString(
const char* pszStr);
105 virtual void Reset();
106 virtual bool Parse(
const char* pStr,
size_t nLength,
bool bFinished);
108 virtual void String(
const char* ,
size_t ) {}
109 virtual void Number(
const char* ,
size_t ) {}
110 virtual void Boolean(
bool ) {}
111 virtual void Null() {}
113 virtual void StartObject() {}
114 virtual void EndObject() {}
115 virtual void StartObjectMember(
const char* ,
size_t ) {}
117 virtual void StartArray() {}
118 virtual void EndArray() {}
119 virtual void StartArrayMember() {}
121 virtual void Exception(
const char* ) {}
124 #endif // __cplusplus 128 #endif // CPL_JSON_STREAMIN_PARSER_H 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:989