spot  2.12.2
optionmap.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) by the Spot authors, see the AUTHORS file for details.
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #pragma once
20 
21 #include <spot/misc/common.hh>
22 #include <string>
23 #include <map>
24 #include <iosfwd>
25 #include <set>
26 
27 namespace spot
28 {
33  class SPOT_API option_map
34  {
35  public:
43 
51  const char* parse_options(const char* options);
52 
58  int get(const char* option, int def = 0) const;
59 
65  std::string get_str(const char* option, std::string def = {}) const;
66 
71  int operator[](const char* option) const;
72 
77  int set(const char* option, int val, int def = 0);
78 
80  void set_if_unset(const char* option, int val);
81 
86  std::string set_str(const char* option,
87  std::string val, std::string def = {});
88 
90  void report_unused_options() const;
91 
93  void set(const option_map& o);
94 
96  int& operator[](const char* option);
97 
99  friend SPOT_API std::ostream&
100  operator<<(std::ostream& os, const option_map& m);
101 
102  private:
103  std::map<std::string, int> options_;
104  std::map<std::string, std::string> options_str_;
105  // Unused values. Initially they will store all options, and they
106  // will be erased as they are used. The resulting set can be used
107  // for diagnosing errors.
108  mutable std::set<std::string> unused_;
109  mutable bool is_used_ = false;
110 
111  void set_(const std::string&, int val);
112  void set_str_(const std::string&, const std::string& val);
113  };
114 }
Manage a map of options.
Definition: optionmap.hh:34
void report_unused_options() const
Raise a runtime_error if some options have not been used.
std::string get_str(const char *option, std::string def={}) const
Get the value of option.
std::string set_str(const char *option, std::string val, std::string def={})
Set the value of a string option to val.
void set(const option_map &o)
Acquire all the settings of o.
int & operator[](const char *option)
Get a reference to the current value of option.
void set_if_unset(const char *option, int val)
Set the value of option to val if it is unset.
const char * parse_options(const char *options)
Add the parsed options to the map.
int set(const char *option, int val, int def=0)
Set the value of option to val.
int get(const char *option, int def=0) const
Get the value of option.
int operator[](const char *option) const
Get the value of option.
Definition: automata.hh:26

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1