Fortran SFF API to data I/O streams in C++

◆ trimws()

std::string fapidxx::trimws ( std::string  s)

remove whitespace at begin and end of string

remove whitespace at beginning and end of string

Definition at line 82 of file helper.cc.

83  {
84  if (s.length()>0)
85  {
86  string::size_type ib=s.find_first_not_of(" ", 0);
87  if (ib==string::npos)
88  {
89  s="";
90  }
91  else
92  {
93  string::size_type il=s.find_last_not_of(" \r", s.length());
94  string::size_type n=il>=ib ? il-ib+1 : 0;
95  if (n==0) { ib = 0; }
96  if ((ib!=0) || (n!=s.length())) { s=s.substr(ib,n); }
97  }
98  }
99  return(s);
100  } // std::string trimws(std::string s)