/*
PolyGun

Copyright (c) 2023 mrkubax10 <mrkubax10@onet.pl>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef POLYGUN_UTILS_COMMAND_ARGUMENT_PARSER_HPP
#define POLYGUN_UTILS_COMMAND_ARGUMENT_PARSER_HPP

#include <config.hpp>
#include <string>

namespace polygun::utils {
	class CommandArgumentsParser final {
	public:
		CommandArgumentsParser(int argc, char** argv);
		~CommandArgumentsParser() = default;

		void parse();

#if defined(BUILD_SERVER)
		bool start_server() const { return m_start_server; }
#if defined(BUILD_CLIENT)
		const std::string& get_host_server_nickname() const { return m_host_server_nickname; }
		bool host_server() const { return m_host_server; }
#endif
#endif
#if defined(BUILD_CLIENT)
		bool connect_to() const { return !m_connect_ip.empty(); }
		const std::string& get_connect_nickname() const { return m_connect_nickname; }
		const std::string& get_connect_ip() const { return m_connect_ip; }
		unsigned short get_connect_port() const { return m_connect_port; }
#endif

	private:
#if defined(BUILD_SERVER)
		bool m_start_server;
#if defined(BUILD_CLIENT)
		std::string m_host_server_nickname;
		bool m_host_server;
#endif
#endif
#if defined(BUILD_CLIENT)
		std::string m_connect_nickname;
		std::string m_connect_ip;
		unsigned short m_connect_port;
#endif
		int m_argc;
		char** m_argv;

	private:
		void show_help();
	};	
}

#endif // POLYGUN_UTILS_COMMAND_ARGUMENT_PARSER_HPP
