-
Notifications
You must be signed in to change notification settings - Fork 4
/
xml_helpers.h
65 lines (50 loc) · 1.73 KB
/
xml_helpers.h
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
#ifndef _XSCRIPT_XML_HELPERS_H_
#define _XSCRIPT_XML_HELPERS_H_
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxslt/transform.h>
#include <libxslt/xsltInternals.h>
#include "xscript/resource_holder.h"
namespace xscript {
template<>
inline void ResourceHolderTraits<xmlDocPtr>::destroy(xmlDocPtr doc) {
xmlFreeDoc(doc);
}
template<>
inline void ResourceHolderTraits<xmlChar*>::destroy(xmlChar *value) {
xmlFree(value);
};
template<>
inline void ResourceHolderTraits<xmlNodePtr>::destroy(xmlNodePtr node) {
xmlFreeNode(node);
};
template<>
inline void ResourceHolderTraits<xmlNodeSetPtr>::destroy(xmlNodeSetPtr node_set) {
xmlXPathFreeNodeSet(node_set);
};
template<>
inline void ResourceHolderTraits<xmlXPathObjectPtr>::destroy(xmlXPathObjectPtr obj) {
xmlXPathFreeObject(obj);
};
template<>
inline void ResourceHolderTraits<xmlXPathContextPtr>::destroy(xmlXPathContextPtr ctx) {
xmlXPathFreeContext(ctx);
};
template<>
inline void ResourceHolderTraits<xsltStylesheetPtr>::destroy(xsltStylesheetPtr sh) {
xsltFreeStylesheet(sh);
};
template<>
inline void ResourceHolderTraits<xsltTransformContextPtr>::destroy(xsltTransformContextPtr ctx) {
xsltFreeTransformContext(ctx);
};
typedef ResourceHolder<xmlDocPtr> XmlDocHelper;
typedef ResourceHolder<xmlChar*> XmlCharHelper;
typedef ResourceHolder<xmlNodePtr> XmlNodeHelper;
typedef ResourceHolder<xmlNodeSetPtr> XmlNodeSetHelper;
typedef ResourceHolder<xmlXPathObjectPtr> XmlXPathObjectHelper;
typedef ResourceHolder<xmlXPathContextPtr> XmlXPathContextHelper;
typedef ResourceHolder<xsltStylesheetPtr> XsltStylesheetHelper;
typedef ResourceHolder<xsltTransformContextPtr> XsltTransformContextHelper;
} // namespace xscript
#endif // _XSCRIPT_XML_HELPERS_H_