vlc_xml.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_xml.h: XML abstraction layer
00003  *****************************************************************************
00004  * Copyright (C) 2004-2010 VLC authors and VideoLAN
00005  *
00006  * Author: Gildas Bazin <gbazin@videolan.org>
00007  *
00008  * This program is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License as published by
00010  * the Free Software Foundation; either version 2.1 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program; if not, write to the Free Software Foundation,
00020  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00021  *****************************************************************************/
00022 
00023 #ifndef VLC_XML_H
00024 #define VLC_XML_H
00025 
00026 /**
00027 * \file
00028 * This file defines functions and structures to handle xml tags in vlc
00029 *
00030 */
00031 
00032 # ifdef __cplusplus
00033 extern "C" {
00034 # endif
00035 
00036 struct xml_t
00037 {
00038     VLC_COMMON_MEMBERS
00039 
00040     /* Module properties */
00041     module_t  *p_module;
00042     xml_sys_t *p_sys;
00043 
00044     void (*pf_catalog_load) ( xml_t *, const char * );
00045     void (*pf_catalog_add) ( xml_t *, const char *, const char *,
00046                             const char * );
00047 };
00048 
00049 VLC_API xml_t * xml_Create( vlc_object_t * ) VLC_USED;
00050 #define xml_Create( a ) xml_Create( VLC_OBJECT(a) )
00051 VLC_API void xml_Delete( xml_t * );
00052 
00053 static inline void xml_CatalogLoad( xml_t *xml, const char *catalog )
00054 {
00055     xml->pf_catalog_load( xml, catalog );
00056 }
00057 
00058 static inline void xml_CatalogAdd( xml_t *xml, const char *type,
00059                                    const char *orig, const char *value )
00060 {
00061     xml->pf_catalog_add( xml, type, orig, value );
00062 }
00063 
00064 
00065 struct xml_reader_t
00066 {
00067     VLC_COMMON_MEMBERS
00068 
00069     xml_reader_sys_t *p_sys;
00070     stream_t *p_stream;
00071     module_t *p_module;
00072 
00073     int (*pf_next_node) ( xml_reader_t *, const char ** );
00074     const char *(*pf_next_attr) ( xml_reader_t *, const char ** );
00075 
00076     int (*pf_use_dtd) ( xml_reader_t * );
00077     int (*pf_is_empty) ( xml_reader_t * );
00078 };
00079 
00080 VLC_API xml_reader_t * xml_ReaderCreate(vlc_object_t *, stream_t *) VLC_USED;
00081 #define xml_ReaderCreate( a, s ) xml_ReaderCreate(VLC_OBJECT(a), s)
00082 VLC_API void xml_ReaderDelete(xml_reader_t *);
00083 VLC_API xml_reader_t * xml_ReaderReset(xml_reader_t *, stream_t *) VLC_USED;
00084 
00085 static inline int xml_ReaderNextNode( xml_reader_t *reader, const char **pval )
00086 {
00087     return reader->pf_next_node( reader, pval );
00088 }
00089 
00090 static inline const char *xml_ReaderNextAttr( xml_reader_t *reader,
00091                                               const char **pval )
00092 {
00093   return reader->pf_next_attr( reader, pval );
00094 }
00095 
00096 static inline int xml_ReaderUseDTD( xml_reader_t *reader )
00097 {
00098   return reader->pf_use_dtd( reader );
00099 }
00100 
00101 static inline int xml_ReaderIsEmptyElement( xml_reader_t *reader )
00102 {
00103     if(reader->pf_is_empty == NULL)
00104         return -2;
00105 
00106     return reader->pf_is_empty( reader );
00107 }
00108 
00109 enum {
00110     XML_READER_NONE=0,
00111     XML_READER_STARTELEM,
00112     XML_READER_ENDELEM,
00113     XML_READER_TEXT,
00114 };
00115 
00116 # ifdef __cplusplus
00117 }
00118 # endif
00119 
00120 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines