// SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once #include #include #include #include #include #include enum class AppType { MultiReceiver, SingleReceiver, FrameSynchronizer }; struct CommonOptions { uint16_t port = -1; uid_t userid = -1; bool versionRequested = false; bool helpRequested = false; }; struct MultiReceiverOptions : CommonOptions { uint16_t numReceivers = 1; bool callbackEnabled = false; }; struct FrameSyncOptions : CommonOptions { uint16_t numReceivers = 1; bool printHeaders = false; }; using ParsedOptions = std::variant; class CommandLineOptions { public: explicit CommandLineOptions(AppType app); ParsedOptions parse(const std::vector &args); // for testing ParsedOptions parse(int argc, char *argv[]); std::string getTypeString() const; std::string getVersion() const; std::string getHelpMessage() const; static void setEffectiveUID(uid_t uid); static std::tuple ParseDeprecated(const std::vector &args); private: AppType appType_; std::string optString_; std::vector