xmlparser.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * xmlparser.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2004 the VideoLAN team
00005  * $Id: aa5f9e22ad17dcafa84e732a5f98221759636e66 $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License along
00020  * with this program; if not, write to the Free Software Foundation, Inc.,
00021  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef XMLPARSER_HPP
00025 #define XMLPARSER_HPP
00026 
00027 #include "../src/skin_common.hpp"
00028 #include <vlc_block.h>
00029 #include <vlc_stream.h>
00030 #include <vlc_xml.h>
00031 #include <map>
00032 
00033 // Current DTD version
00034 #define SKINS_DTD_VERSION "2.0"
00035 
00036 /// XML parser using libxml2 text reader API
00037 class XMLParser: public SkinObject
00038 {
00039 public:
00040     XMLParser( intf_thread_t *pIntf, const string &rFileName,
00041                bool useDTD = true );
00042     virtual ~XMLParser();
00043 
00044     /// Parse the file. Returns true on success
00045     bool parse();
00046 
00047 protected:
00048     // Key comparison function for type "const char*"
00049     struct ltstr
00050     {
00051         bool operator()(const char* s1, const char* s2) const
00052         {
00053             return strcmp(s1, s2) < 0;
00054         }
00055     };
00056     /// Type for attribute lists
00057     typedef map<const char*, const char*, ltstr> AttrList_t;
00058 
00059     /// Flag for validation errors
00060     bool m_errors;
00061 
00062     /// Callbacks
00063     virtual void handleBeginElement( const string &rName,
00064                                      AttrList_t &attr ) { }
00065     virtual void handleEndElement( const string &rName ) { }
00066 
00067 private:
00068     void LoadCatalog();
00069 
00070     /// Reader context
00071     xml_t *m_pXML;
00072     xml_reader_t *m_pReader;
00073     stream_t *m_pStream;
00074 };
00075 
00076 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6