-
Notifications
You must be signed in to change notification settings - Fork 70
/
lsl_xml_element_c.cpp
86 lines (78 loc) · 3.21 KB
/
lsl_xml_element_c.cpp
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
#include <pugixml.hpp>
extern "C" {
#include "api_types.hpp"
// include api_types before public API header
#include "../include/lsl/xml.h"
using namespace pugi;
LIBLSL_C_API lsl_xml_ptr lsl_first_child(lsl_xml_ptr e) {
return xml_node(e).first_child().internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_last_child(lsl_xml_ptr e) {
return xml_node(e).last_child().internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_next_sibling(lsl_xml_ptr e) {
return xml_node(e).next_sibling().internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_previous_sibling(lsl_xml_ptr e) {
return xml_node(e).previous_sibling().internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_parent(lsl_xml_ptr e) {
return xml_node(e).parent().internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_child(lsl_xml_ptr e, const char *name) {
return xml_node(e).child(name).internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_next_sibling_n(lsl_xml_ptr e, const char *name) {
return xml_node(e).next_sibling(name).internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_previous_sibling_n(lsl_xml_ptr e, const char *name) {
return xml_node(e).previous_sibling(name).internal_object();
}
LIBLSL_C_API int32_t lsl_empty(lsl_xml_ptr e) { return xml_node(e).empty(); }
LIBLSL_C_API int32_t lsl_is_text(lsl_xml_ptr e) { return xml_node(e).type() != node_element; }
LIBLSL_C_API const char *lsl_name(lsl_xml_ptr e) { return xml_node(e).name(); }
LIBLSL_C_API const char *lsl_value(lsl_xml_ptr e) { return xml_node(e).value(); }
LIBLSL_C_API const char *lsl_child_value(lsl_xml_ptr e) { return xml_node(e).child_value(); }
LIBLSL_C_API const char *lsl_child_value_n(lsl_xml_ptr e, const char *name) {
return xml_node(e).child_value(name);
}
LIBLSL_C_API int32_t lsl_set_name(lsl_xml_ptr e, const char *rhs) {
return xml_node(e).set_name(rhs);
}
LIBLSL_C_API int32_t lsl_set_value(lsl_xml_ptr e, const char *rhs) {
return xml_node(e).set_value(rhs);
}
LIBLSL_C_API lsl_xml_ptr lsl_append_child(lsl_xml_ptr e, const char *name) {
return xml_node(e).append_child(name).internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_prepend_child(lsl_xml_ptr e, const char *name) {
return xml_node(e).prepend_child(name).internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_append_copy(lsl_xml_ptr e, lsl_xml_ptr e2) {
return xml_node(e).append_copy(xml_node(e2)).internal_object();
}
LIBLSL_C_API lsl_xml_ptr lsl_prepend_copy(lsl_xml_ptr e, lsl_xml_ptr e2) {
return xml_node(e).prepend_copy(xml_node(e2)).internal_object();
}
LIBLSL_C_API void lsl_remove_child_n(lsl_xml_ptr e, const char *name) {
xml_node(e).remove_child(name);
}
LIBLSL_C_API void lsl_remove_child(lsl_xml_ptr e, lsl_xml_ptr e2) {
xml_node(e).remove_child(xml_node(e2));
}
LIBLSL_C_API int32_t lsl_set_child_value(lsl_xml_ptr e, const char *name, const char *value) {
return xml_node(e).child(name).first_child().set_value(value);
}
LIBLSL_C_API lsl_xml_ptr lsl_append_child_value(
lsl_xml_ptr e, const char *name, const char *value) {
xml_node result = xml_node(e).append_child(name);
result.append_child(node_pcdata).set_value(value);
return e;
}
LIBLSL_C_API lsl_xml_ptr lsl_prepend_child_value(
lsl_xml_ptr e, const char *name, const char *value) {
xml_node result = xml_node(e).prepend_child(name);
result.append_child(node_pcdata).set_value(value);
return e;
}
}