FDR  4.2.7(6ecbe5a21b71ab020e8fcaeccfe5ebaad0599f4f)
option.h
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 
7 #include <fdr/error.h>
8 
9 namespace FDR
10 {
13 {
14 public:
15  DisallowedOptionValueError(const std::string& key, const std::string& value);
16 };
17 
19 class UnknownOptionError : public Error
20 {
21 public:
22  UnknownOptionError(const std::string& key);
23 };
24 
29 class Option
30 {
31 public:
32  virtual ~Option()
33  {
34  }
35 
40  virtual std::vector<std::string> allowed_values() const = 0;
41 
43  virtual std::string default_value() const = 0;
44 
46  virtual std::string get() const = 0;
47 
49  virtual std::string description() const = 0;
50 
52  virtual std::string name() const = 0;
53 
60  virtual void set(const std::string& new_value) = 0;
61 
63  static const std::vector<std::shared_ptr<Option>>& options();
64 
68  static const std::shared_ptr<Option>& get_option(const std::string& option_name);
69 };
70 
71 } // end FDR
FDR::Option::set
virtual void set(const std::string &new_value)=0
Sets the value of the option.
FDR::DisallowedOptionValueError
Thrown when an option is set to a disallowed value.
Definition: option.h:13
FDR::Option::default_value
virtual std::string default_value() const =0
The default value of this option.
FDR::Option
A setting for FDR.
Definition: option.h:30
FDR::Option::get_option
static const std::shared_ptr< Option > & get_option(const std::string &option_name)
Returns the Option with the specified name.
FDR::Option::allowed_values
virtual std::vector< std::string > allowed_values() const =0
The values that the option is allowed to take.
FDR::Option::options
static const std::vector< std::shared_ptr< Option > > & options()
Returns a list of all the options available.
FDR::Option::get
virtual std::string get() const =0
The current value of this option.
FDR::Error
An error thrown by libfdr.
Definition: error.h:11
FDR::Option::name
virtual std::string name() const =0
The current value of the option.
FDR::UnknownOptionError
Thrown when an option is not known (i.e. the key is invalid).
Definition: option.h:20
FDR::Option::description
virtual std::string description() const =0
A human-readable description of the option.