summaryrefslogtreecommitdiff
path: root/lib/saxParse-persistence.cpp
blob: a6a0d2356b8dfe3163a927e76147b774ecc69c5c (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
44
45
46
47
48
49
50
#include "saxParse-persistence.h"

namespace Persistence {

	void
	SAXParsePersistence::loadStateInternal(FILE * in)
	{
		stk.top()->beforeValue(stk);
		stk.top()->beginObject(stk);
		parseFile(in);
		stk.pop();
		stk.pop();
	}

	void
	SAXParsePersistence::elementOpen(mxml_node_t * n)
	{
		stk.push(stk.top()->select(mxmlGetElement(n)));
		stk.top()->beforeValue(stk);
		stk.top()->beginObject(stk);
		for (int attrCount = mxmlElementGetAttrCount(n), attrIdx {0}; attrIdx < attrCount; ++attrIdx) {
			const char *name, *value = mxmlElementGetAttrByIndex(n, attrIdx, &name);
			auto sel = stk.top()->select(name);
			sel->beforeValue(stk);
			sel->setValue(std::string {value});
		}
	}

	void
	SAXParsePersistence::elementClose(mxml_node_t *)
	{
		stk.top()->endObject(stk);
		stk.top()->endObject(stk);
	}

	void
	SAXParsePersistence::data(mxml_node_t *)
	{
	}

	void
	SAXParsePersistence::directive(mxml_node_t *)
	{
	}

	void
	SAXParsePersistence::cdata(mxml_node_t *)
	{
	}
}