cprover
goto_cc_cmdline.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Command line interpretation for goto-cc
4 
5 Author: Daniel Kroening
6 
7 Date: April 2010
8 
9 \*******************************************************************/
10 
13 
14 #ifndef CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H
15 #define CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H
16 
17 #include <util/cmdline.h>
18 
20 {
21 public:
23 
24  using cmdlinet::parse;
25  virtual bool parse(int argc, const char **argv)=0;
26 
27  static bool in_list(const char *option, const char **list);
28 
29  static bool prefix_in_list(
30  const char *option,
31  const char **list,
32  std::string &prefix);
33 
34  // never fails, will add if not found
35  std::size_t get_optnr(const std::string &option);
36 
37  void set(const std::string &opt, const std::string &value)
38  {
39  std::size_t nr=get_optnr(opt);
40  options[nr].isset=true;
41  options[nr].values.push_back(value);
42  }
43 
44  void set(const std::string &opt)
45  {
46  options[get_optnr(opt)].isset=true;
47  }
48 
49  // This lets you distinguish input file name arguments
50  // from others, but is otherwise identical to the
51  // original command line.
52 
53  struct argt
54  {
55  public:
56  argt():is_infile_name(false) { }
57  explicit argt(const std::string &_arg):is_infile_name(false), arg(_arg) { }
59  std::string arg;
60  };
61 
62  typedef std::list<argt> parsed_argvt;
63  parsed_argvt parsed_argv;
64 
65  bool have_infile_arg() const
66  {
67  for(parsed_argvt::const_iterator
68  it=parsed_argv.begin(); it!=parsed_argv.end(); it++)
69  if(it->is_infile_name)
70  return true;
71  return false;
72  }
73 
74  std::string stdin_file;
75 
76 protected:
77  void add_arg(const std::string &arg)
78  {
79  parsed_argv.push_back(argt(arg));
80  }
81 
82  void add_infile_arg(const std::string &arg);
83 };
84 
85 #endif // CPROVER_GOTO_CC_GOTO_CC_CMDLINE_H
std::string stdin_file
std::size_t get_optnr(const std::string &option)
static bool prefix_in_list(const char *option, const char **list, std::string &prefix)
virtual bool parse(int argc, const char **argv, const char *optstring)
Definition: cmdline.cpp:116
static bool in_list(const char *option, const char **list)
void add_arg(const std::string &arg)
std::list< argt > parsed_argvt
virtual bool parse(int argc, const char **argv)=0
argt(const std::string &_arg)
bool have_infile_arg() const
parsed_argvt parsed_argv
std::vector< optiont > options
Definition: cmdline.h:58
void add_infile_arg(const std::string &arg)