summaryrefslogtreecommitdiffabout
path: root/lib/expat.cc
blob: c4dab7e929d4651ef3c2556389854e7ca71e957b (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <opkele/expat.h>

namespace opkele {

    namespace util {

	expat_t::~expat_t() throw() {
	    if(_x)
		XML_ParserFree(_x);
	}

	expat_t& expat_t::operator=(XML_Parser x) {
	    if(_x)
		XML_ParserFree(_x);
	    _x = x;
	    return *this;
	}

	static void _start_element(void* ud,const XML_Char *n,const XML_Char **a) {
	    ((expat_t*)ud)->start_element(n,a);
	}
	static void _end_element(void *ud,const XML_Char *n) {
	    ((expat_t*)ud)->end_element(n);
	}

	void expat_t::set_element_handler() {
	    assert(_x);
	    XML_SetElementHandler(_x,_start_element,_end_element);
	}

	static void _character_data(void *ud,const XML_Char *s,int l) {
	    ((expat_t*)ud)->character_data(s,l);
	}

	void expat_t::set_character_data_handler() {
	    assert(_x);
	    XML_SetCharacterDataHandler(_x,_character_data);
	}

	static void _processing_instruction(void *ud,const XML_Char *t,const XML_Char *d) {
	    ((expat_t*)ud)->processing_instruction(t,d);
	}

	void expat_t::set_processing_instruction_handler() {
	    assert(_x);
	    XML_SetProcessingInstructionHandler(_x,_processing_instruction);
	}

	static void _comment(void *ud,const XML_Char *d) {
	    ((expat_t*)ud)->comment(d);
	}

	void expat_t::set_comment_handler() {
	    assert(_x);
	    XML_SetCommentHandler(_x,_comment);
	}

	static void _start_cdata_section(void *ud) {
	    ((expat_t*)ud)->start_cdata_section();
	}
	static void _end_cdata_section(void *ud) {
	    ((expat_t*)ud)->end_cdata_section();
	}

	void expat_t::set_cdata_section_handler() {
	    assert(_x);
	    XML_SetCdataSectionHandler(_x,_start_cdata_section,_end_cdata_section);
	}

	static void _default_handler(void *ud,const XML_Char *s,int l) {
	    ((expat_t*)ud)->default_handler(s,l);
	}

	void expat_t::set_default_handler() {
	    assert(_x);
	    XML_SetDefaultHandler(_x,_default_handler);
	}
	void expat_t::set_default_handler_expand() {
	    assert(_x);
	    XML_SetDefaultHandlerExpand(_x,_default_handler);
	}

	static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) {
	    ((expat_t*)ud)->start_namespace_decl(p,u);
	}
	static void _end_namespace_decl(void *ud,const XML_Char *p) {
	    ((expat_t*)ud)->end_namespace_decl(p);
	}

	void expat_t::set_namespace_decl_handler() {
	    assert(_x);
	    XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl);
	}

    }

}