Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

Iterable* Impala::Util::ParseRangeDefinitionElement ( const std::string &  name,
std::string &  definition 
)

Definition at line 195 of file Iterable.h.

Referenced by ParseRangeDefinition().

00196 {
00197     if(definition.find(':') == std::string::npos)
00198         return 0;
00199     bool logarithmic = false;
00200     double logarithmicBase = 10.0;
00201     if(definition.substr(0,3) == "log")
00202     {
00203         logarithmic = true;
00204         definition = definition.substr(3);
00205         logarithmicBase = 10.0;
00206     }
00207     if(definition.substr(0,4) == "2log")
00208     {
00209         logarithmic = true;
00210         definition = definition.substr(4);
00211         logarithmicBase = 2.0;
00212     }
00213     std::istringstream iss(definition);
00214     double start, stop;
00215     int steps;
00216     char c;
00217     iss >> start >> c >> stop;
00218     if(c!=':')
00219     {
00220         std::cout << "[ParseRangeDefinitionElement] error " << definition << " is not a valid element\n";
00221         return 0; //syntax error;
00222     }
00223     iss >> c;
00224     if(!iss.eof())
00225     {
00226         iss >> steps;
00227         if(c != '/')
00228         {
00229             std::cout << "[ParseRangeDefinitionElement] error " << definition << " is not a valid element\n";
00230             return 0; //syntax error;
00231         }
00232     }
00233     else
00234         steps = fabs(stop - start) + 1;
00235 
00236     if(logarithmic)
00237         return new LogRange(name, start, stop, steps, logarithmicBase);
00238     return new Range(name, start, stop, steps, false);
00239 }


Generated on Fri Mar 19 11:39:08 2010 for ImpalaSrc by  doxygen 1.5.1