vlc_xml.h 3.32 KB
Newer Older
Gildas Bazin's avatar
Gildas Bazin committed
1
/*****************************************************************************
Pere Orga's avatar
Pere Orga committed
2
 * vlc_xml.h: XML abstraction layer
3
 *****************************************************************************
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
4
 * Copyright (C) 2004-2010 VLC authors and VideoLAN
5 6 7
 *
 * Author: Gildas Bazin <gbazin@videolan.org>
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
8 9 10
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
11 12 13 14
 * (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
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
15 16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
17
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
18 19 20
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21
 *****************************************************************************/
Gildas Bazin's avatar
Gildas Bazin committed
22

23 24
#ifndef VLC_XML_H
#define VLC_XML_H
Gildas Bazin's avatar
Gildas Bazin committed
25

26
/**
27 28 29 30
* \file
* This file defines functions and structures to handle xml tags in vlc
*
*/
31

32 33 34 35
# ifdef __cplusplus
extern "C" {
# endif

Gildas Bazin's avatar
Gildas Bazin committed
36 37
struct xml_t
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
38
    VLC_COMMON_MEMBERS
Gildas Bazin's avatar
Gildas Bazin committed
39

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
40 41 42
    /* Module properties */
    module_t  *p_module;
    xml_sys_t *p_sys;
Gildas Bazin's avatar
Gildas Bazin committed
43

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
44 45 46
    void (*pf_catalog_load) ( xml_t *, const char * );
    void (*pf_catalog_add) ( xml_t *, const char *, const char *,
                            const char * );
Gildas Bazin's avatar
Gildas Bazin committed
47 48
};

49
VLC_API xml_t * xml_Create( vlc_object_t * ) VLC_USED;
50
#define xml_Create( a ) xml_Create( VLC_OBJECT(a) )
51
VLC_API void xml_Delete( xml_t * );
Gildas Bazin's avatar
Gildas Bazin committed
52

53 54 55 56 57 58 59 60 61 62 63
static inline void xml_CatalogLoad( xml_t *xml, const char *catalog )
{
    xml->pf_catalog_load( xml, catalog );
}

static inline void xml_CatalogAdd( xml_t *xml, const char *type,
                                   const char *orig, const char *value )
{
    xml->pf_catalog_add( xml, type, orig, value );
}

Gildas Bazin's avatar
Gildas Bazin committed
64 65 66

struct xml_reader_t
{
67 68
    VLC_COMMON_MEMBERS

Gildas Bazin's avatar
Gildas Bazin committed
69
    xml_reader_sys_t *p_sys;
70 71
    stream_t *p_stream;
    module_t *p_module;
Gildas Bazin's avatar
Gildas Bazin committed
72

73
    int (*pf_next_node) ( xml_reader_t *, const char ** );
74
    const char *(*pf_next_attr) ( xml_reader_t *, const char ** );
75

76
    int (*pf_use_dtd) ( xml_reader_t * );
77
    int (*pf_is_empty) ( xml_reader_t * );
Gildas Bazin's avatar
Gildas Bazin committed
78 79
};

80
VLC_API xml_reader_t * xml_ReaderCreate(vlc_object_t *, stream_t *) VLC_USED;
81
#define xml_ReaderCreate( a, s ) xml_ReaderCreate(VLC_OBJECT(a), s)
82
VLC_API void xml_ReaderDelete(xml_reader_t *);
83
VLC_API xml_reader_t * xml_ReaderReset(xml_reader_t *, stream_t *) VLC_USED;
84

85
static inline int xml_ReaderNextNode( xml_reader_t *reader, const char **pval )
86
{
87
    return reader->pf_next_node( reader, pval );
88 89
}

90 91
static inline const char *xml_ReaderNextAttr( xml_reader_t *reader,
                                              const char **pval )
92
{
93
  return reader->pf_next_attr( reader, pval );
94 95
}

96
static inline int xml_ReaderUseDTD( xml_reader_t *reader )
97
{
98
  return reader->pf_use_dtd( reader );
99 100
}

101 102 103 104 105 106 107 108
static inline int xml_ReaderIsEmptyElement( xml_reader_t *reader )
{
    if(reader->pf_is_empty == NULL)
        return -2;

    return reader->pf_is_empty( reader );
}

109
enum {
110
    XML_READER_ERROR=-1,
111 112 113 114 115
    XML_READER_NONE=0,
    XML_READER_STARTELEM,
    XML_READER_ENDELEM,
    XML_READER_TEXT,
};
Gildas Bazin's avatar
Gildas Bazin committed
116

117 118 119 120
# ifdef __cplusplus
}
# endif

Gildas Bazin's avatar
Gildas Bazin committed
121
#endif