PTLib  Version 2.10.4
PCLI::Context Class Reference

Context for command line interpreter. More...

#include <cli.h>

Inheritance diagram for PCLI::Context:
PIndirectChannel PChannel PObject

List of all members.

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 bool ProcessInput (const PString &line)
virtual void OnCompletedLine ()
 Call back for a command line was completed and ENTER pressed.
Member access
PCLIGetCLI () const
 Get the CLI.
bool IsProcessingCommand () const
 Indicate is currently processing a command.

Protected Types

enum  State { e_Username, e_Password, e_CommandEntry, e_ProcessingCommand }

Protected Member Functions

 PDECLARE_NOTIFIER (PThread, Context, ThreadMain)

Protected Attributes

PCLIm_cli
PString m_commandLine
bool m_ignoreNextEOL
PStringList m_commandHistory
PThreadm_thread
enum PCLI::Context::State m_state
PString m_enteredUsername

Detailed Description

Context for command line interpreter.


Member Enumeration Documentation

enum PCLI::Context::State [protected]
Enumerator:
e_Username 
e_Password 
e_CommandEntry 
e_ProcessingCommand 

Constructor & Destructor Documentation

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.


Member Function Documentation

PCLI& PCLI::Context::GetCLI ( ) const [inline]

Get the CLI.

References m_cli.

bool PCLI::Context::IsProcessingCommand ( ) const [inline]

Indicate is currently processing a command.

References e_ProcessingCommand, and m_state.

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.

PCLI::Context::PDECLARE_NOTIFIER ( PThread  ,
Context  ,
ThreadMain   
) [protected]
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::ProcessInput ( const PString line) [virtual]
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.

Start a command line interpreter thread.

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.

Returns:
true if at least len bytes were written to the channel.
Parameters:
bufPointer to a block of memory to write.
lenNumber of bytes to write.

Reimplemented from PIndirectChannel.

virtual bool PCLI::Context::WritePrompt ( ) [virtual]

Write prompt (depending on state) to channel.


Member Data Documentation

PCLI& PCLI::Context::m_cli [protected]

Referenced by GetCLI().


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