
#ifndef _JL_COMMANDLINE_H_
#define _JL_COMMANDLINE_H_

#include "jlstring.h"

#define MAX_OPTIONS 100

struct CLOption {
	JLString	token;
	int			*toggle;
	int			*var_int;
	float		*var_float;
	char		**var_char;
	JLString	*var_string;
};
typedef struct CLOption CLOption, *CLOptionPtr;

class CommandLine {

	private:
		CLOptionPtr	_options[MAX_OPTIONS];
		int			_numoptions;
		int			_argc;
		char		**_argv;
		int			_index;
		int			_tokenless_count;
		int			_finish_add_option_flag;

		CommandLine& AddOption();

	public:
		CommandLine();
		CommandLine(int, char**);
		CommandLine(const CommandLine&);
		~CommandLine();

		CommandLine& AddOption(const JLString&, int*);
		CommandLine& AddOption(const JLString&, float*);
		CommandLine& AddOption(const JLString&, char**);
		CommandLine& AddOption(const JLString&, JLString*);
		CommandLine& AddToggle(const JLString&, int*);

		friend CommandLine& operator<<(CommandLine&, const char*);
		friend CommandLine& operator<<(CommandLine&, int&);
		friend CommandLine& operator<<(CommandLine&, float&);
		friend CommandLine& operator<<(CommandLine&, JLString&);

		CommandLine& SetVariable(int);
		CommandLine& CheckOption();
		CommandLine& CheckTokenless();
		CommandLine& ParseCommandLine();
};

#endif
