Ejemplo n.º 1
0
void read_grid(grid *g, FILE *fp){
	char *line = NULL;
	size_t size = 0;
	int x, y;
	while(getline(&line, &size, fp)!= -1){
		if(line[0] == '#')
			continue;
		else{
			sscanf(line, "%d %d", &y, &x);
			ins_point(g, x, y);
		}

	}

	free(line);


}
bool
AsciiProcessor::ins_obj( const char * buf,
                         int fref,
                         BuilderBase * build,
                         const char* & next )
{
    // ==========================================================
    if ( strskip( buf, "FRAME", next ) )
    {
        buf = next;
        return ins_frame( buf, fref, build, next );
    }

    // ==========================================================
    else if ( strskip( buf, "CIRCLE", next ) )
    {
        buf = next;
        return ins_circle( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "LINE", next ) )
    {
        buf = next;
        return ins_line( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "POINT", next ) )
    {
        buf = next;
        return ins_point( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "POLYLINE", next ) )
    {
        buf = next;
        return ins_polyline( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "POLYGON", next ) )
    {
        buf = next;
        return ins_polygon( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "STRING", next ) )
    {
        buf = next;
        return ins_string( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "GRID", next ) )
    {
        buf = next;
        return ins_grid( buf, fref, build, next );
    }

    // ==========================================================

    else if ( strskip( buf, "STR_GRID", next ) )
    {
        buf = next;
        return ins_string_grid( buf, fref, build, next );
    }

    else
    {
        return CMD_ERR;
    }

    return CMD_OK;
}