CommandProcessing::Handler Class Reference

Command handler class. More...

#include <Handler.h>

Public Member Functions

 Handler ()
 Instantiate a CommandHandler. More...
 
 Handler (ReadWriteStream *stream, bool owned=true)
 
 Handler (const Handler &rhs)=delete
 
 ~Handler ()
 
void setOutputStream (ReadWriteStream *stream, bool owned=true)
 sets the output stream More...
 
ReadWriteStreamgetOutputStream ()
 
size_t process (char charToWrite)
 
size_t process (const char *buffer, size_t size)
 Write chars to stream. More...
 
String processNow (const char *buffer, size_t size)
 Process command input and return response text. More...
 
bool registerCommand (const Command &command)
 Add a new command to the command handler. More...
 
bool unregisterCommand (const Command &command)
 Remove a command from the command handler. More...
 
void registerSystemCommands ()
 Register default system commands. More...
 
Command getCommand (const String &name) const
 Find command object. More...
 
bool isVerbose () const
 Get the verbose mode. More...
 
void setVerbose (bool mode)
 Set the verbose mode. More...
 
String getCommandPrompt () const
 Get the command line prompt. More...
 
void setCommandPrompt (const String &prompt)
 Set the command line prompt. More...
 
char getCommandEOL () const
 Get the end of line character. More...
 
void setCommandEOL (char eol)
 Set the end of line character. More...
 
String getCommandWelcomeMessage () const
 Get the welcome message. More...
 
void setCommandWelcomeMessage (const String &message)
 Set the welcome message. More...
 

Detailed Description

Command handler class.

Constructor & Destructor Documentation

◆ Handler() [1/3]

CommandProcessing::Handler::Handler ( )
inline

Instantiate a CommandHandler.

◆ Handler() [2/3]

CommandProcessing::Handler::Handler ( ReadWriteStream stream,
bool  owned = true 
)
inline

◆ Handler() [3/3]

CommandProcessing::Handler::Handler ( const Handler rhs)
delete

◆ ~Handler()

CommandProcessing::Handler::~Handler ( )
inline

Member Function Documentation

◆ getCommand()

Command CommandProcessing::Handler::getCommand ( const String name) const

Find command object.

Parameters
nameCommand to query
Return values
CommandThe command object matching the command

◆ getCommandEOL()

char CommandProcessing::Handler::getCommandEOL ( ) const
inline

Get the end of line character.

Return values
charThe EOL character
Note
Only supports one EOL, unlike Windows
Deprecated:
Not required

◆ getCommandPrompt()

String CommandProcessing::Handler::getCommandPrompt ( ) const

Get the command line prompt.

Return values
StringThe command line prompt
Note
This is what is shown on the command line before user input Default is Sming>

◆ getCommandWelcomeMessage()

String CommandProcessing::Handler::getCommandWelcomeMessage ( ) const

Get the welcome message.

Return values
StringThe welcome message that should be shown when clients connect
Note
For use by application

◆ getOutputStream()

ReadWriteStream& CommandProcessing::Handler::getOutputStream ( )
inline

◆ isVerbose()

bool CommandProcessing::Handler::isVerbose ( ) const
inline

Get the verbose mode.

Return values
boolVerbose mode

◆ process() [1/2]

size_t CommandProcessing::Handler::process ( char  charToWrite)

◆ process() [2/2]

size_t CommandProcessing::Handler::process ( const char *  buffer,
size_t  size 
)
inline

Write chars to stream.

Parameters
bufferPointer to buffer to write to the stream
sizeQuantity of chars to write
Return values
size_tQuantity of chars processed

◆ processNow()

String CommandProcessing::Handler::processNow ( const char *  buffer,
size_t  size 
)

Process command input and return response text.

Parameters
bufferCommand input
sizeNumber of characters to process
Return values
StringResponse text
Note
Do not use this method if setOutputStream has been called

◆ registerCommand()

bool CommandProcessing::Handler::registerCommand ( const Command command)

Add a new command to the command handler.

Parameters
commandCommand to register
Return values
boolTrue on success
Note
If command already exists, it will not be replaced and function will fail. Call unregisterCommand first if you want to replace a command.

◆ registerSystemCommands()

void CommandProcessing::Handler::registerSystemCommands ( )

Register default system commands.

Note
Adds the following system commands to the command handler
  • status
  • echo
  • help
  • debugon
  • debugoff
  • command

◆ setCommandEOL()

void CommandProcessing::Handler::setCommandEOL ( char  eol)
inline

Set the end of line character.

Parameters
eolThe EOL character
Note
Only supports one EOL, unlike Windows
Deprecated:
Not required

◆ setCommandPrompt()

void CommandProcessing::Handler::setCommandPrompt ( const String prompt)
inline

Set the command line prompt.

Parameters
promptThe command line prompt, nullptr to reset to default
Note
This is what is shown on the command line before user input Default is Sming>

◆ setCommandWelcomeMessage()

void CommandProcessing::Handler::setCommandWelcomeMessage ( const String message)
inline

Set the welcome message.

Parameters
messageThe welcome message that should be shown when clients connect
Note
For use by application Pass nullptr to revert to default message.

◆ setOutputStream()

void CommandProcessing::Handler::setOutputStream ( ReadWriteStream stream,
bool  owned = true 
)
inline

sets the output stream

Parameters
streampointer to the output stream
ownedspecifies if the output stream should be deleted in this class(owned=true)

◆ setVerbose()

void CommandProcessing::Handler::setVerbose ( bool  mode)
inline

Set the verbose mode.

Parameters
modeVerbose mode to set

◆ unregisterCommand()

bool CommandProcessing::Handler::unregisterCommand ( const Command command)

Remove a command from the command handler.

Parameters
commandItem to remove from command handler

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