fix redraw at top-left of map
[Tsunagari.git] / src / cmd.h
blobdf513bc549546cb0f1ae4454eb2b6877c39ba837
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** cmd.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef CMD_H
8 #define CMD_H
10 #include <string>
11 #include <vector>
13 //! This class handles Tsunagari's command line input.
14 class CommandLineOptions
16 public:
17 //! Initialize the parser with argc and argv.
18 CommandLineOptions(int argc, char** argv);
19 ~CommandLineOptions();
21 //! Add an option to the parser.
22 /*!
23 @param shortopt Full short option, ex. "-c", empty string if no
24 short option.
25 @param longopt Full long option, ex. "--config", required.
26 @param argument A short description of the argument expected to
27 the option, an empty string if no argument.
28 @param description A description of the argument, required.
30 void insert(std::string shortopt, std::string longopt,
31 std::string argument, std::string description);
33 //! Process the command line.
34 /*!
35 Run after all of your inserts.
36 @return true if succeeded, false if failed.
38 bool parse();
40 //! Check if option was used.
41 /*!
42 @return true if option was used, false otherwise.
44 bool check(std::string longopt);
46 //! Get the string value of an option's argument.
47 /*!
48 @return empty string if failed.
50 std::string get(std::string longopt);
52 //! Print a pretty usage/help message.
53 /*!
54 automatically formatted from the list of inserted options.
56 void usage();
58 private:
59 void usageSize(size_t* optmaxlen, size_t* argmaxlen);
60 void usagePrintShort();
61 void usagePrintLong(size_t optmaxlen, size_t argmaxlen);
63 int argc;
64 char** argv;
66 struct Option {
67 std::string shortopt;
68 std::string longopt;
69 std::string argument;
70 std::string description;
71 bool present;
72 std::string value;
75 std::vector<Option*> OptionsList;
78 #endif