summaryrefslogtreecommitdiffstats
path: root/src/CommandLineOptions.cpp
blob: fae5c29d2ec4c370c8a2a6f154e5cc98afe1b27c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * This class parses the command line options.
 */


#include <getopt.h>
#include <cstdlib>
#include "CommandLineOptions.h"

CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){
	// Parse command line arguments.
	int longIndex = 0;
	// Declare the short options as a char*, these have exactly one - followed by letter from optString.
	// For example: ./fbbrowser -h
	// Declare the long options in the const struct, these have two - followed by a string found in longOpts[].
	// Same as:     ./fbbrowser --help
	// Note: I included 'qwsdiplay' here to not have errors, when setting fbbrowser to be the server app aswell.
	static const char *optString = "hqwsdiplay";
	static const struct option longOpts[] =
	{
	    // If an option requires parameters, write this number instead of no_argument.
	    // The last argument, is the corresponding char to the option string.
		{"debug", no_argument, NULL, 'D'},
		{"help", no_argument, NULL, 'h'}
	};
	// getopt_long returns the index of the next argument to be read, -1 if there are no more arguments.
	int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
	while (opt != -1)
	{
		switch(opt)
	    {
	    case 'h':
	        //printUsage();
	        break;
	    }
	    opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
	}
}

CommandLineOptions::~CommandLineOptions(){

}