diff --git a/slsReceiverSoftware/src/CommandLineOptions.cpp b/slsReceiverSoftware/src/CommandLineOptions.cpp index e64ea97b6..34a0882be 100644 --- a/slsReceiverSoftware/src/CommandLineOptions.cpp +++ b/slsReceiverSoftware/src/CommandLineOptions.cpp @@ -11,6 +11,10 @@ #include #include +CommandLineOptions::CommandLineOptions(AppType app) + : appType_(app), optString_(buildOptString()), + longOptions_(buildOptionList()) {} + /** for testing */ ParsedOptions CommandLineOptions::parse(const std::vector &args) { std::vector argv; @@ -28,13 +32,11 @@ ParsedOptions CommandLineOptions::parse(int argc, char *argv[]) { FrameSyncOptions frame; base.port = DEFAULT_TCP_RX_PORTNO; - auto optString = buildOptString(); - auto longOptions = buildOptionList(); optind = 0; // reset getopt int opt, option_index = 0; - while ((opt = getopt_long(argc, argv, optString.c_str(), longOptions.data(), - &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, optString_.c_str(), + longOptions_.data(), &option_index)) != -1) { switch (opt) { case 'v': case 'h': diff --git a/slsReceiverSoftware/src/CommandLineOptions.h b/slsReceiverSoftware/src/CommandLineOptions.h index 6a41dff5e..6bc7bc791 100644 --- a/slsReceiverSoftware/src/CommandLineOptions.h +++ b/slsReceiverSoftware/src/CommandLineOptions.h @@ -33,7 +33,7 @@ using ParsedOptions = class CommandLineOptions { public: - constexpr explicit CommandLineOptions(AppType app) : appType_(app) {} + explicit CommandLineOptions(AppType app); ParsedOptions parse(const std::vector &args); // for testing ParsedOptions parse(int argc, char *argv[]); std::string getTypeString() const; @@ -46,6 +46,8 @@ class CommandLineOptions { private: AppType appType_; + std::string optString_; + std::vector