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{};
63 std::vector<bool> m_abFirstElement{};
64 bool m_bInStringEscape =
false;
65 bool m_bInUnicode =
false;
66 std::string m_osUnicodeHex{};
67 size_t m_nMaxDepth = 1024;
68 size_t m_nMaxStringSize = 10000000;
77 std::vector<MemberState> m_aeObjectState{};
79 enum State currentState() {
return m_aState.back(); }
80 void SkipSpace(
const char*& pStr,
size_t& nLength);
81 void AdvanceChar(
const char*& pStr,
size_t& nLength);
82 bool EmitException(
const char* pszMessage);
83 bool EmitUnexpectedChar(
char ch);
84 bool StartNewToken(
const char*& pStr,
size_t& nLength);
85 bool CheckAndEmitTrueFalseOrNull(
char ch);
86 bool CheckStackEmpty();
90 CPLJSonStreamingParser();
91 virtual ~CPLJSonStreamingParser();
93 void SetMaxDepth(
size_t nVal);
94 void SetMaxStringSize(
size_t nVal);
95 bool ExceptionOccurred()
const {
return m_bExceptionOccurred; }
97 static std::string GetSerializedString(
const char* pszStr);
100 virtual bool Parse(
const char* pStr,
size_t nLength,
bool bFinished);
102 virtual void String(
const char* ,
size_t ) {}
103 virtual void Number(
const char* ,
size_t ) {}
104 virtual void Boolean(
bool ) {}
105 virtual void Null() {}
107 virtual void StartObject() {}
108 virtual void EndObject() {}
109 virtual void StartObjectMember(
const char* ,
size_t ) {}
111 virtual void StartArray() {}
112 virtual void EndArray() {}
113 virtual void StartArrayMember() {}
115 virtual void Exception(
const char* ) {}
118 #endif // __cplusplus
122 #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