STFINV library: seek source wavelet correction filter
parameterhandler.cc
Go to the documentation of this file.
1 
36 #define STFINV_PARAMETERHANDLER_CC_VERSION \
37  "STFINV_PARAMETERHANDLER_CC V1.1"
38 
39 #include <algorithm>
41 
42 std::string stfinv::tools::clipstring(std::string& s, const std::string& delim)
43 {
44  std::string::size_type i=s.find(delim);
45  std::string result;
46  if ((i>=0) && (i<s.length())) {
47  result=s.substr(0,i);
48  s.erase(0,i+delim.length());
49  } else {
50  result=s;
51  s.erase();
52  }
53  return(result);
54 } // std::string stfinv::tools::clipstring()
55 
56 /*----------------------------------------------------------------------*/
57 
59  const std::string& delimiter,
60  const std::string& assign)
61 {
62  std::string pstring=p;
64  while (pstring.length()>0)
65  {
66  std::string para=stfinv::tools::clipstring(pstring, delimiter);
67  std::string key=stfinv::tools::clipstring(para, assign);
68  retval.insert(make_pair(key, para));
69  }
70  return retval;
71 } // stfinv::tools::Tparamap stfinv::tools::makeparamap()
72 
73 /*----------------------------------------------------------------------*/
74 
75 std::string stfinv::tools::secomtospace(std::string s)
76 {
77  std::replace(s.begin(), s.end(), ',', ' ');
78  std::replace(s.begin(), s.end(), ';', ' ');
79  return(s);
80 } // std::string stfinv::tools::secomtospace(const std::string& s)
81 
82 /*----------------------------------------------------------------------*/
83 
84 // \brief remove leading and trailing whitespace
85 std::string stfinv::tools::trimws(std::string s)
86 {
87  if (s.length()>0)
88  {
89  std::string::size_type ib=s.find_first_not_of(" ", 0);
90  if (ib==std::string::npos)
91  {
92  s="";
93  }
94  else
95  {
96  std::string::size_type il=s.find_last_not_of(" \r", s.length());
97  std::string::size_type n=il>=ib ? il-ib+1 : 0;
98  if (n==0) { ib = 0; }
99  if ((ib!=0) || (n!=s.length())) { s=s.substr(ib,n); }
100  }
101  }
102  return(s);
103 } // std::string trimws(std::string s)
104 
105 /* ----- END OF parameterhandler.cc ----- */
Tparamap makeparamap(const std::string &p, const std::string &delimiter=":", const std::string &assign="=")
Create a parameter map from a parameter string.
std::map< std::string, std::string > Tparamap
A map to store parameters.
handle a parameter configuration string (prototypes)
std::string trimws(std::string s)
remove leading and trailing whitespace
std::string secomtospace(std::string s)
std::string clipstring(std::string &s, const std::string &delim=":")