![]() |
Zen
A cross-platform functional programming language
|
Command line parser class. More...
#include <CmdLine.hpp>
Classes | |
| class | Command |
| Command class. More... | |
Public Member Functions | |
| CmdLine (const z::string &desc) | |
| Default constructor. | |
| Command & | addCommand (const z::string &cmd, int value, const z::string &desc) |
| Add command. | |
| const int & | getCommand () const |
| Get current command. | |
| const z::string & | getError () const |
| Get error message. | |
| int | parse (int argc, char *argv[]) |
| Parse command line arguments. | |
| int | parse (const z::stringlist &args) |
| Parse command line arguments. | |
| void | show (z::stream &str) const |
| Write commands to output stream. | |
Private Types | |
| typedef z::sharedptr< OptionBase > | OptPtr_t |
| Autopointer type for OptionBase. | |
| typedef z::list< OptPtr_t > | OptList_t |
| List type for OptPtr. | |
|
typedef z::dict< z::string, OptionBase * > | Map_t |
| Map type for OptionBase. | |
| typedef z::list< OptionBase * > | List_t |
| List type for OptionBase. | |
|
typedef z::dict< z::string, Command > | CmdMap_t |
| Type of command map. | |
| typedef z::list< Command * > | CmdList_t |
| Type of commandlist. Used only for printing options in original order. | |
Private Member Functions | |
| const Command * | hasCommandMap (z::stringlist::iterator &it) |
| Check if command pointed to by iterator exists. | |
| const Command & | getCommandMap (z::stringlist::iterator &it) |
| Get command pointed to by iterator. | |
Private Attributes | |
| CmdMap_t | _cmdMap |
| Command map. | |
| CmdList_t | _cmdList |
| Command list. | |
| z::string | _appName |
| Application name. | |
| int | _command |
| Current command. | |
| z::string | _desc |
| Application description. | |
| z::string | _error |
| Current error message, if any. | |
Command line parser class.
| CmdLine::Command & addCommand | ( | const z::string & | cmd, |
| int | value, | ||
| const z::string & | desc | ||
| ) | [inline] |
Add command.
| cmd | The command name |
| value | Command value |
| desc | Description of command |
| const int & getCommand | ( | ) | const [inline] |
Get current command.
| const CmdLine::Command & getCommandMap | ( | z::stringlist::iterator & | it | ) | [inline, private] |
Get command pointed to by iterator.
| it | Iterator pointing to command name argument. |
| const z::string & getError | ( | ) | const [inline] |
Get error message.
| const CmdLine::Command * hasCommandMap | ( | z::stringlist::iterator & | it | ) | [inline, private] |
Check if command pointed to by iterator exists.
| it | Itertaor pointing to command name argument. |
| int parse | ( | int | argc, |
| char * | argv[] | ||
| ) | [inline] |
Parse command line arguments.
| argc | Argument count |
| argv | Argument list |
| int parse | ( | const z::stringlist & | args | ) | [inline] |
Parse command line arguments.
| args | Argument list |
| void show | ( | z::stream & | str | ) | const [inline] |
Write commands to output stream.
| str | Output stream |