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

◆ trimws()

std::string datrw::util::trimws ( std::string  s)

remove leading and trailing whitespace

Parameters
sany string
Returns
value a input string with any leading and trailing whitespace removed

Definition at line 129 of file util.cc.

Referenced by datrw::tsoft::channel(), datrw::formatmodifiers::makeparamap(), and datrw::iasciistream::readheader().

130  {
131  if (s.length()>0)
132  {
133  std::string::size_type ib=s.find_first_not_of(" ", 0);
134  if (ib==std::string::npos)
135  {
136  s="";
137  }
138  else
139  {
140  std::string::size_type il=s.find_last_not_of(" \r", s.length());
141  std::string::size_type n=il>=ib ? il-ib+1 : 0;
142  if (n==0) { ib = 0; }
143  if ((ib!=0) || (n!=s.length())) { s=s.substr(ib,n); }
144  }
145  }
146  return(s);
147  } // std::string trimws(std::string s)
Here is the caller graph for this function: