spot  2.11.6
optionmap.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2013, 2015, 2016-2017, 2022 Laboratoire de Recherche
3 // et Developpement de l'Epita (LRDE)
4 // Copyright (C) 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
5 // département Systèmes Répartis Coopératifs (SRC), Université Pierre
6 // et Marie Curie.
7 //
8 // This file is part of Spot, a model checking library.
9 //
10 // Spot is free software; you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Spot is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 #pragma once
24 
25 #include <spot/misc/common.hh>
26 #include <string>
27 #include <map>
28 #include <iosfwd>
29 #include <set>
30 
31 namespace spot
32 {
37  class SPOT_API option_map
38  {
39  public:
47 
55  const char* parse_options(const char* options);
56 
62  int get(const char* option, int def = 0) const;
63 
69  std::string get_str(const char* option, std::string def = {}) const;
70 
75  int operator[](const char* option) const;
76 
81  int set(const char* option, int val, int def = 0);
82 
84  void set_if_unset(const char* option, int val);
85 
90  std::string set_str(const char* option,
91  std::string val, std::string def = {});
92 
94  void report_unused_options() const;
95 
97  void set(const option_map& o);
98 
100  int& operator[](const char* option);
101 
103  friend SPOT_API std::ostream&
104  operator<<(std::ostream& os, const option_map& m);
105 
106  private:
107  std::map<std::string, int> options_;
108  std::map<std::string, std::string> options_str_;
109  // Unused values. Initially they will store all options, and they
110  // will be erased as they are used. The resulting set can be used
111  // for diagnosing errors.
112  mutable std::set<std::string> unused_;
113  mutable bool is_used_ = false;
114 
115  void set_(const std::string&, int val);
116  void set_str_(const std::string&, const std::string& val);
117  };
118 }
Manage a map of options.
Definition: optionmap.hh:38
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:27

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