const ConfigSet Config::children( const std::string& key ) const { ConfigSet r; for(ConfigSet::const_iterator i = _children.begin(); i != _children.end(); i++ ) { if ( (i)->key() == key ) r.push_back( *i ); } return r; }
void CssUtils::readConfig( const std::string& css, const std::string& referrer, ConfigSet& output ) { ConfigSet result; // if there's no brackets, assume this is a single default block. std::string temp = css; if ( css.find_first_of("{") == std::string::npos ) { temp = "default { " + css + " }"; } else if ( css.size() > 0 && css[0] == '{' ) { temp = "default " + css; } // tokenize the CSS into a config object.. Config conf( "css" ); StringTokenizer blockIzer( "{}", "" ); blockIzer.addQuotes( "'\"", true ); StringTokenizer propSetIzer( ";", "" ); propSetIzer.addQuotes( "'\"", true ); StringTokenizer propIzer( ":", "" ); propIzer.addQuotes( "()'\"", true ); StringVector blocks; blockIzer.tokenize( temp, blocks ); for( unsigned i=0; i<blocks.size(); ) { const std::string& name = blocks[i++]; if ( i < blocks.size() ) { Config elementConf( name ); elementConf.setReferrer( referrer ); StringVector propSet; propSetIzer.tokenize( blocks[i++], propSet ); for( unsigned j=0; j<propSet.size(); ++j ) { StringVector prop; propIzer.tokenize( propSet[j], prop ); if ( prop.size() == 2 ) { elementConf.set( prop[0], prop[1] ); } } output.push_back( elementConf ); } } }