Zen
A cross-platform functional programming language

CmdLine Class Reference

Command line parser class. More...

#include <CmdLine.hpp>

List of all members.

Classes

class  Command
 Command class. More...

Public Member Functions

 CmdLine (const z::string &desc)
 Default constructor.
CommandaddCommand (const z::string &cmd, int value, const z::string &desc)
 Add command.
const int & getCommand () const
 Get current command.
const z::stringgetError () 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< OptionBaseOptPtr_t
 Autopointer type for OptionBase.
typedef z::list< OptPtr_tOptList_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 CommandhasCommandMap (z::stringlist::iterator &it)
 Check if command pointed to by iterator exists.
const CommandgetCommandMap (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.

Detailed Description

Command line parser class.


Member Function Documentation

CmdLine::Command & addCommand ( const z::string cmd,
int  value,
const z::string desc 
) [inline]

Add command.

Parameters:
cmdThe command name
valueCommand value
descDescription of command
Returns:
Newly added command
const int & getCommand ( ) const [inline]

Get current command.

Returns:
Current command
const CmdLine::Command & getCommandMap ( z::stringlist::iterator &  it) [inline, private]

Get command pointed to by iterator.

Parameters:
itIterator pointing to command name argument.
Returns:
Reference to command.
const z::string & getError ( ) const [inline]

Get error message.

Returns:
Error message
const CmdLine::Command * hasCommandMap ( z::stringlist::iterator &  it) [inline, private]

Check if command pointed to by iterator exists.

Parameters:
itItertaor pointing to command name argument.
Returns:
Pointer to command if any, else 0
int parse ( int  argc,
char *  argv[] 
) [inline]

Parse command line arguments.

Parameters:
argcArgument count
argvArgument list
Returns:
0 on success, else error value
int parse ( const z::stringlist args) [inline]

Parse command line arguments.

Parameters:
argsArgument list
Returns:
0 on success, else error value
void show ( z::stream str) const [inline]

Write commands to output stream.

Parameters:
strOutput stream

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines