diff --git a/include/popl.hpp b/include/popl.hpp index 8fd668b..8912438 100644 --- a/include/popl.hpp +++ b/include/popl.hpp @@ -380,6 +380,16 @@ class OptionParser template std::shared_ptr get_option(char short_name) const; + /// Check if an option is set by it's long name + /// @param the Option's long name + /// @return true if set at least once + bool is_set(const std::string& long_name) const; + + /// Check if an option is set by it's short name + /// @param the Option's long name + /// @return true if set at least once + bool is_set(char short_name) const; + protected: std::vector options_; std::string description_; @@ -940,6 +950,18 @@ inline std::shared_ptr OptionParser::get_option(char short_name) const return result; } +bool OptionParser::is_set(const std::string& long_name) const +{ + Option_ptr option = find_option(long_name); + return option && option->is_set(); +} + +bool OptionParser::is_set(char short_name) const +{ + Option_ptr option = find_option(short_name); + return option && option->is_set(); +} + inline void OptionParser::parse(const std::string& ini_filename) { std::ifstream file(ini_filename.c_str());