1 #ifndef _interface__setting__hpp__included__
2 #define _interface__setting__hpp__included__
11 struct core_setting_group
;
14 * A value for setting (structure).
16 struct core_setting_value_param
24 * A setting (structure)
26 struct core_setting_param
31 std::vector
<core_setting_value_param
> values
;
36 * A value for setting.
38 struct core_setting_value
41 * Create a new setting value.
43 core_setting_value(const core_setting_value_param
& p
) throw(std::bad_alloc
);
47 const std::string iname
;
49 * Human-readable value.
51 const std::string hname
;
64 * Create a new setting.
66 core_setting(const core_setting_param
& p
);
70 const std::string iname
;
72 * Human-readable name.
74 const std::string hname
;
76 * Regular expression for validation of fretext setting.
78 const std::string regex
;
82 const std::string dflt
;
86 std::vector
<core_setting_value
> values
;
88 * Is this setting a boolean?
90 bool is_boolean() const throw();
92 * Is this setting a freetext setting?
94 bool is_freetext() const throw();
96 * Get set of human-readable strings.
98 std::vector
<std::string
> hvalues() const throw(std::runtime_error
);
100 * Translate hvalue to ivalue.
102 std::string
hvalue_to_ivalue(const std::string
& hvalue
) const throw(std::runtime_error
);
104 * Translate ivalue to index.
106 signed ivalue_to_index(const std::string
& ivalue
) const throw(std::runtime_error
);
110 * Parameter value: The value to validate.
112 bool validate(const std::string
& value
) const;
116 * A group of settings.
118 struct core_setting_group
120 core_setting_group();
122 * Create a new group of settings.
124 core_setting_group(std::initializer_list
<core_setting_param
> settings
);
126 * Create a new group of settings.
128 core_setting_group(std::vector
<core_setting_param
> settings
);
132 std::map
<std::string
, core_setting
> settings
;
134 * Get specified setting.
136 core_setting
& operator[](const std::string
& name
) { return settings
.find(name
)->second
; }
138 * Translate ivalue to index.
140 signed ivalue_to_index(std::map
<std::string
, std::string
>& values
, const std::string
& name
) const
141 throw(std::runtime_error
)
143 return settings
.find(name
)->second
.ivalue_to_index(values
[name
]);
146 * Fill a map of settings with defaults.
148 void fill_defaults(std::map
<std::string
, std::string
>& values
) throw(std::bad_alloc
);
150 * Get set of settings.
152 std::set
<std::string
> get_setting_set();