#include <cli.h>
Inheritance diagram for PCLI::Context:
Public Member Functions | |
Construction | |
Context (PCLI &cli) | |
Construct new command line interpreter context. | |
virtual | ~Context () |
Destroy command line interpreter context. | |
Overrides from PChannel | |
virtual PBoolean | Write (const void *buf, PINDEX len) |
Low level write to the channel. | |
Operations | |
bool | Start () |
Start a command line interpreter thread. | |
void | Stop () |
Stop command line interpreter context. | |
virtual void | OnStart () |
Call back frunction for when context is started. | |
virtual void | OnStop () |
Callback for when context is stopping. | |
virtual bool | WritePrompt () |
Write prompt (depending on state) to channel. | |
virtual bool | ReadAndProcessInput () |
Read a character from the attached channel an process. | |
virtual bool | ProcessInput (int ch) |
Process a character read from the channel. | |
virtual void | OnCompletedLine () |
Call back for a command line was completed and ENTER pressed. | |
Member access | |
PCLI & | GetCLI () const |
Get the CLI. | |
bool | IsProcessingCommand () const |
Indicate is currently processing a command. | |
Protected Types | |
e_Username | |
e_Password | |
e_CommandEntry | |
e_ProcessingCommand | |
enum | State { e_Username, e_Password, e_CommandEntry, e_ProcessingCommand } |
Protected Member Functions | |
PDECLARE_NOTIFIER (PThread, Context, ThreadMain) | |
Protected Attributes | |
PCLI & | m_cli |
PString | m_commandLine |
bool | m_ignoreNextEOL |
PStringList | m_commandHistory |
PThread * | m_thread |
enum PCLI::Context::State | m_state |
PString | m_enteredUsername |
enum PCLI::Context::State [protected] |
PCLI::Context::Context | ( | PCLI & | cli | ) |
Construct new command line interpreter context.
virtual PCLI::Context::~Context | ( | ) | [virtual] |
Destroy command line interpreter context.
This will close and wait for threads to exit.
PCLI& PCLI::Context::GetCLI | ( | ) | const [inline] |
Get the CLI.
bool PCLI::Context::IsProcessingCommand | ( | ) | const [inline] |
Indicate is currently processing a command.
virtual void PCLI::Context::OnCompletedLine | ( | ) | [virtual] |
Call back for a command line was completed and ENTER pressed.
The default behaviour processes the line into a PArgList and deals with the command history and help.
Control is then passed on to PCLI::OnReceivedLine().
virtual void PCLI::Context::OnStart | ( | ) | [virtual] |
Call back frunction for when context is started.
This is usually called from within a background thread.
The default behaviour displays the prompt.
virtual void PCLI::Context::OnStop | ( | ) | [virtual] |
Callback for when context is stopping.
This is usually called from within a background thread.
The default behaviour does nothing.
virtual bool PCLI::Context::ProcessInput | ( | int | ch | ) | [virtual] |
Process a character read from the channel.
Returns false if have error and processing is to cease.
virtual bool PCLI::Context::ReadAndProcessInput | ( | ) | [virtual] |
Read a character from the attached channel an process.
If the character was successfully read then ProcessInput() is called.
bool PCLI::Context::Start | ( | ) |
Start a command line interpreter thread.
void PCLI::Context::Stop | ( | ) |
Stop command line interpreter context.
This will close the channel and wait for threads to exit.
virtual PBoolean PCLI::Context::Write | ( | const void * | buf, | |
PINDEX | len | |||
) | [virtual] |
Low level write to the channel.
This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.
This translate new line character ('
') to be the text string in PCLI::m_newLine.
The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.
buf | Pointer to a block of memory to write. |
len | Number of bytes to write. |
Reimplemented from PIndirectChannel.
virtual bool PCLI::Context::WritePrompt | ( | ) | [virtual] |
Write prompt (depending on state) to channel.
PCLI& PCLI::Context::m_cli [protected] |
PStringList PCLI::Context::m_commandHistory [protected] |
PString PCLI::Context::m_commandLine [protected] |
PString PCLI::Context::m_enteredUsername [protected] |
bool PCLI::Context::m_ignoreNextEOL [protected] |
enum PCLI::Context::State PCLI::Context::m_state [protected] |
PThread* PCLI::Context::m_thread [protected] |