#include <cli.h>
Inheritance diagram for PCLI:

Public Member Functions | |
Operations | |
| virtual bool | Start (bool runInBackground=true) |
| virtual void | Stop () |
| bool | StartContext (PChannel *channel, bool autoDelete=true, bool runInBackground=true) |
| bool | StartContext (PChannel *readChannel, PChannel *writeChannel, bool autoDeleteRead=true, bool autoDeleteWrite=true, bool runInBackground=true) |
| virtual Context * | CreateContext () |
| virtual Context * | AddContext (Context *context=NULL) |
| virtual void | RemoveContext (Context *context) |
| virtual void | GarbageCollection () |
| virtual void | OnReceivedLine (Arguments &line) |
| void | Broadcast (const PString &message) const |
| bool | SetCommand (const char *command, const PNotifier ¬ifier, const char *help=NULL, const char *usage=NULL) |
| void | ShowHelp (Context &context) |
Member access | |
| const PString & | GetPrompt () const |
| void | SetPrompt (const PString &prompt) |
| const PString & | GetNewLine () const |
| void | SetNewLine (const PString &newLine) |
| const PCaselessString & | GetHelpCommand () const |
| void | SetHelpCommand (const PCaselessString &helpCommand) |
| const PString & | GetHelpOnHelp () const |
| void | SetHelpOnHelp (const PCaselessString &helpOnHelp) |
| const PCaselessString & | GetRepeatCommand () const |
| void | SetRepeatCommand (const PCaselessString &repeatCommand) |
| const PCaselessString & | GetHistoryCommand () const |
| void | SetHistoryCommand (const PCaselessString &historyCommand) |
| const PString & | GetNoHistoryError () const |
| void | SetNoHistoryError (const PString &noHistoryError) |
| const PString & | GetCommandUsagePrefix () const |
| void | SetCommandUsagePrefix (const PString &commandUsagePrefix) |
| const PString & | GetCommandErrorPrefix () const |
| void | SetCommandErrorPrefix (const PString &commandErrorPrefix) |
| const PString & | GetUnknownCommandError () const |
| void | SetUnknownCommandError (const PString &unknownCommandError) |
Protected Types | |
| typedef std::map< PString, InternalCommand > | CommandMap_t |
| typedef std::list< Context * > | ContextList_t |
Protected Attributes | |
| PString | m_prompt |
| PString | m_newLine |
| PCaselessString | m_helpCommand |
| PString | m_helpOnHelp |
| PCaselessString | m_repeatCommand |
| PCaselessString | m_historyCommand |
| PString | m_noHistoryError |
| PString | m_commandUsagePrefix |
| PString | m_commandErrorPrefix |
| PString | m_unknownCommandError |
| CommandMap_t | m_commands |
| ContextList_t | m_contextList |
| PMutex | m_contextMutex |
Classes | |
| class | Arguments |
| class | Context |
| struct | InternalCommand |
The system supports multiple simultaneous interpreter which may access the same command set. For example several telnet sessions.
Note that the various command interpreters could be operating in different threads, so care should be taken for sybchronisation issues on the object being acted upon via the PNotifiers.
typedef std::map<PString, InternalCommand> PCLI::CommandMap_t [protected] |
typedef std::list<Context *> PCLI::ContextList_t [protected] |
| PCLI::PCLI | ( | const char * | prompt = NULL |
) |
Contracut a new command line interpreter.
| virtual PCLI::~PCLI | ( | ) | [virtual] |
Destroy the command line interpreter. This will call Stop() to assure everything is cleaned up before exiting.
| PCLI::PCLI | ( | const char * | prompt = NULL |
) |
Contracut a new command line interpreter.
| virtual PCLI::~PCLI | ( | ) | [virtual] |
Destroy the command line interpreter. This will call Stop() to assure everything is cleaned up before exiting.
| virtual bool PCLI::Start | ( | bool | runInBackground = true |
) | [virtual] |
Start a command line interpreter. If runInBackground is true the all the command line interpreter contexts that have been added will have their background threads started.
If runInBackground is false, then there must only be one context added and that context is continuously read until it's channel is closed or returns end of file.
| runInBackground | Spawn a thread to read and interpret commands |
Reimplemented in PCLIStandard, and PCLISocket.
| virtual void PCLI::Stop | ( | ) | [virtual] |
Stop and clean up command line interpreters. All the running contexts threads will be stopped, closing the channels and memory cleaned up.
Reimplemented in PCLISocket.
| bool PCLI::StartContext | ( | PChannel * | channel, | |
| bool | autoDelete = true, |
|||
| bool | runInBackground = true | |||
| ) |
Open a command line interpreter context.
| channel | Channel to read/write |
| autoDelete | Automatically delete channel on exit |
| runInBackground | Spawn a thread to read and interpret commands |
| bool PCLI::StartContext | ( | PChannel * | readChannel, | |
| PChannel * | writeChannel, | |||
| bool | autoDeleteRead = true, |
|||
| bool | autoDeleteWrite = true, |
|||
| bool | runInBackground = true | |||
| ) |
| readChannel | Channel to be used for both read operations. |
| writeChannel | Channel to be used for both write operations. |
| autoDeleteRead | Automatically delete the read channel |
| autoDeleteWrite | Automatically delete the write channel |
| runInBackground | Spawn a thread to read and interpret commands |
| virtual Context* PCLI::CreateContext | ( | ) | [virtual] |
Create a new context. Users may use this to create derived classes for their own use.
Add a command line interpreter context to the system. If context is NULL then CreateContext() is called to create one.
| context | New context to add to the system. |
| virtual void PCLI::RemoveContext | ( | Context * | context | ) | [virtual] |
Remove the command line interpreter context. The context thread is stopped, the channel closed and memory deleted.
| context | Context to remove |
| virtual void PCLI::GarbageCollection | ( | ) | [virtual] |
Remove any closed command line interpreter contexts.
| virtual void PCLI::OnReceivedLine | ( | Arguments & | line | ) | [virtual] |
| void PCLI::Broadcast | ( | const PString & | message | ) | const |
Set a string to all command line interpreter contexts.
| message | Message to broadcast. |
| bool PCLI::SetCommand | ( | const char * | command, | |
| const PNotifier & | notifier, | |||
| const char * | help = NULL, |
|||
| const char * | usage = NULL | |||
| ) |
Register a new command to be interpreted. Note the command may be a series of synonyms of the same command separated by the '
' character.
The command may also contain spaces which separates sub-commands, e.g. "list users".
Returns false if one of the command synonyms was a dupicate of an existing command.
| command | Command(s) to register |
| notifier | Callback to execute when command interpreted |
| help | Help text on command (what it does) |
| usage | Usage text on command (syntax/options) |
| void PCLI::ShowHelp | ( | Context & | context | ) |
Show help for registered commands to the context.
| context | Context to output help to. |
| const PString& PCLI::GetPrompt | ( | ) | const [inline] |
Get prompt used for command line interpreter. Default is "CLI> ".
| void PCLI::SetPrompt | ( | const PString & | prompt | ) | [inline] |
Set prompt used for command line interpreter. Default is "CLI> ".
| const PString& PCLI::GetNewLine | ( | ) | const [inline] |
Get new line string output at the end of every line. Default is "\n".
| void PCLI::SetNewLine | ( | const PString & | newLine | ) | [inline] |
Set new line string output at the end of every line. Default is "\n".
| const PCaselessString& PCLI::GetHelpCommand | ( | ) | const [inline] |
Get command to be used to display help. Default is "?".
| void PCLI::SetHelpCommand | ( | const PCaselessString & | helpCommand | ) | [inline] |
Set command to be used to display help. Default is "?".
| const PString& PCLI::GetHelpOnHelp | ( | ) | const [inline] |
Get help on help.
| void PCLI::SetHelpOnHelp | ( | const PCaselessString & | helpOnHelp | ) | [inline] |
Set help on help.
| const PCaselessString& PCLI::GetRepeatCommand | ( | ) | const [inline] |
Get the command to be used to repeat the last executed command. Default is "!!".
| void PCLI::SetRepeatCommand | ( | const PCaselessString & | repeatCommand | ) | [inline] |
Set the command to be used to repeat the last executed command. Default is "!!".
| const PCaselessString& PCLI::GetHistoryCommand | ( | ) | const [inline] |
Get command that will list/execute command history. Default is "!".
| void PCLI::SetHistoryCommand | ( | const PCaselessString & | historyCommand | ) | [inline] |
Set command that will list/execute command history. Default is "!".
| const PString& PCLI::GetNoHistoryError | ( | ) | const [inline] |
Get error message for if there is no history.
| void PCLI::SetNoHistoryError | ( | const PString & | noHistoryError | ) | [inline] |
Set error message for if there is no history.
| const PString& PCLI::GetCommandUsagePrefix | ( | ) | const [inline] |
Get usage prefix for if Arguments::WriteError() called.
| void PCLI::SetCommandUsagePrefix | ( | const PString & | commandUsagePrefix | ) | [inline] |
Set usage prefix for if Arguments::WriteError() called.
| const PString& PCLI::GetCommandErrorPrefix | ( | ) | const [inline] |
Get error prefix for if Arguments::WriteError() called.
| void PCLI::SetCommandErrorPrefix | ( | const PString & | commandErrorPrefix | ) | [inline] |
Set error prefix for if Arguments::WriteError() called.
| const PString& PCLI::GetUnknownCommandError | ( | ) | const [inline] |
Get error message for if unknown command is entered.
| void PCLI::SetUnknownCommandError | ( | const PString & | unknownCommandError | ) | [inline] |
Set error message for if unknown command is entered.
PString PCLI::m_prompt [protected] |
PString PCLI::m_newLine [protected] |
PCaselessString PCLI::m_helpCommand [protected] |
PString PCLI::m_helpOnHelp [protected] |
PCaselessString PCLI::m_repeatCommand [protected] |
PCaselessString PCLI::m_historyCommand [protected] |
PString PCLI::m_noHistoryError [protected] |
PString PCLI::m_commandUsagePrefix [protected] |
PString PCLI::m_commandErrorPrefix [protected] |
PString PCLI::m_unknownCommandError [protected] |
CommandMap_t PCLI::m_commands [protected] |
ContextList_t PCLI::m_contextList [protected] |
PMutex PCLI::m_contextMutex [protected] |
1.5.1