summaryrefslogtreecommitdiff
path: root/lib/jsonParse.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-28 17:17:11 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-07 16:41:37 +0000
commit3cd4ff83a253e098e6524df5be3a686727e4f50b (patch)
treecfbfaac4753d6321339f8653c3cabaca440afec8 /lib/jsonParse.h
parentCompile stb wrapper in C++ mode (diff)
downloadilt-3cd4ff83a253e098e6524df5be3a686727e4f50b.tar.bz2
ilt-3cd4ff83a253e098e6524df5be3a686727e4f50b.tar.xz
ilt-3cd4ff83a253e098e6524df5be3a686727e4f50b.zip
Initial commit of basis persistence
JSON parser lifted almost verbatim for libjsonpp running into some custom code for populating ilt objects. Pretty minimal per object code requirements.
Diffstat (limited to 'lib/jsonParse.h')
-rw-r--r--lib/jsonParse.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/jsonParse.h b/lib/jsonParse.h
new file mode 100644
index 0000000..6b1249f
--- /dev/null
+++ b/lib/jsonParse.h
@@ -0,0 +1,43 @@
+#ifndef JSONFLEXLEXER_H
+#define JSONFLEXLEXER_H
+
+#ifndef FLEX_SCANNER
+# define yyFlexLexer jsonBaseFlexLexer
+# include <FlexLexer.h>
+#endif
+#include <cassert>
+#include <filesystem>
+#include <fstream>
+#include <memory>
+#include <stdexcept>
+#include <string>
+
+namespace json {
+ class jsonParser : public yyFlexLexer {
+ public:
+ using yyFlexLexer::yyFlexLexer;
+ int yylex() override;
+
+ static void appendEscape(const char *, std::string &);
+ static void appendEscape(unsigned long, std::string &);
+
+ protected:
+ virtual void BeginObject() = 0;
+ virtual void BeginArray() = 0;
+
+ virtual void PushBoolean(bool) = 0;
+ virtual void PushNumber(float) = 0;
+ virtual void PushNull() = 0;
+ virtual void PushText(std::string &&) = 0;
+ virtual void PushKey(std::string &&) = 0;
+
+ virtual void EndArray() = 0;
+ virtual void EndObject() = 0;
+
+ void LexerError(const char * msg) override;
+
+ std::string buf;
+ };
+}
+
+#endif