From: Diego Barrios Romero Date: Wed, 17 Feb 2010 01:33:35 +0000 (+0100) Subject: Simplified code. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=63d3e2f564c1b725bfead19fe0ce28fb0cf502f5;p=synfig.git Simplified code. New function to extract a parameter value. Simplified iterators in loops. --- diff --git a/synfig-core/src/tool/main.cpp b/synfig-core/src/tool/main.cpp index 064959a..2beff60 100644 --- a/synfig-core/src/tool/main.cpp +++ b/synfig-core/src/tool/main.cpp @@ -382,116 +382,100 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) return SYNFIGTOOL_OK; } +/*! Extract a parameter from the argument list + * + * \param arg_list Argument list from wich the parameter is extracted. + * \param iter Iterator pointing to the argument list parameter to be + * extracted. + */ +string extract_parameter (arg_list_t& arg_list, + arg_list_t::iterator& iter) +{ + string parameter; + arg_list.erase(iter); + iter++; + parameter = *iter; + arg_list.erase(iter); + return parameter; +} + int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) { - arg_list_t::iterator iter, next; + arg_list_t::iterator iter; int w=0,h=0; float span=0; - for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) + for(iter=arg_list.begin(); iter!=arg_list.end(); iter++) { if(*iter=="-w") { - arg_list.erase(iter); - iter=next++; - w=atoi(iter->c_str()); - arg_list.erase(iter); + w = atoi(extract_parameter(arg_list, iter).c_str()); } else if(*iter=="-h") { - arg_list.erase(iter); - iter=next++; - h=atoi(iter->c_str()); - arg_list.erase(iter); + h = atoi(extract_parameter(arg_list, iter).c_str()); } else if(*iter=="-a") { int a; - arg_list.erase(iter); - iter=next++; - a=atoi(iter->c_str()); + a = atoi(extract_parameter(arg_list, iter).c_str()); desc.set_antialias(a); VERBOSE_OUT(1)<c_str()); + span = atoi(extract_parameter(arg_list, iter).c_str()); VERBOSE_OUT(1)<c_str()); + float fps = atof(extract_parameter(arg_list, iter).c_str()); desc.set_frame_rate(fps); - arg_list.erase(iter); VERBOSE_OUT(1)<c_str()); + float dpi = atof(extract_parameter(arg_list, iter).c_str()); float dots_per_meter=dpi*39.3700787402; desc.set_x_res(dots_per_meter).set_y_res(dots_per_meter); - arg_list.erase(iter); VERBOSE_OUT(1)<c_str()); + float dpi = atof(extract_parameter(arg_list, iter).c_str()); float dots_per_meter=dpi*39.3700787402; desc.set_x_res(dots_per_meter); - arg_list.erase(iter); VERBOSE_OUT(1)<c_str()); + float dpi = atof(extract_parameter(arg_list, iter).c_str()); float dots_per_meter=dpi*39.3700787402; desc.set_y_res(dots_per_meter); - arg_list.erase(iter); VERBOSE_OUT(1)<c_str()))); - arg_list.erase(iter); + //desc.set_gamma(Gamma(atoi(extract_parameter(arg_list, iter).c_str()))); } else if (flag_requires_value(*iter)) - iter=next++; + iter++; } if (w||h) { @@ -510,19 +494,16 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) int extract_quality(arg_list_t &arg_list,int &quality) { - arg_list_t::iterator iter, next; - for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) + arg_list_t::iterator iter; + for(iter=arg_list.begin(); iter!=arg_list.end(); iter++) { if(*iter=="-Q") { - arg_list.erase(iter); - iter=next++; - quality=atoi(iter->c_str()); + quality = atoi(extract_parameter(arg_list, iter).c_str()); VERBOSE_OUT(1)<c_str()); + threads = atoi(extract_parameter(arg_list, iter).c_str()); VERBOSE_OUT(1)<