summaryrefslogtreecommitdiff
path: root/libtemplate/xmlparser.h
blob: ecdcca33073bd25ddbe6a619acf1857fbc9a7aec (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
#ifndef __XMLPARSER_H
#define __XMLPARSER_H

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
#include <vdr/plugin.h>

#include "templateview.h"
#include "templateviewlist.h"
#include "templateviewtab.h"

using namespace std;

// --- cXmlParser -------------------------------------------------------------

class cXmlParser {
private:
    cTemplateView *view;
    cGlobals *globals;
    xmlParserCtxtPtr ctxt;
    xmlDocPtr doc;
    xmlNodePtr root;
    string GetPath(string xmlFile);
    void ParseGlobalColors(xmlNodePtr node);
    void InsertColor(string name, string value);
    void ParseGlobalVariables(xmlNodePtr node);
    void InsertVariable(string name, string type, string value);
    void ParseGlobalFonts(xmlNodePtr node);
    void ParseTranslations(xmlNodePtr node);
    bool ParseSubView(xmlNodePtr node);
    void ParseViewElement(const xmlChar * viewElement, xmlNodePtr node, bool debugVE, cTemplateView *subView = NULL);
    void ParseViewList(xmlNodePtr parentNode, cTemplateView *subView = NULL);
    void ParseViewTab(xmlNodePtr parentNode, cTemplateView *subView);
    void ParseFunctionCalls(xmlNodePtr node, cTemplatePixmap *pix);
    void ParseLoopFunctionCalls(xmlNodePtr node, cTemplateLoopFunction *loopFunc);
    bool ParseAttributes(xmlAttrPtr attr, xmlNodePtr node, vector<pair<string, string> > &attribs);
    bool DebugViewElement(xmlNodePtr node);
public:
    cXmlParser(void);
    virtual ~cXmlParser(void);
    bool ReadView(cTemplateView *view, string xmlFile);
    bool ReadGlobals(cGlobals *globals, string xmlFile);
    bool ParseView(void);
    bool ParseGlobals(void);
    void DeleteDocument(void);
};

#endif //__XMLPARSER_H