osgEarth 2.1.1
Static Public Member Functions

osgEarth::Symbology::CssUtils Class Reference

List of all members.

Static Public Member Functions

static Config readConfig (std::istream &in)

Detailed Description

Definition at line 28 of file CssUtils.


Member Function Documentation

Config CssUtils::readConfig ( std::istream &  in) [static]

Definition at line 29 of file CssUtils.cpp.

{
    // read the entire stream into a string:
    std::stringstream buf;
    //std::copy( std::istreambuf_iterator<char>(in), //::istream_iterator<char>(in),
    //    std::istreambuf_iterator<char>(),
    //    std::ostreambuf_iterator<char>( buf ) );

    buf << in.rdbuf();

    std::string css;
        css = buf.str();

    // 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( css, blocks );

    for( unsigned i=0; i<blocks.size(); )
    {
        const std::string& name = blocks[i++];
        if ( i < blocks.size() )
        {
            Config elementConf( name );

            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.attr( prop[0] ) = prop[1];
                }
            }
            conf.add( elementConf );
        }
    }

    return conf;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines