Skip to content

Commit 6f24009

Browse files
committed
Can now test for an option being set in optionst
There was previously no public interface to check whether an option had been set in an optionst object; this meant that clients were instead using the isset() method of cmdlinet. This change allows us to set the options from the cmdlinet near the beginning of the front-end, and not refer to the cmdlinet afterward.
1 parent 0764f77 commit 6f24009

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/util/options.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ unsigned int optionst::get_unsigned_int_option(const std::string &option) const
5757
return value.empty()?0:safe_string2unsigned(value);
5858
}
5959

60+
bool optionst::is_set(const std::string &option) const
61+
{
62+
return option_map.find(option) != option_map.end();
63+
}
64+
6065
const std::string optionst::get_option(const std::string &option) const
6166
{
6267
option_mapt::const_iterator it=

src/util/options.h

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class optionst
2828
unsigned int get_unsigned_int_option(const std::string &option) const;
2929
const value_listt &get_list_option(const std::string &option) const;
3030

31+
/// N.B. opts.is_set("foo") does not imply opts.get_bool_option("foo")
32+
bool is_set(const std::string &option) const;
33+
3134
void set_option(const std::string &option, const bool value);
3235
void set_option(const std::string &option, const int value);
3336
void set_option(const std::string &option, const unsigned value);

0 commit comments

Comments
 (0)