summaryrefslogtreecommitdiff
path: root/lib/saxParse.cpp
blob: d592a1f121cdf0d039247d2f80f8f2978b948bab (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
#include "saxParse.h"
#include "mxml.h"

namespace Persistence {
	void
	SAXParse::comment(mxml_node_t *)
	{
		// Default to just ignore comments
	}

	void
	SAXParse::parseFile(FILE * file)
	{
		mxmlSAXLoadFile(
				nullptr, file, MXML_TEXT_CALLBACK,
				[](mxml_node_t * n, mxml_sax_event_t e, void * data) {
					SAXParse * self = static_cast<SAXParse *>(data);
					switch (e) {
						case MXML_SAX_ELEMENT_OPEN:
							return self->elementOpen(n);
							break;
						case MXML_SAX_ELEMENT_CLOSE:
							return self->elementClose(n);
							break;
						case MXML_SAX_COMMENT:
							return self->comment(n);
							break;
						case MXML_SAX_DATA:
							return self->data(n);
							break;
						case MXML_SAX_DIRECTIVE:
							return self->directive(n);
							break;
						case MXML_SAX_CDATA:;
							return self->cdata(n);
							break;
					}
				},
				this);
	}
}