diff options
author | Matt Spinler <spinler@us.ibm.com> | 2018-09-07 12:41:05 -0500 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2018-09-28 08:24:53 -0500 |
commit | dd9458613b8745177ad2a7e0519277654f4834f5 (patch) | |
tree | 7ee5a2a630db8e14abc832f3ca46761d858ca10b /src/argument.hpp | |
parent | 605206314f23710ef8a429745f139c891630588f (diff) | |
download | phosphor-objmgr-dd9458613b8745177ad2a7e0519277654f4834f5.tar.gz phosphor-objmgr-dd9458613b8745177ad2a7e0519277654f4834f5.zip |
Add service and interface whitelist/blacklists
This allows service whitelists and blacklists, and
interface whitelists to be passed into the application.
The whitelists can be prefixes, like xyz.openbmc_project.
The blacklist is the full service name.
A future commit can add support for interface blacklists.
Change-Id: I91f6ef2f7be63e4d13ac03d570bba18ef8277fae
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'src/argument.hpp')
-rw-r--r-- | src/argument.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/argument.hpp b/src/argument.hpp new file mode 100644 index 0000000..71a2c76 --- /dev/null +++ b/src/argument.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include <getopt.h> + +#include <map> +#include <string> + +/** @brief Class - Encapsulates parsing command line options and + * populating arguments + */ +class ArgumentParser +{ + public: + ArgumentParser() = delete; + ~ArgumentParser() = default; + ArgumentParser(const ArgumentParser&) = delete; + ArgumentParser& operator=(const ArgumentParser&) = delete; + ArgumentParser(ArgumentParser&&) = default; + ArgumentParser& operator=(ArgumentParser&&) = default; + + /** @brief Constructs Argument object + * + * @param argc - the main function's argc passed as is + * @param argv - the main function's argv passed as is + * @return Object constructed + */ + ArgumentParser(int argc, char** argv); + + /** @brief Given a option, returns its argument(optarg) */ + const std::string& operator[](const std::string& opt); + + /** @brief Displays usage */ + static void usage(char** argv); + + /** @brief Set to 'true' when an option is passed */ + static const std::string true_string; + + /** @brief Set to '' when an option is not passed */ + static const std::string empty_string; + + private: + /** @brief Option to argument mapping */ + std::map<const std::string, std::string> arguments; + + /** @brief Array of struct options as needed by getopt_long */ + static const option options[]; + + /** @brief optstring as needed by getopt_long */ + static const char* optionstr; +}; |