xmlparser.hpp 2.34 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
 *
 * 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
dionoea's avatar
dionoea committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22
23
24
25
26
27
 *****************************************************************************/

#ifndef XMLPARSER_HPP
#define XMLPARSER_HPP

#include "../src/skin_common.hpp"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
28
29
30
#include <vlc_block.h>
#include <vlc_stream.h>
#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
/// XML parser using libxml2 text reader API
class XMLParser: public SkinObject
{
    public:
40
41
        XMLParser( intf_thread_t *pIntf, const string &rFileName,
                   bool useDTD = true );
42
43
        virtual ~XMLParser();

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

47
    protected:
48
49
50
51
52
53
54
55
56
57
58
        // 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;

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

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

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

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

#endif