CBMC
options.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Options
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_UTIL_OPTIONS_H
13 #define CPROVER_UTIL_OPTIONS_H
14 
15 #include <string>
16 #include <map>
17 #include <list>
18 
19 class json_objectt;
20 class xmlt;
21 
22 class optionst
23 {
24 public:
25  typedef std::list<std::string> value_listt;
26  typedef std::map<std::string, value_listt> option_mapt;
27 
28  const std::string get_option(const std::string &option) const;
29  bool get_bool_option(const std::string &option) const;
30  signed int get_signed_int_option(const std::string &option) const;
31  unsigned int get_unsigned_int_option(const std::string &option) const;
32  const value_listt &get_list_option(const std::string &option) const;
33 
35  bool is_set(const std::string &option) const;
36 
37  void set_option(const std::string &option, const bool value);
38  void set_option(const std::string &option, const int value);
39  void set_option(const std::string &option, const unsigned value);
40  void set_option(const std::string &option, const std::string &value);
41 
42  void set_option(const std::string &option, const char *value)
43  {
44  set_option(option, std::string(value));
45  }
46 
47  void set_option(const std::string &option, const value_listt &values)
48  {
49  option_map[option]=values;
50  }
51 
52  optionst() { }
53  ~optionst() { }
54 
55  optionst &operator=(const optionst &other)
56  {
57  option_map=other.option_map;
58  return *this;
59  }
60 
61  json_objectt to_json() const;
62  xmlt to_xml() const;
63  void output(std::ostream &out) const;
64 
65 protected:
68 };
69 
70 #endif // CPROVER_UTIL_OPTIONS_H
unsigned int get_unsigned_int_option(const std::string &option) const
Definition: options.cpp:56
optionst()
Definition: options.h:52
void set_option(const std::string &option, const char *value)
Definition: options.h:42
bool is_set(const std::string &option) const
N.B. opts.is_set("foo") does not imply opts.get_bool_option("foo")
Definition: options.cpp:62
json_objectt to_json() const
Returns the options as JSON key value pairs.
Definition: options.cpp:93
const value_listt empty_list
Definition: options.h:67
option_mapt option_map
Definition: options.h:66
void set_option(const std::string &option, const value_listt &values)
Definition: options.h:47
bool get_bool_option(const std::string &option) const
Definition: options.cpp:44
optionst & operator=(const optionst &other)
Definition: options.h:55
void set_option(const std::string &option, const bool value)
Definition: options.cpp:28
const std::string get_option(const std::string &option) const
Definition: options.cpp:67
~optionst()
Definition: options.h:53
xmlt to_xml() const
Returns the options in XML format.
Definition: options.cpp:104
std::map< std::string, value_listt > option_mapt
Definition: options.h:26
void output(std::ostream &out) const
Outputs the options to out
Definition: options.cpp:121
signed int get_signed_int_option(const std::string &option) const
Definition: options.cpp:50
const value_listt & get_list_option(const std::string &option) const
Definition: options.cpp:80
std::list< std::string > value_listt
Definition: options.h:25
Definition: xml.h:21