src/stats/model/omnet-data-output.cc
changeset 7200 4e1d562d5029
parent 7189 a3a61f7d66ef
child 7252 c8200621e252
equal deleted inserted replaced
7199:eae56a101979 7200:4e1d562d5029
    55 }
    55 }
    56 
    56 
    57 //----------------------------------------------
    57 //----------------------------------------------
    58 
    58 
    59 inline bool isNumeric(const std::string& s) {
    59 inline bool isNumeric(const std::string& s) {
    60   char *endp;
    60   bool decimalPtSeen = false;
    61   double unused = strtod(s.c_str(), &endp); // declared with warn_unused_result
    61   bool exponentSeen = false;
    62   unused = unused; // quiet compiler
    62   char last = '\0';
    63   return endp == s.c_str() + s.size();
    63 
       
    64   for (std::string::const_iterator it = s.begin (); it != s.end (); it++)
       
    65     {
       
    66       if ((*it == '.') && (decimalPtSeen))
       
    67         return false;
       
    68       else if (*it == '.')
       
    69         decimalPtSeen = true;
       
    70       else if ((*it == 'e') && exponentSeen)
       
    71         return false;
       
    72       else if (*it == 'e')
       
    73         {
       
    74           exponentSeen = true;
       
    75           decimalPtSeen = false;
       
    76         }
       
    77       else if (*it == '-' && it != s.begin () && last != 'e')
       
    78         return false;
       
    79 
       
    80       last = *it;
       
    81     }
       
    82   return true;
    64 }
    83 }
    65 
    84 
    66 void
    85 void
    67 OmnetDataOutput::Output(DataCollector &dc)
    86 OmnetDataOutput::Output(DataCollector &dc)
    68 {
    87 {