DATRW++ library: seismic data I/O with multiple formats

◆ stringtovec()

Tvos datrw::tsoft::stringtovec ( const std::string &  line,
const std::string &  delimiters 
)

helper function stringtok

Definition at line 341 of file tsoftdata.cc.

Referenced by schannelid(), datrw::tsoft::Channelinfo::setchannelinfo(), and tchannelid().

343  {
344  Tvos result;
345  const string::size_type len = line.length();
346  string::size_type i = 0;
347 
348  while ( i < len )
349  {
350  // eat leading whitespace
351  i = line.find_first_not_of (" ", i);
352  if (i == string::npos)
353  return result; // nothing left but white space
354 
355  // find the end of the token
356  string::size_type j = line.find_first_of (delimiters, i);
357 
358  // push token
359  if (j == string::npos) {
360  result.push_back (line.substr(i));
361  return result;
362  } else
363  result.push_back (line.substr(i, j-i));
364 
365  // set up for next loop
366  i = j + 1;
367  }
368  return result;
369  } // Tvos stringtovec(const std::string& line,
std::vector< std::string > Tvos
vector of strings.
Definition: tsoftdata.h:104
Here is the caller graph for this function: