ZNC  trunk
Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
CModCommand Class Reference

A helper class for handling commands in modules. More...

#include <Modules.h>

+ Inheritance diagram for CModCommand:
+ Collaboration diagram for CModCommand:

Public Types

typedef void(CModule::* ModCmdFunc) (const CString &sLine)
 Type for the callback function that handles the actual command. More...
 
typedef std::function< void(const CString &sLine)> CmdFunc
 

Public Member Functions

 CModCommand ()
 Default constructor, needed so that this can be saved in a std::map. More...
 
 CModCommand (const CString &sCmd, CModule *pMod, ModCmdFunc func, const CString &sArgs, const CString &sDesc)
 Construct a new CModCommand. More...
 
 CModCommand (const CString &sCmd, CmdFunc func, const COptionalTranslation &Args, const COptionalTranslation &Desc)
 
 CModCommand (const CModCommand &other)=default
 Copy constructor, needed so that this can be saved in a std::map. More...
 
CModCommandoperator= (const CModCommand &other)=default
 Assignment operator, needed so that this can be saved in a std::map. More...
 
void AddHelp (CTable &Table) const
 Add this command to the CTable instance. More...
 
const CStringGetCommand () const
 
CmdFunc GetFunction () const
 
CString GetArgs () const
 
CString GetDescription () const
 
void Call (const CString &sLine) const
 

Static Public Member Functions

static void InitHelp (CTable &Table)
 Initialize a CTable so that it can be used with AddHelp(). More...
 

Static Private Member Functions

static CString t_s (const CString &sEnglish, const CString &sContext="")
 
static CInlineFormatMessage t_f (const CString &sEnglish, const CString &sContext="")
 
static CInlineFormatMessage t_p (const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="")
 
static CDelayedTranslation t_d (const CString &sEnglish, const CString &sContext="")
 

Detailed Description

A helper class for handling commands in modules.

Member Typedef Documentation

◆ CmdFunc

typedef std::function<void(const CString& sLine)> CModCommand::CmdFunc

◆ ModCmdFunc

typedef void(CModule::* CModCommand::ModCmdFunc) (const CString &sLine)

Type for the callback function that handles the actual command.

Constructor & Destructor Documentation

◆ CModCommand() [1/4]

CModCommand::CModCommand ( )

Default constructor, needed so that this can be saved in a std::map.

◆ CModCommand() [2/4]

CModCommand::CModCommand ( const CString sCmd,
CModule pMod,
ModCmdFunc  func,
const CString sArgs,
const CString sDesc 
)

Construct a new CModCommand.

Parameters
sCmdThe name of the command.
funcThe command's callback function.
sArgsHelp text describing the arguments to this command.
sDescHelp text describing what this command does.

◆ CModCommand() [3/4]

CModCommand::CModCommand ( const CString sCmd,
CmdFunc  func,
const COptionalTranslation Args,
const COptionalTranslation Desc 
)

◆ CModCommand() [4/4]

CModCommand::CModCommand ( const CModCommand other)
default

Copy constructor, needed so that this can be saved in a std::map.

Parameters
otherObject to copy from.

Member Function Documentation

◆ AddHelp()

void CModCommand::AddHelp ( CTable Table) const

Add this command to the CTable instance.

Parameters
TableInstance of CTable to which this should be added.
Warning
The Table should be initialized via InitHelp().

◆ Call()

void CModCommand::Call ( const CString sLine) const
inline

◆ GetArgs()

CString CModCommand::GetArgs ( ) const
inline

◆ GetCommand()

const CString& CModCommand::GetCommand ( ) const
inline

◆ GetDescription()

CString CModCommand::GetDescription ( ) const
inline

◆ GetFunction()

CmdFunc CModCommand::GetFunction ( ) const
inline

◆ InitHelp()

static void CModCommand::InitHelp ( CTable Table)
static

Initialize a CTable so that it can be used with AddHelp().

Parameters
TableThe instance of CTable to initialize.

◆ operator=()

CModCommand& CModCommand::operator= ( const CModCommand other)
default

Assignment operator, needed so that this can be saved in a std::map.

Parameters
otherObject to copy from.

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