]> git.localhorst.tv Git - l2e.git/blob - src/app/Arguments.cpp
added argument interpreter
[l2e.git] / src / app / Arguments.cpp
1 /*
2  * Arguments.cpp
3  *
4  *  Created on: Sep 15, 2012
5  *      Author: holy
6  */
7
8 #include "Arguments.h"
9
10 #include <stdexcept>
11 #include <string>
12
13 namespace app {
14
15 Arguments::Arguments()
16 : outfile(0) {
17
18 }
19
20
21 void Arguments::Read(int argc, char **argv) {
22         for (int i(1); i < argc; ++i) {
23                 char *arg(argv[i]);
24                 if (arg[0] == '-') {
25                         switch (arg[1]) {
26                                 case 'o':
27                                         if (i + 1 >= argc) {
28                                                 throw std::runtime_error("missing argument to -o");
29                                         }
30                                         ++i;
31                                         outfile = argv[i];
32                                         break;
33                                 default:
34                                         throw std::runtime_error(std::string("unknown option ") + arg[1]);
35                                         break;
36                         }
37                 } else {
38                         infiles.push_back(arg);
39                 }
40         }
41 }
42
43 }