当前位置: 首页>>代码示例>>C++>>正文


C++ tokenizer::expect_literal方法代码示例

本文整理汇总了C++中tokenizer::expect_literal方法的典型用法代码示例。如果您正苦于以下问题:C++ tokenizer::expect_literal方法的具体用法?C++ tokenizer::expect_literal怎么用?C++ tokenizer::expect_literal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tokenizer的用法示例。


在下文中一共展示了tokenizer::expect_literal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read_faces

void read_faces(tokenizer& t,int count,std::vector<face_type>& faces)
{ 
    t.expect_literal( "{" );
    t.expect_linefeed();
    for( int i = 0 ; i< count ; i++ ) { 
        face_type f;
        f.vertex_count = t.expect_integer( 2, 4 );
        f.material_index = -1;
        for( int j = 0 ; j < f.vertex_count ; j++ ) { 
            f.colors[ j ].red = f.colors[ j ].green = 
                f.colors[ j ].blue = f.colors[ j ].alpha = 1;
        }
        for( ; ; ) { 
            substr token = t();
            if( token == "V" ) { 
                t.expect_literal( "(" );
                for( int j = 0 ; j< f.vertex_count ; j++ ) { 
                    f.vertex_indices[ j ] =
                        t.expect_integer( 0 );
                }
                t.expect_literal( ")" );
            } else if( token == "M" ) { 
                t.expect_literal( "(" );
                f.material_index = t.expect_integer( -1 );
                t.expect_literal( ")" );
            } else if( token == "UV" ) { 
                t.expect_literal( "(" );
                for( int j = 0 ; j< f.vertex_count ; j++ ) { 
                    f.uv[ j ].u = t.expect_float();
                    f.uv[ j ].v = t.expect_float();
                }
                t.expect_literal( ")" );
            } else if( token == "COL" ) { 
                t.expect_literal( "(" );
                for( int j = 0 ; j < f.vertex_count ; j++ ) { 
                    DWORD c = t.expect_dword();
                    f.colors[ j ].red =
                        ( c & 0xff ) / 255.0f;
                    f.colors[ j ].green =
                        ( ( c & 0xff00 ) >> 8 ) /
                        255.0f;
                    f.colors[ j ].blue =
                        ( ( c & 0xff0000 ) >> 16 ) /
                        255.0f;
                    f.colors[ j ].alpha =
                        ( ( c & 0xff000000 ) >> 24 ) /
                        255.0f;
                }
                t.expect_literal( ")" );
            } else if( token == "\n" ) { 
                break;
            } else { 
                throw mqo_reader_error(
                    "unexpected token: "+token.str() );
            }
        }
开发者ID:jonigata,项目名称:partix,代码行数:56,代码来源:mqoreader.cpp

示例2: read_vertices

void read_vertices(tokenizer& t,int count,std::vector<vertex_type>& vertices)
{
    t.expect_literal( "{" );
    t.expect_linefeed();
    for( int i = 0 ; i< count ; i++ ) {
        vertex_type v; 
        v.x = t.expect_float();
        v.y = t.expect_float();
        v.z = t.expect_float();
        t.expect_linefeed();
        vertices.push_back( v );
    }
    t.expect_literal( "}" );
    t.expect_linefeed();
}
开发者ID:jonigata,项目名称:partix,代码行数:15,代码来源:mqoreader.cpp

示例3: read_scene

void read_scene(tokenizer& t,document_type& doc)
{
    //std::cerr << "unsupported data: Scene" << std::endl;
    OutputDebugStringA("Scene>>>>");
    t.expect_literal( "{" );
    for( ;; ) {
        substr token = t();
        OutputDebugStringA((token.str() + "\n").c_str());
        if( token == "}" ) { break; }
        if( token == "amb" ) {
            doc.scene.ambient.red = t.expect_float(0,1);
            doc.scene.ambient.green = t.expect_float(0,1);
            doc.scene.ambient.blue = t.expect_float(0,1);
            doc.scene.ambient.alpha = 1;
            t.expect_linefeed();
        } else if( token == "dirlights" ) {
            t();
            skip_chunk(t);
            skip_to_linefeed(t);
        } else {
            skip_to_linefeed(t);
        }
    }
    OutputDebugStringA("Scene<<<<");
}
开发者ID:jonigata,项目名称:partix,代码行数:25,代码来源:mqoreader.cpp

示例4: read_header

void read_header(tokenizer& t,document_type& doc)
{
    t.expect_literal( "Metasequoia" ) ; 
    t.expect_literal( "Document" ) ; 
    t.expect_linefeed() ; 
    t.expect_literal( "Format" ) ; 
    t.expect_literal( "Text" ) ; 
    t.expect_literal( "Ver" );

    substr version = t();
    std::stringstream ss( version.str() );
    char c;
    ss >> doc.major_version
       >> c
       >> doc.minor_version;

    t.expect_linefeed();
}
开发者ID:jonigata,项目名称:partix,代码行数:18,代码来源:mqoreader.cpp

示例5: read_scene

void read_scene(tokenizer& t,document_type& doc)
{
        //std::cerr << "unsupported data: Scene" << std::endl;
        t.expect_literal( "{" );
        for( ;; ) {
                substr token = t();
                if( token == "}" ) { break; }
                if( token == "amb" ) {
                        doc.scene.ambient.red = t.expect_float(0,1);
                        doc.scene.ambient.green = t.expect_float(0,1);
                        doc.scene.ambient.blue = t.expect_float(0,1);
                        doc.scene.ambient.alpha = 1;
						t.expect_linefeed();
                } else {
                        skip_to_linefeed(t);
                }
        }
}
开发者ID:jonigata,项目名称:yamadumi,代码行数:18,代码来源:mqoreader.cpp

示例6: read_material

void read_material(tokenizer& t,document_type& doc)
{
    int count=t.expect_integer(1);
    t.expect_literal( "{" );
    t.expect_linefeed();
    for(int i=0;i<count;i++){
        material_type m;
        m.name=t.expect_string(31).str();
        m.shader = shader_phong;
        m.vertex_color = false;
        m.color.red = m.color.green = m.color.blue = m.color.alpha =
            1.0f;
        m.diffuse = m.ambient = m.emissive = m.specular = m.power =
            1.0f;
        m.projection = projection_uv;
        m.proj_pos.x = m.proj_pos.y = m.proj_pos.z = 0;
        m.proj_scale.x = m.proj_scale.y = m.proj_scale.z = 0;
        m.proj_angle.heading =
            m.proj_angle.pitching =
            m.proj_angle.banking = 0;
        for(;;){
            substr token = t();
            if( token == "shader" ) { 
                t.expect_literal( "(" );
                m.shader = shader_type(
                    t.expect_integer( 0, 4 ) );
                t.expect_literal( ")" );
            } else if( token == "vcol" ) { 
                t.expect_literal( "(" );
                m.vertex_color = t.expect_bool();
                t.expect_literal( ")" );
            } else if( token == "col" ) { 
                t.expect_literal( "(" );
                m.color.red = t.expect_float( 0, 1.0f );
                m.color.green = t.expect_float( 0, 1.0f );
                m.color.blue = t.expect_float( 0, 1.0f );
                m.color.alpha = t.expect_float( 0, 1.0f );
                t.expect_literal( ")" );
            } else if( token == "dif" ) { 
                t.expect_literal( "(" );
                m.diffuse = t.expect_float( 0, 1.0f );
                t.expect_literal( ")" );
            } else if( token == "amb" ) { 
                t.expect_literal( "(" );
                m.ambient = t.expect_float( 0, 1.0f );
                t.expect_literal( ")" );
            } else if( token == "emi" ) { 
                t.expect_literal( "(" );
                m.emissive = t.expect_float( 0, 1.0f );
                t.expect_literal( ")" );
            } else if( token == "spc" ) { 
                t.expect_literal( "(" );
                m.specular = t.expect_float( 0, 1.0f );
                t.expect_literal( ")" );
            } else if( token == "power" ) { 
                t.expect_literal( "(" );
                m.power = t.expect_float( 0, 100.0f );
                t.expect_literal( ")" );
            } else if( token == "tex" ) { 
                t.expect_literal( "(" );
                m.texture = t.expect_string( 63 ).str();
                t.expect_literal( ")" );
            } else if( token == "aplane" ) { 
                t.expect_literal( "(" );
                m.aplane = t.expect_string( 63 ).str();
                t.expect_literal( ")" );
            } else if( token == "bump" ) { 
                t.expect_literal( "(" );
                m.bump = t.expect_string( 63 ).str();
                t.expect_literal( ")" );
            } else if( token == "proj_type" ) { 
                t.expect_literal( "(" );
                m.projection = projection_type( 
                    t.expect_integer( 0, 3 ) );
                t.expect_literal( ")" );
            } else if( token == "proj_pos" ) { 
                t.expect_literal( "(" );
                m.proj_pos.x = t.expect_float();
                m.proj_pos.y = t.expect_float();
                m.proj_pos.z = t.expect_float();
                t.expect_literal( ")" );
            } else if( token == "proj_scale" ) { 
                t.expect_literal( "(" );
                m.proj_scale.x = t.expect_float();
                m.proj_scale.y = t.expect_float();
                m.proj_scale.z = t.expect_float();
                t.expect_literal( ")" );
            } else if( token == "proj_angle" ) { 
                t.expect_literal( "(" );
                m.proj_angle.heading = t.expect_float();
                m.proj_angle.pitching = t.expect_float();
                m.proj_angle.banking = t.expect_float();
                t.expect_literal( ")" );
            } else if( token == "\n" ) { 
                break;
            } else { 
                throw mqo_reader_error(
                    "unexpected token: "+token.str() );
            }
        }
//.........这里部分代码省略.........
开发者ID:jonigata,项目名称:partix,代码行数:101,代码来源:mqoreader.cpp


注:本文中的tokenizer::expect_literal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。