1 /******************************
2 ** Tsunagari Tile Engine **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
13 //! This class handles Tsunagari's command line input.
14 class CommandLineOptions
17 //! Initialize the parser with argc and argv.
18 CommandLineOptions(int argc
, char** argv
);
19 ~CommandLineOptions();
21 //! Add an option to the parser.
23 @param shortopt Full short option, ex. "-c", empty string if no
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.
35 Run after all of your inserts.
36 @return true if succeeded, false if failed.
40 //! Check if option was used.
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.
48 @return empty string if failed.
50 std::string
get(std::string longopt
);
52 //! Print a pretty usage/help message.
54 automatically formatted from the list of inserted options.
59 void usageSize(size_t* optmaxlen
, size_t* argmaxlen
);
60 void usagePrintShort();
61 void usagePrintLong(size_t optmaxlen
, size_t argmaxlen
);
70 std::string description
;
75 std::vector
<Option
*> OptionsList
;