Commit 0fb4941e authored by JP Dinger's avatar JP Dinger

Skins2: Reduce another macro to bare minimum and helper fuction.

parent f500f796
...@@ -75,24 +75,23 @@ CmdGeneric *Builder::parseAction( const string &rAction ) ...@@ -75,24 +75,23 @@ CmdGeneric *Builder::parseAction( const string &rAction )
return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme ); return Interpreter::instance( getIntf() )->parseAction( rAction, m_pTheme );
} }
template<class T> inline
// Useful macro void Builder::add_objects(const std::list<T> &list,
#define ADD_OBJECTS( type ) \ void (Builder::*addfn)(const T &))
list<BuilderData::type>::const_iterator it##type; \ {
for( it##type = m_rData.m_list##type.begin(); \ typename std::list<T>::const_iterator i;
it##type != m_rData.m_list##type.end(); it##type++ ) \ for( i = list.begin(); i != list.end(); ++i )
{ \ (this->*addfn)( *i );
add##type( *it##type ); \ }
}
Theme *Builder::build() Theme *Builder::build()
{ {
m_pTheme = new Theme( getIntf() ); #define ADD_OBJECTS( type ) \
add_objects(m_rData.m_list##type,&Builder::add##type)
m_pTheme = new (std::nothrow) Theme( getIntf() );
if( m_pTheme == NULL ) if( m_pTheme == NULL )
{
return NULL; return NULL;
}
// Create everything from the data in the XML // Create everything from the data in the XML
ADD_OBJECTS( Theme ); ADD_OBJECTS( Theme );
...@@ -123,6 +122,8 @@ Theme *Builder::build() ...@@ -123,6 +122,8 @@ Theme *Builder::build()
ADD_OBJECTS( MenuSeparator ); ADD_OBJECTS( MenuSeparator );
return m_pTheme; return m_pTheme;
#undef ADD_OBJECTS
} }
......
...@@ -91,6 +91,10 @@ private: ...@@ -91,6 +91,10 @@ private:
void addTree( const BuilderData::Tree &rData ); void addTree( const BuilderData::Tree &rData );
void addVideo( const BuilderData::Video &rData ); void addVideo( const BuilderData::Video &rData );
/// Helper for build(); gluing BuilderData::list<T>s to addType(T&)
template<class T> void add_objects(const std::list<T> &list,
void (Builder::*addfn)(const T &));
/// Compute the position of a control /// Compute the position of a control
const Position makePosition( const string &rLeftTop, const Position makePosition( const string &rLeftTop,
const string &rRightBottom, const string &rRightBottom,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment