示例#1
0
const StyleSelector*
StyleSheet::getSelector( const std::string& name ) const
{
    for(StyleSelectorList::const_iterator i = _selectors.begin(); i != _selectors.end(); ++i )
    {
        if ( i->name() == name )
        {
            return &(*i);
        }
    }
    return 0L;
}
示例#2
0
Config
StyleSheet::getConfig() const
{
    Config conf;
    for( StyleSelectorList::const_iterator i = _selectors.begin(); i != _selectors.end(); ++i )
    {
        conf.add( "selector", i->getConfig() );
    }
    for( StyleMap::const_iterator i = _styles.begin(); i != _styles.end(); ++i )
    {
        conf.add( "style", i->second.getConfig() );
    }
    return conf;
}
示例#3
0
Config
StyleSheet::getConfig() const
{
    Config conf;
    conf.set("name", _name);

    for( StyleSelectorList::const_iterator i = _selectors.begin(); i != _selectors.end(); ++i )
    {
        conf.add( "selector", i->getConfig() );
    }

    for( StyleMap::const_iterator i = _styles.begin(); i != _styles.end(); ++i )
    {
        conf.add( "style", i->second.getConfig() );
    }

    {
        Threading::ScopedReadLock shared( const_cast<StyleSheet*>(this)->_resLibsMutex );

        for( ResourceLibraries::const_iterator i = _resLibs.begin(); i != _resLibs.end(); ++i )
        {
            if ( i->second.valid() )
            {
                Config libConf = i->second->getConfig();
                conf.add( "library", libConf );
            }
        }
    }

    if ( _script.valid() )
    {
        Config scriptConf("script");

        if ( !_script->name.empty() )
            scriptConf.set( "name", _script->name );
        if ( !_script->language.empty() )
            scriptConf.set( "language", _script->language );
        if ( _script->uri.isSet() )
            scriptConf.set( "url", _script->uri->base() );
        if ( !_script->profile.empty() )
            scriptConf.set( "profile", _script->profile );
        else if ( !_script->code.empty() )
            scriptConf.setValue(_script->code);

        conf.add( scriptConf );
    }

    return conf;
}