]> git.sesse.net Git - vlc/blob - modules/gui/skins2/parser/skin_parser.hpp
812bc258b43a665ec18509c053ce5823ffa43cb7
[vlc] / modules / gui / skins2 / parser / skin_parser.hpp
1 /*****************************************************************************
2  * skin_parser.hpp
3  *****************************************************************************
4  * Copyright (C) 2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef SKIN_PARSER_HPP
25 #define SKIN_PARSER_HPP
26
27 #include "xmlparser.hpp"
28 #include "builder_data.hpp"
29 #include <set>
30
31
32 /// Parser for the skin DTD
33 class SkinParser: public XMLParser
34 {
35     public:
36         SkinParser( intf_thread_t *pIntf, const string &rFileName,
37                     const string &rPath );
38         virtual ~SkinParser() {}
39
40         const BuilderData &getData() const { return m_data; }
41
42     private:
43         // Static variable to avoid initializing catalogs twice
44         static bool m_initialized;
45         /// Container for mapping data from the XML
46         BuilderData m_data;
47         /// Current IDs
48         string m_curWindowId;
49         string m_curLayoutId;
50         string m_curListId;
51         /// Current offset of the controls
52         int m_xOffset, m_yOffset;
53         list<int> m_xOffsetList, m_yOffsetList;
54         /// Layer of the current control in the layout
55         int m_curLayer;
56         /// Set of used id
57         set<string> m_idSet;
58         /// Path of the XML file being parsed
59         const string m_path;
60
61         /// Callbacks
62         virtual void handleBeginElement( const string &rName,
63                                          AttrList_t &attr );
64         virtual void handleEndElement( const string &rName );
65
66         /// Helper functions
67         //@{
68         bool convertBoolean( const char *value ) const;
69         int convertColor( const char *transcolor ) const;
70         string convertFileName( const char *fileName ) const;
71         /// Transform to int, and check that it is in the given range (if not,
72         /// the closest range boundary will be used)
73         int convertInRange( const char *value, int minValue, int maxValue,
74                             const string &rAttribute ) const;
75         //@}
76
77         /// Generate a new id
78         const string generateId() const;
79
80         /// Check if the id is unique, and if not generate a new one
81         const string uniqueId( const string &id );
82 };
83
84 #endif