TF++, Miscellaneous classes and modules in C++:

◆ main()

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

Definition at line 69 of file filetest.cc.

References tfxx::cmdline::arg_no, tfxx::cmdline::Commandline::extra(), FILETEST_VERSION, tfxx::cmdline::Commandline::next(), tfxx::cmdline::Commandline::optset(), and testfile().

70 {
71 
72  // define usage information
73  char usage_text[]=
74  {
75  FILETEST_VERSION "\n"
76  "usage: filetest" "\n"
77  " or: filetest --help|-h" "\n"
78  };
79 
80  // define full help text
81  char help_text[]=
82  {
83  FILETEST_CVSID
84  };
85 
86  // define commandline options
87  using namespace tfxx::cmdline;
88  static Declare options[]=
89  {
90  // 0: print help
91  {"help",arg_no,"-"},
92  // 1: verbose mode
93  {"v",arg_no,"-"},
94  {NULL}
95  };
96 
97  // no arguments? print usage...
98  if (iargc<2)
99  {
100  cerr << usage_text << endl;
101  exit(0);
102  }
103 
104  // collect options from commandline
105  Commandline cmdline(iargc, argv, options);
106 
107  // help requested? print full help text...
108  if (cmdline.optset(0))
109  {
110  cerr << usage_text << endl;
111  cerr << help_text << endl;
112  exit(0);
113  }
114 
115  /*
116  // dummy operation: print option settings
117  for (int iopt=0; iopt<2; iopt++)
118  {
119  cout << "option: '" << options[iopt].opt_string << "'" << endl;
120  if (cmdline.optset(iopt)) { cout << " option was set"; }
121  else { cout << "option was not set"; }
122  cout << endl;
123  cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
124  cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
125  cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
126  cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
127  cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
128  cout << " argument (bool): '";
129  if (cmdline.bool_arg(iopt))
130  { cout << "true"; } else { cout << "false"; }
131  cout << "'" << endl;
132  }
133  while (cmdline.extra()) { cout << cmdline.next() << endl; }
134  */
135 
136  while (cmdline.extra()) { testfile(cmdline.next()); }
137 }
void testfile(const std::string &s)
Definition: filetest.cc:54
Namespace containing all components of module commandline. ,.
Definition: commandline.cc:41
#define FILETEST_VERSION
Definition: filetest.cc:35
Evaluates commandline by calling long_getopt. ,You may instantiate a Commandline object by passing th...
Definition: commandline.h:201
struct to define options ,This struct is used to define a list of options. An example is: ...
Definition: commandline.h:136
option has no argument
Definition: commandline.h:100
Here is the call graph for this function: