summaryrefslogtreecommitdiffstats
path: root/src/CommandLineOptions.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2011-03-05 16:09:54 +0100
committerJonathan Bauer2011-03-05 16:09:54 +0100
commitcf9609c876318f0c27914a723af915a9acfdbcc3 (patch)
treefcf2b5477835528b00c7ba3cacd7cd240ae57e86 /src/CommandLineOptions.cpp
parentwebkitTest.html: resetting of progress bar when download finishes. (diff)
downloadfbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.tar.gz
fbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.tar.xz
fbgui-cf9609c876318f0c27914a723af915a9acfdbcc3.zip
Command line options parsing moved to its own class, in preparation for Settings
Diffstat (limited to 'src/CommandLineOptions.cpp')
-rw-r--r--src/CommandLineOptions.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/CommandLineOptions.cpp b/src/CommandLineOptions.cpp
new file mode 100644
index 0000000..fae5c29
--- /dev/null
+++ b/src/CommandLineOptions.cpp
@@ -0,0 +1,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(){
+
+}