STFINV library: seek source wavelet correction filter

◆ main()

int main ( int  iargc,
char *  argv[] 
)

Definition at line 56 of file tooltest.cc.

References Options::clipstring, stfinv::tools::clipstring(), stfinv::tools::makeparamap(), Options::mapstring, Options::testclip, Options::testmap, TOOLTEST_VERSION, and Options::verbose.

57 {
58 
59  // define usage information
60  char usage_text[]=
61  {
62  TOOLTEST_VERSION "\n"
63  "usage: tooltest [-clip string] [-map string]" "\n"
64  " or: tooltest --help|-h" "\n"
65  };
66 
67  // define full help text
68  char help_text[]=
69  {
70  TOOLTEST_CVSID
71  };
72 
73  // define commandline options
74  using namespace tfxx::cmdline;
75  static Declare options[]=
76  {
77  // 0: print help
78  {"help",arg_no,"-"},
79  // 1: verbose mode
80  {"v",arg_no,"-"},
81  // 2: verbose mode
82  {"clip",arg_yes,"-"},
83  // 3: verbose mode
84  {"map",arg_yes,"-"},
85  {NULL}
86  };
87 
88  // no arguments? print usage...
89  if (iargc<2)
90  {
91  cerr << usage_text << endl;
92  exit(0);
93  }
94 
95  // collect options from commandline
96  Commandline cmdline(iargc, argv, options);
97 
98  // help requested? print full help text...
99  if (cmdline.optset(0))
100  {
101  cerr << usage_text << endl;
102  cerr << help_text << endl;
103  exit(0);
104  }
105 
106  Options opt;
107  opt.verbose=cmdline.optset(1);
108  opt.testclip=cmdline.optset(2);
109  opt.clipstring=cmdline.string_arg(2);
110  opt.testmap=cmdline.optset(3);
111  opt.mapstring=cmdline.string_arg(3);
112 
113  // dummy operation: print rest of command line
114  if (opt.verbose)
115  {
116  cout << "part of command line which was not parsed:" << endl;
117  }
118  while (cmdline.extra()) { cout << cmdline.next() << endl; }
119 
120  /*----------------------------------------------------------------------*/
121 
122  if (opt.testclip)
123  {
124  if (opt.verbose)
125  {
126  cout << endl;
127  cout << "Test stfinv::tools::clipstring with default delimiter"
128  << endl;
129  }
130  std::string s=opt.clipstring;
131  cout << "remainder is: " << s << endl;
132  while (s.length()>0)
133  {
134  cout << "stripped off: " << stfinv::tools::clipstring(s) << endl;
135  cout << "remainder is: " << s << endl;
136  }
137  std::string delim="++";
138  if (opt.verbose)
139  {
140  cout << endl;
141  cout << "Test stfinv::tools::clipstring with delimiter "
142  << delim << endl;
143  }
144  s=opt.clipstring;
145  cout << "remainder is: " << s << endl;
146  while (s.length()>0)
147  {
148  cout << "stripped off: " << stfinv::tools::clipstring(s,delim) << endl;
149  cout << "remainder is: " << s << endl;
150  }
151  } // if (opt.testclip)
152 
153  /*----------------------------------------------------------------------*/
154 
155  if (opt.testmap)
156  {
157  if (opt.verbose)
158  {
159  cout << endl;
160  cout << "Test stfinv::tools::makeparamap with default delimiter"
161  << endl;
162  }
164 
165  std::string liststring=paramap["list"];
166  std::replace(liststring.begin(), liststring.end(),',',' ');
167  cout << liststring << endl;
168 
169  } // if (opt.testmap)
170 
171 }
Tparamap makeparamap(const std::string &p, const std::string &delimiter=":", const std::string &assign="=")
Create a parameter map from a parameter string.
bool testclip
Definition: tooltest.cc:50
std::string clipstring
Definition: tooltest.cc:51
std::map< std::string, std::string > Tparamap
A map to store parameters.
#define TOOLTEST_VERSION
Definition: tooltest.cc:35
bool verbose
Definition: tooltest.cc:50
bool testmap
Definition: tooltest.cc:50
std::string mapstring
Definition: tooltest.cc:51
std::string clipstring(std::string &s, const std::string &delim=":")
Here is the call graph for this function: