summaryrefslogtreecommitdiff
path: root/lib/jsonParse.h
blob: 6b1249f97c48952bcb75536f953585d68ec0532c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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