瀏覽代碼

Switched to using a POSIX compliant argument parser. This will break scripts! sorry

naelstrof 7 年之前
父節點
當前提交
3b19860795
共有 6 個文件被更改,包括 1572 次插入343 次删除
  1. 2
    3
      CMakeLists.txt
  2. 4
    4
      README.md
  3. 1468
    0
      src/cxxopts.hpp
  4. 98
    29
      src/main.cpp
  5. 0
    246
      src/options.cpp
  6. 0
    61
      src/options.hpp

+ 2
- 3
CMakeLists.txt 查看文件

@@ -21,7 +21,7 @@ endif()
21 21
 
22 22
 include_directories("${PROJECT_BINARY_DIR}")
23 23
 
24
-add_definitions(-DSLOP_VERSION="v5.3.38")
24
+add_definitions(-DSLOP_VERSION="v6.3.38")
25 25
 
26 26
 # The names have to be unique unfortunately.
27 27
 set(EXECUTABLE_NAME "slop")
@@ -44,8 +44,7 @@ add_library(${LIBRARY_NAME} SHARED  src/mouse.cpp
44 44
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
45 45
 set_property(TARGET ${LIBRARY_NAME} PROPERTY CXX_STANDARD 11)
46 46
 
47
-add_executable(${EXECUTABLE_NAME} src/options.cpp
48
-                                  src/main.cpp)
47
+add_executable(${EXECUTABLE_NAME} src/main.cpp)
49 48
 
50 49
 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
51 50
 set_property(TARGET ${EXECUTABLE_NAME} PROPERTY CXX_STANDARD 11)

+ 4
- 4
README.md 查看文件

@@ -86,21 +86,21 @@ Shaders are loaded from the `--shader` flag in slop. They are delimited by comma
86 86
 Enough chatting about it though, here's some example shaders you can copy from [shaderexamples](https://github.com/naelstrof/slop/tree/master/shaderexamples) to `~/.config/slop` to try out!
87 87
 
88 88
 The files listed to the right of the `|` are the required files for the command to the left to work correctly.
89
-* `slop -rblur1,blur2 -b100` | `~/.config/slop/{blur1,blur2}{.frag,.vert}`
89
+* `slop -r blur1,blur2 -b 100` | `~/.config/slop/{blur1,blur2}{.frag,.vert}`
90 90
 
91 91
 ![slop blur](https://my.mixtape.moe/bvsrzr.png)
92 92
 
93
-* `slop -rwiggle -b10` | `~/.config/slop/wiggle{.frag,.vert}`
93
+* `slop -r wiggle -b 10` | `~/.config/slop/wiggle{.frag,.vert}`
94 94
 
95 95
 ![slop animation](http://i.giphy.com/12vjSbFZ0CWDW8.gif)
96 96
 
97 97
 And all together now...
98
-* `slop -rblur1,blur2,wiggle -b50 -c1,1,1` | `~/.config/slop/{blur1,blur2,wiggle}{.frag,.vert}`
98
+* `slop -r blur1,blur2,wiggle -b 50 -c 1,1,1` | `~/.config/slop/{blur1,blur2,wiggle}{.frag,.vert}`
99 99
 
100 100
 ![slop animation](http://i.giphy.com/kfBLafeJfLs2Y.gif)
101 101
 
102 102
 Finally here's an example of a magnifying glass.
103
-* `slop -rcrosshair` | `~/.config/slop/crosshair{.frag,.vert}`
103
+* `slop -r crosshair` | `~/.config/slop/crosshair{.frag,.vert}`
104 104
 
105 105
 ![slop animation](http://i.giphy.com/2xy0fC2LOFQfm.gif)
106 106
 

+ 1468
- 0
src/cxxopts.hpp
文件差異過大導致無法顯示
查看文件


+ 98
- 29
src/main.cpp 查看文件

@@ -20,8 +20,12 @@
20 20
 
21 21
 #include <iostream>
22 22
 #include <sstream>
23
+#include <string>
24
+#include <vector>
25
+#include <glm/glm.hpp>
26
+
27
+#include "cxxopts.hpp"
23 28
 #include "slop.hpp"
24
-#include "options.hpp"
25 29
 
26 30
 using namespace slop;
27 31
 
@@ -34,41 +38,79 @@ static void split(const std::string &s, char delim, Out result) {
34 38
         *(result++) = item;
35 39
     }
36 40
 }
41
+
37 42
 static std::vector<std::string> split(const std::string &s, char delim) {
38 43
     std::vector<std::string> elems;
39 44
     split(s, delim, std::back_inserter(elems));
40 45
     return elems;
41 46
 }
42 47
 
43
-SlopOptions* getOptions( Options& options ) {
44
-    SlopOptions* foo = new SlopOptions();
45
-    options.getFloat("bordersize", 'b', foo->borderSize);
46
-    options.getFloat("padding", 'p', foo->padding);
47
-    options.getFloat("tolerance", 't', foo->tolerance);
48
+glm::vec4 parseColor( std::string value ) {
49
+    std::string valuecopy = value;
50
+    glm::vec4 found;
51
+    std::string::size_type sz;
52
+    try {
53
+        found[0] = std::stof(value,&sz);
54
+        value = value.substr(sz+1);
55
+        found[1] = std::stof(value,&sz);
56
+        value = value.substr(sz+1);
57
+        found[2] = std::stof(value,&sz);
58
+        if ( value.size() != sz ) {
59
+            value = value.substr(sz+1);
60
+            found[3] = std::stof(value,&sz);
61
+            if ( value.size() != sz ) {
62
+                throw "dur";
63
+            }
64
+        } else {
65
+            found[3] = 1;
66
+        }
67
+    } catch ( ... ) {
68
+        throw new std::invalid_argument("Unable to parse value `" + valuecopy + "` as a color. Should be in the format r,g,b or r,g,b,a. Like 1,1,1,1.");
69
+    }
70
+    return found;
71
+}
72
+
73
+SlopOptions* getOptions( cxxopts::Options& options ) {
74
+    slop::SlopOptions* foo = new slop::SlopOptions();
75
+    if ( options.count( "bordersize" ) > 0 ) {
76
+        foo->borderSize = options["bordersize"].as<float>();
77
+    }
78
+    if ( options.count( "padding" ) > 0 ) {
79
+        foo->padding = options["padding"].as<float>();
80
+    }
81
+    if ( options.count( "tolerance" ) > 0 ) {
82
+        foo->tolerance = options["tolerance"].as<float>();
83
+    }
48 84
     glm::vec4 color = glm::vec4( foo->r, foo->g, foo->b, foo->a );
49
-    options.getColor("color", 'c', color);
50
-    options.getBool("nokeyboard", 'k', foo->nokeyboard);
51
-    options.getBool("noopengl", 'o', foo->noopengl);
52
-    options.getString( "xdisplay", 'x', foo->xdisplay );
53
-    std::string shaders = "textured";
54
-    options.getString( "shader", 'r', shaders );
55
-    foo->shaders = split( shaders, ',' );
85
+    if ( options.count( "color" ) > 0 ) {
86
+        color = parseColor( options["color"].as<std::string>() );
87
+    }
56 88
     foo->r = color.r;
57 89
     foo->g = color.g;
58 90
     foo->b = color.b;
59 91
     foo->a = color.a;
60
-    options.getBool("highlight", 'l', foo->highlight);
61
-    try {
62
-        bool test = false;
63
-        options.getBool("nodecorations", 'n', test);
64
-        if ( test ) {
65
-            foo->nodecorations = 1;
66
-        }
67
-    } catch( ... ) {
68
-        options.getInt("nodecorations", 'n', foo->nodecorations);
92
+    if ( options.count( "nokeyboard" ) > 0 ) {
93
+        foo->nokeyboard = options["nokeyboard"].as<bool>();
94
+    }
95
+    if ( options.count( "xdisplay" ) > 0 ) {
96
+        foo->xdisplay = options["xdisplay"].as<std::string>();
69 97
     }
70
-    if ( foo->nodecorations < 0 || foo->nodecorations > 2 ) {
71
-        throw new std::invalid_argument( "--nodecorations must be between 0 and 2. Or be used as a flag." );
98
+    std::string shaders = "textured";
99
+    if ( options.count( "shader" ) > 0 ) {
100
+        shaders = options["shader"].as<std::string>();
101
+    }
102
+    foo->shaders = split( shaders, ',' );
103
+    if ( options.count( "noopengl" ) > 0 ) {
104
+        foo->noopengl = options["noopengl"].as<bool>();
105
+    }
106
+    if ( options.count( "highlight" ) > 0 ) {
107
+        foo->highlight = options["highlight"].as<bool>();
108
+    }
109
+    if ( options.count( "nodecorations" ) > 0 ) {
110
+        foo->nodecorations = options["nodecorations"].as<int>();
111
+        if ( foo->nodecorations < 0 || foo->nodecorations > 2 ) {
112
+            throw new std::invalid_argument( "--nodecorations must be between 0 and 2. Or be used as a flag." );
113
+        }
72 114
     }
73 115
     return foo;
74 116
 }
@@ -184,16 +226,42 @@ void printHelp() {
184 226
 }
185 227
 
186 228
 int app( int argc, char** argv ) {
229
+    cxxopts::Options options("maim", "Screenshot application.");
230
+    options.add_options()
231
+    ("h,help", "Print help and exit.")
232
+    ("v,version", "Print version and exit.")
233
+    ("x,xdisplay", "Sets the xdisplay to use", cxxopts::value<std::string>())
234
+    ("f,format", "Sets the output format for slop. Format specifiers are  %x, %y, %w, %h, %i, %c, and %g. If actual percentage signs are desired in output, use a double percentage sign like so `%%`.", cxxopts::value<std::string>())
235
+    ("b,bordersize", "Sets the selection rectangle's thickness.", cxxopts::value<float>())
236
+    ("p,padding", "Sets the padding size for the selection, this can be negative.", cxxopts::value<float>())
237
+    ("t,tolerance", "How far in pixels the mouse can move after clicking, and still be detected as a normal click instead of a click-and-drag. Setting this to 0 will disable window selections. Alternatively setting it to 9999999 would force a window selection.", cxxopts::value<float>())
238
+    ("c,color", "Sets  the  selection  rectangle's  color.  Supports  RGB or RGBA input. Depending on the system's window manager/OpenGL  support, the opacity may be ignored.", cxxopts::value<std::string>())
239
+    ("r,shader", "This  sets  the  vertex shader, and fragment shader combo to use when drawing the final framebuffer to the screen. This obviously only  works  when OpenGL is enabled. The shaders are loaded from ~/.config/maim. See https://github.com/naelstrof/slop for more information on how to create your own shaders.", cxxopts::value<std::string>())
240
+    ("n,nodecorations", "Sets the level of aggressiveness when trying to remove window decroations. `0' is off, `1' will try lightly to remove decorations, and `2' will recursively descend into the root tree until it gets the deepest available visible child under the mouse. Defaults to `0'.", cxxopts::value<int>()->implicit_value("1"))
241
+    ("l,highlight", "Instead of outlining a selection, maim will highlight it instead. This is particularly useful if the color is set to an opacity lower than 1.")
242
+    ("q,quiet", "Disable any unnecessary cerr output. Any warnings or info simply won't print.")
243
+    ("k,nokeyboard", "Disables the ability to cancel selections with the keyboard.")
244
+    ("o,noopengl", "Disables graphics hardware acceleration.")
245
+    ;
246
+    options.parse(argc, argv);
187 247
     // Options just validates all of our input from argv
188
-    Options options( argc, argv );
189 248
     bool quiet = false;
190
-    options.getBool( "quiet", 'q', quiet );
249
+    if ( options.count( "quiet" ) > 0 ) {
250
+        quiet = options["quiet"].as<bool>();
251
+    }
191 252
     bool help = false;
192
-    if ( options.getBool( "help", 'h', help ) ) {
253
+    if ( options.count( "help" ) > 0 ) {
254
+        help = options["help"].as<bool>();
255
+    }
256
+    if ( help ) {
193 257
         printHelp();
194 258
         return 0;
195 259
     }
196
-    if ( options.getBool( "version", 'v', help ) ) {
260
+    bool version = false;
261
+    if ( options.count( "version" ) > 0 ) {
262
+        version = options["version"].as<bool>();
263
+    }
264
+    if ( version ) {
197 265
         std::cout << SLOP_VERSION << "\n";
198 266
         return 0;
199 267
     }
@@ -204,8 +272,9 @@ int app( int argc, char** argv ) {
204 272
     // on a fake selection.
205 273
     SlopSelection selection(0,0,0,0,0);
206 274
     std::string format;
207
-    bool gotFormat = options.getString("format", 'f', format);
275
+    bool gotFormat = options.count( "format" ) > 0;
208 276
     if ( gotFormat ) {
277
+        format = options["format"].as<std::string>();
209 278
         formatOutput( format, selection, false );
210 279
     }
211 280
 

+ 0
- 246
src/options.cpp 查看文件

@@ -1,246 +0,0 @@
1
-#include "options.hpp"
2
-
3
-Options::Options( int argc, char** argv ) {
4
-    validArguments.push_back( Argument( "nodecorations", 'n', true ) );
5
-    validArguments.push_back( Argument( "bordersize",   'b', false ) );
6
-    validArguments.push_back( Argument( "padding",      'p', false ) );
7
-    validArguments.push_back( Argument( "color",        'c', false ) );
8
-    validArguments.push_back( Argument( "shader",       'r', false ) );
9
-    validArguments.push_back( Argument( "highlight",    'l', true ) );
10
-    validArguments.push_back( Argument( "format",       'f', false ) );
11
-    validArguments.push_back( Argument( "tolerance",    't', false ) );
12
-    validArguments.push_back( Argument( "nokeyboard",   'k', true ) );
13
-    validArguments.push_back( Argument( "noopengl",     'o', true ) );
14
-    validArguments.push_back( Argument( "help",         'h', true ) );
15
-    validArguments.push_back( Argument( "xdisplay",     'x', false ) );
16
-    validArguments.push_back( Argument( "version",      'v', true ) );
17
-    validArguments.push_back( Argument( "quiet",        'q', true ) );
18
-    try {
19
-        validate( argc, argv );
20
-    } catch( ... ) {
21
-        arguments.clear();
22
-        values.clear();
23
-        floatingValues.clear();
24
-        validArguments[0].isFlagArgument = false;
25
-        validate( argc, argv );
26
-    }
27
-}
28
-
29
-
30
-int Options::validateStringOption( int argc, char** argv, int argumentIndex ) {
31
-    std::string argument = argv[argumentIndex];
32
-    unsigned int index = 0;
33
-    while( index < validArguments.size() ) {
34
-        Argument& check = validArguments[index];
35
-        for( unsigned int i=0;i<check.name.length();i++ ) {
36
-            if ( check.name[i] != argument[i+2] ) {
37
-                break;
38
-            }
39
-            if ( i == check.name.length()-1 ) {
40
-                if ( !check.isFlagArgument && argument.find("=") == std::string::npos ) {
41
-                    throw new std::invalid_argument("Expected `=` after " + argument);
42
-                }
43
-                if ( check.isFlagArgument && i+3 != argument.length() ) {
44
-                    throw new std::invalid_argument("Trailing characters on flag " + argument );
45
-                }
46
-                return parseStringOption( argc, argv, argumentIndex, index );
47
-            }
48
-        }
49
-        index++;
50
-    }
51
-    throw new std::invalid_argument("Invalid argument " + argument);
52
-    return 0;
53
-}
54
-
55
-int Options::parseCharOption( int argc, char** argv, int argumentIndex, int validIndex ) {
56
-    std::string argument = argv[argumentIndex];
57
-    Argument& check = validArguments[validIndex];
58
-    // If we're a flag, we take no arguments, nor do we allow = signs or whatever.
59
-    if ( check.isFlagArgument ) {
60
-        if ( argument != std::string()+"-"+check.cname ) {
61
-            for( int o=1;o<argument.length();o++ ) {
62
-                bool isValid = false;
63
-                for( int i=0;i<validArguments.size()&&!isValid;i++ ) {
64
-                    if ( argument[o] == check.cname ) {
65
-                        if ( check.isFlagArgument ) {
66
-                            isValid = true;
67
-                            arguments.push_back( std::string()+check.cname );
68
-                            values.push_back("");
69
-                            break;
70
-                        } else {
71
-                            throw new std::invalid_argument( std::string()+"Truncating non-flag arguments is not allowed. Split this up: `" + argument + "`." );
72
-                        }
73
-                    }
74
-                }
75
-                if (!isValid) {
76
-                    throw new std::invalid_argument( std::string()+"Unexpected characters around flag `" + argument + "`." );
77
-                }
78
-            }
79
-            return 1;
80
-        } else {
81
-            arguments.push_back( std::string()+argument[1] );
82
-            values.push_back("");
83
-            return 1;
84
-        }
85
-    }
86
-    arguments.push_back( std::string()+argument[1] );
87
-    // If they supplied the parameters with spaces
88
-    if ( argument == std::string()+"-"+check.cname ) {
89
-        if ( argumentIndex+1 < argc ) {
90
-            values.push_back(argv[argumentIndex+1]);
91
-        } else {
92
-            values.push_back("");
93
-        }
94
-        return 2;
95
-    }
96
-    // If they didn't supply the parameters with spaces
97
-    if ( argument[2] == '=' ) {
98
-        values.push_back(argument.substr(3));
99
-        return 1;
100
-    }
101
-    values.push_back(argument.substr(2));
102
-    return 1;
103
-}
104
-
105
-int Options::parseStringOption( int argc, char** argv, int argumentIndex, int validIndex ) {
106
-    std::string argument = argv[argumentIndex];
107
-    if ( validArguments[validIndex].isFlagArgument ) {
108
-        arguments.push_back( argument.substr(2) );
109
-        values.push_back("");
110
-        return 1;
111
-    }
112
-    arguments.push_back( argument.substr(2,argument.find_first_of('=')) );
113
-    values.push_back(argument.substr(argument.find_first_of('=')));
114
-    return 1;
115
-}
116
-
117
-int Options::validateCharOption( int argc, char** argv, int argumentIndex ) {
118
-    std::string argument = argv[argumentIndex];
119
-    unsigned int index = 0;
120
-    while( index < validArguments.size() ) {
121
-        char check = validArguments[index].cname;
122
-        if ( argument.length() < 2 ) {
123
-            continue;
124
-        }
125
-        if ( check == argument[1] && ( argument.find("=") == 2 || argument.find('=') == std::string::npos ) && argument[0] == '-' ) {
126
-            return parseCharOption( argc, argv, argumentIndex, index );
127
-        }
128
-        index++;
129
-    }
130
-    throw new std::invalid_argument("Invalid argument `" + argument + "`.");
131
-    return 0;
132
-}
133
-
134
-void Options::validate( int argc, char** argv ) {
135
-    for ( int i=1;i<argc;) {
136
-        std::string argument = argv[i];
137
-        if ( argument[0] != '-' ) {
138
-            floatingValues.push_back( argument );
139
-            if ( floatingValues.size() > maxFloatingValues ) {
140
-                throw new std::invalid_argument("Unexpected floating value `" + argument + "`. Forget to specify an option?" );
141
-            }
142
-            i++;
143
-            continue;
144
-        }
145
-        if ( argument[0] == '-' && argument[1] == '-' ) {
146
-            i += validateStringOption( argc, argv, i );
147
-            continue;
148
-        }
149
-        i += validateCharOption( argc, argv, i );
150
-    }
151
-}
152
-
153
-bool Options::getFloat( std::string name, char namec, float& found ) {
154
-    for( unsigned int i=0;i<arguments.size();i++ ) {
155
-        if ( arguments[i] == name || arguments[i] == std::string("")+namec ) {
156
-            std::string::size_type sz;
157
-            float retvar;
158
-            try {
159
-                retvar = std::stof(values[i],&sz);
160
-            } catch ( ... ) {
161
-                throw new std::invalid_argument("Unable to parse `" + arguments[i] + "`'s value `" + values[i] + "` as a float.");
162
-            }
163
-            if ( sz != values[i].length() ) {
164
-                throw new std::invalid_argument("Unable to parse `" + arguments[i] + "`'s value `" + values[i] + "` as a float.");
165
-            }
166
-            found = retvar;
167
-            return true;
168
-        }
169
-    }
170
-    return false;
171
-}
172
-
173
-bool Options::getInt( std::string name, char namec, int& found ) {
174
-    for( unsigned int i=0;i<arguments.size();i++ ) {
175
-        if ( arguments[i] == name || arguments[i] == std::string("")+namec ) {
176
-            if ( arguments[i].size() > 1 && arguments[i].find("=") == std::string::npos ) {
177
-                throw new std::invalid_argument("Expected `=` after " + arguments[i]);
178
-            }
179
-            std::string::size_type sz;
180
-            float retvar;
181
-            try {
182
-                retvar = std::stoi(values[i],&sz);
183
-            } catch ( ... ) {
184
-                throw new std::invalid_argument("Unable to parse " + arguments[i] + "'s value " + values[i] + " as an integer.");
185
-            }
186
-            if ( sz != values[i].length() ) {
187
-                throw new std::invalid_argument("Unable to parse " + arguments[i] + "'s value " + values[i] + " as an integer.");
188
-            }
189
-            found = retvar;
190
-            return true;
191
-        }
192
-    }
193
-    return false;
194
-}
195
-
196
-bool Options::getString( std::string name, char namec, std::string& found ) {
197
-    for( unsigned int i=0;i<arguments.size();i++ ) {
198
-        if ( arguments[i] == name || arguments[i] == std::string("")+namec ) {
199
-            found = values[i];
200
-            return true;
201
-        }
202
-    }
203
-    return false;
204
-}
205
-
206
-bool Options::getColor( std::string name, char namec, glm::vec4& found ) {
207
-    for( unsigned int i=0;i<arguments.size();i++ ) {
208
-        if ( arguments[i] == name || arguments[i] == std::string("")+namec ) {
209
-            std::string::size_type sz;
210
-            std::string value = values[i];
211
-            try {
212
-                found[0] = std::stof(value,&sz);
213
-                value = value.substr(sz+1);
214
-                found[1] = std::stof(value,&sz);
215
-                value = value.substr(sz+1);
216
-                found[2] = std::stof(value,&sz);
217
-                if ( value.size() != sz ) {
218
-                    value = value.substr(sz+1);
219
-                    found[3] = std::stof(value,&sz);
220
-                    if ( value.size() != sz ) {
221
-                        throw "dur";
222
-                    }
223
-                } else {
224
-                    found[3] = 1;
225
-                }
226
-            } catch ( ... ) {
227
-                throw new std::invalid_argument("Unable to parse `" + arguments[i] + "`'s value `" + values[i] + "` as a color. Should be in the format r,g,b or r,g,b,a. Like 1,1,1,1.");
228
-            }
229
-            return true;
230
-        }
231
-    }
232
-    return false;
233
-}
234
-
235
-bool Options::getBool( std::string name, char namec, bool& found ) {
236
-    for( unsigned int i=0;i<arguments.size();i++ ) {
237
-        if ( arguments[i] == name || arguments[i] == std::string("")+namec ) {
238
-            if ( values[i] != "" ) {
239
-                throw new std::invalid_argument("Unexpected value `" + values[i] + "` for flag argument `" + arguments[i] + "`.");
240
-            }
241
-            found = true;
242
-            return true;
243
-        }
244
-    }
245
-    return false;
246
-}

+ 0
- 61
src/options.hpp 查看文件

@@ -1,61 +0,0 @@
1
-/* options.hpp: parses arguments from the commandline.
2
- *
3
- * Copyright (C) 2014: Dalton Nell, Slop Contributors (https://github.com/naelstrof/slop/graphs/contributors).
4
- *
5
- * This file is part of Slop.
6
- *
7
- * Slop is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * Slop is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with Slop.  If not, see <http://www.gnu.org/licenses/>.
19
- */
20
-
21
-#ifndef N_OPTIONS_H_
22
-#define N_OPTIONS_H_
23
-
24
-#include <iostream>
25
-#include <string>
26
-#include <exception>
27
-#include <stdexcept>
28
-#include <vector>
29
-#include <glm/glm.hpp>
30
-
31
-class Argument {
32
-public:
33
-    std::string name;
34
-    char cname;
35
-    bool isFlagArgument;
36
-    Argument( std::string name, char cname, bool isFlagArgument ) : name(name), cname(cname), isFlagArgument(isFlagArgument) {}
37
-};
38
-
39
-static std::vector<Argument> validArguments;
40
-static unsigned int maxFloatingValues = 0;
41
-
42
-class Options {
43
-private:
44
-    std::vector<std::string> arguments;
45
-    std::vector<std::string> values;
46
-    std::vector<std::string> floatingValues;
47
-    int parseCharOption( int argc, char** argv, int argumentIndex, int validIndex );
48
-    int parseStringOption( int argc, char** argv, int argumentIndex, int validIndex );
49
-    int validateStringOption( int argc, char** argv, int argumentIndex );
50
-    int validateCharOption( int argc, char** argv, int argumentIndex );
51
-    void validate( int argc, char** argv );
52
-public:
53
-    Options( int argc, char** argv );
54
-    bool getFloat( std::string name, char namec, float& found );
55
-    bool getInt( std::string name, char namec, int& found );
56
-    bool getString( std::string name, char namec, std::string& found );
57
-    bool getColor( std::string name, char namec, glm::vec4& found );
58
-    bool getBool( std::string name, char namec, bool& found );
59
-};
60
-
61
-#endif // N_OPTIONS_H_