xmlparser.hpp 2.29 KB
Newer Older
1
2
3
/*****************************************************************************
 * xmlparser.hpp
 *****************************************************************************
4
 * Copyright (C) 2004 the VideoLAN team
gbazin's avatar
gbazin committed
5
 * $Id$
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 *
 * Authors: Cyril Deguet     <asmax@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

#ifndef XMLPARSER_HPP
#define XMLPARSER_HPP

#include "../src/skin_common.hpp"
sigmunau's avatar
sigmunau committed
28
29
#include "vlc_block.h"
#include "vlc_stream.h"
gbazin's avatar
gbazin committed
30
#include "vlc_xml.h"
31
32
#include <map>

gbazin's avatar
gbazin committed
33
34
35
// Current DTD version
#define SKINS_DTD_VERSION "2.0"

36
37
38
39
40
41
42
/// XML parser using libxml2 text reader API
class XMLParser: public SkinObject
{
    public:
        XMLParser( intf_thread_t *pIntf, const string &rFileName );
        virtual ~XMLParser();

43
44
        /// Parse the file. Returns true on success
        bool parse();
45

46
    protected:
47
48
49
50
51
52
53
54
55
56
57
        // Key comparison function for type "const char*"
        struct ltstr
        {
            bool operator()(const char* s1, const char* s2) const
            {
                return strcmp(s1, s2) < 0;
            }
        };
        /// Type for attribute lists
        typedef map<const char*, const char*, ltstr> AttrList_t;

58
59
60
        /// Flag for validation errors
        bool m_errors;

61
        /// Callbacks
gbazin's avatar
gbazin committed
62
63
        virtual void handleBeginElement( const string &rName,
                                         AttrList_t &attr ) {}
64
        virtual void handleEndElement( const string &rName ) {}
65
66

    private:
gbazin's avatar
gbazin committed
67
        void LoadCatalog();
68

gbazin's avatar
gbazin committed
69
70
71
        /// Reader context
        xml_t *m_pXML;
        xml_reader_t *m_pReader;
sigmunau's avatar
sigmunau committed
72
        stream_t *m_pStream;
73
74
75
};

#endif