findit.hh

Go to the documentation of this file.
00001 #include "std_cpp_includes.hh"
00002 
00009 template<typename T>
00010 std::string findit(std::string arg, char sep, size_t & pos, T & thingie, int & ierr) {
00011   std::string ret = "";
00012   // bail if at end already
00013   if (pos >= arg.size()) { return ret; }
00014   // skip over sep if currently there
00015   if (arg[pos]==sep) pos++;
00016   // save current initial position
00017   size_t posc=pos;
00018   // look for next sep, or end
00019   while (pos < arg.size() && arg[pos] != sep) pos++;
00020   // extract substring
00021   ret = arg.substr(posc,pos-posc);
00022   // convert to type T if possible
00023   stringstream alpha;
00024   if (ret != "") alpha << ret;
00025   alpha >> thingie;
00026   // success flag
00027   ierr=0;
00028   if ( (alpha.rdstate() & std::ifstream::failbit ) != 0 ) ierr=1;
00029   // return value is substring
00030   return ret;
00031 }
00032 
00033 

Generated on 5 Jan 2017 for IWAVEBASE by  doxygen 1.4.7