summaryrefslogtreecommitdiff
path: root/extensions/libxmlwrapper.h
blob: 0838f524b8d11b9b61158f109c05520e6faeb947 (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
#ifndef __LIBXMLWRAPPER_H
#define __LIBXMLWRAPPER_H

#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include <vdr/plugin.h>

using namespace std;
typedef pair<string,string> stringpair;
typedef map<string,string> stringmap;

class cLibXMLWrapper {
private:
    xmlParserCtxtPtr ctxt;
    xmlDocPtr doc;
    xmlNodePtr root;
    xmlNodePtr current;
    stack<xmlNodePtr> nodeStack;
protected:
    void DeleteDocument(void);
    bool ReadXMLFile(const char *path, bool validate = true);
    bool SetDocument(void);
    bool Validate(void);
    bool CheckNodeName(const char *name);
    const char *NodeName(void);
    vector<stringpair> ParseAttributes(void);
    bool LevelDown(void);
    bool LevelUp(void);
    bool NextNode(void);
    bool GetAttribute(string &name, string &value);
    bool GetNodeValue(string &value);
public:
    cLibXMLWrapper(void);
    virtual ~cLibXMLWrapper(void);
    static void InitLibXML();
    static void CleanupLibXML();
};

#endif //__LIBXMLWRAPPER_H