3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include <msp/core/getopt.h>
9 #include <msp/fs/utils.h>
10 #include <msp/strings/lexicalcast.h>
11 #include <msp/strings/regex.h>
17 Options::Options(int argc, char **argv):
28 getopt.add_option('r', "resolution", res, GetOpt::REQUIRED_ARG);
29 getopt.add_option('f', "fullscreen", fullscreen, GetOpt::NO_ARG);
30 getopt.add_option('g', "debug", debug, GetOpt::NO_ARG);
31 getopt.add_option('d', "driver", driver, GetOpt::REQUIRED_ARG);
32 getopt.add_option('s', "simulate", simulate, GetOpt::NO_ARG);
33 getopt.add_option('n', "network", network, GetOpt::NO_ARG);
34 getopt.add_option( "state", state_fn, GetOpt::REQUIRED_ARG);
39 if(RegMatch m=Regex("([1-9][0-9]*)x([1-9][0-9]*)").match(res))
41 screen_w = lexical_cast<unsigned>(m[1].str);
42 screen_h = lexical_cast<unsigned>(m[2].str);
45 throw UsageError("Invalid resolution");
48 const vector<string> &args = getopt.get_args();
50 throw UsageError("No layout given");
55 state_fn = FS::basepart(layout_fn)+".state";