ui-utilcpp  1.8.5
Public Member Functions | Static Public Member Functions | Protected Attributes
UI::Util::CmdLine::Cmd Class Referenceabstract

Represents a command. More...

#include <CmdLine.hpp>

Inheritance diagram for UI::Util::CmdLine::Cmd:
Inheritance graph
Collaboration diagram for UI::Util::CmdLine::Cmd:
Collaboration graph

Public Member Functions

 Cmd (std::string const &name, std::string const &help="No help for this command")
 Standard constructor. More...
 
std::string getName () const
 Get command name.
 
void addArg (std::string const &name, std::string const &help="No help for this option")
 Add mandatory argument. Use this in constructors of custom Cmd classes. More...
 
void addOptArg (std::string const &name, std::string const &help="No help for this option")
 Add optional argument. Use this in constructors of custom Cmd classes. More...
 
int getMinArgs () const
 Get min args.
 
int getMaxArgs () const
 Get max args.
 
std::string getSyntax () const
 Get syntax line: cmd arg1 arg2 [arg3].
 
std::string getHelp (bool showArgs=false) const
 Print help (i.e., syntax + documentation text).
 
bool parse (std::string const &line)
 Parse a line. More...
 
bool isParsed () const
 Check if we are in "parsed" state.
 
std::string getArg (int i) const
 Get the argument of a parsed command. More...
 
int run ()
 Public run function. Use this to run commands.
 
void setCL (CmdLine *cl)
 Set Command Line Pointer; This must be run when adding commands from a CmdLine.
 

Static Public Member Functions

static std::string stripLine (std::string const &line)
 Helper function.
 
static std::string commandFromLine (std::string const &line)
 Helper function.
 

Protected Attributes

CmdLinecl_
 Should be there to access CmdLine.
 

Detailed Description

Represents a command.

Examples:
CmdLine.cpp.

Constructor & Destructor Documentation

UI::Util::CmdLine::Cmd::Cmd ( std::string const &  name,
std::string const &  help = "No help for this command" 
)

Standard constructor.

Parameters
nameName of the command.
helpDocumentation string for this command.
Examples:
CmdLine.cpp.

Member Function Documentation

void UI::Util::CmdLine::Cmd::addArg ( std::string const &  name,
std::string const &  help = "No help for this option" 
)

Add mandatory argument. Use this in constructors of custom Cmd classes.

Parameters
nameName of the argument.
helpHelp for this command.
Examples:
CmdLine.cpp.
void UI::Util::CmdLine::Cmd::addOptArg ( std::string const &  name,
std::string const &  help = "No help for this option" 
)

Add optional argument. Use this in constructors of custom Cmd classes.

Parameters
nameName of the argument.
helpHelp for this command.
Examples:
CmdLine.cpp.
std::string UI::Util::CmdLine::Cmd::getArg ( int  i) const

Get the argument of a parsed command.

Parameters
iNumber of argument to get.
Examples:
CmdLine.cpp.

References cl_, getMaxArgs(), and UI::Util::CmdLine::CmdLine::getVar().

Referenced by run().

bool UI::Util::CmdLine::Cmd::parse ( std::string const &  line)

Parse a line.

Parameters
lineInput line.

References getMaxArgs(), getMinArgs(), getName(), and stripLine().

Referenced by UI::Util::CmdLine::CmdLine::run().


The documentation for this class was generated from the following files: