SOLIDstate
A C++ library for solid state physics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Argv.hpp
Go to the documentation of this file.
1 
11 #ifndef INFO_ARGV_HPP
12 #define INFO_ARGV_HPP
13 
14 #include <unistd.h>
15 #include <iostream>
16 #include "Info.hpp"
17 
18 namespace solid
19 {
20 
25 {
26 
27 public:
28  static void Parse(int argc, char *argv[])
29  {
30  int option;
31  int returnCode = 0;
32  char optstring[] = ":cvf:";
33  while ((option = getopt(argc, argv, optstring)) != -1)
34  switch (option)
35  {
36  case 'c':
37  std::cout << "option -" << char(option) << " selected\n";
38  break;
39  case 'v':
40  Info::isVerbose = true;
41  break;
42  case 'f':
43  std::cout << "option -" << char(option) << " selected\n";
44  break;
45  case ':':
46  std::cout << "option -" << char(optopt) << " requires argument\n";
47  returnCode = 1;
48  break;
49  case '?':
50  default:
51  std::cout << "option -" << char(optopt) << " unknown\n";
52  returnCode = 1;
53  break;
54  }
55  //if (optind > 0)
56  // std::cout << "other arguments:\n";
57  for (; optind < argc; ++optind)
58  std::cout << "argv[" << optind << "] = '" << argv[optind] << "'\n";
59  }
60 };
61 
62 } // namespace solid
63 
64 #endif
static bool isVerbose
option isVerbose
Definition: Info.hpp:43
Info class header.
static void Parse(int argc, char *argv[])
Definition: Argv.hpp:28
simple argv class
Definition: Argv.hpp:24