Program Listing for File ArgsParser.hpp¶
↰ Return to documentation for file (gui/ArgsParser.hpp)
#pragma once
#include <cstdint>
#include <string>
extern const std::string GUI_USAGE; // Usage message for the GUI
struct Args {
private:
std::string host; // Server hostname, NULL-terminated
uint16_t port; // Range between 1024 and 65535
bool help = false; // Display help message
static uint16_t ParseNumber(
const std::string &arg,
const char *name,
uint16_t min,
uint16_t max);
bool Dispatcher(char *argv[], int opt); // NOLINT
public:
[[nodiscard]] bool GetHelp() const
{
return help;
}
[[nodiscard]] const std::string &GetHost() const
{
return host;
}
[[nodiscard]] uint16_t GetPort() const
{
return port;
}
bool Parse(int argc, char *argv[]); // NOLINT
[[nodiscard]] std::string ToString() const;
friend std::ostream &operator<<(std::ostream &os, const Args &args)
{
os << args.ToString();
return os;
}
};