ZNC  trunk
Public Types | Public Member Functions | List of all members
CMessage Class Reference

Here is a small explanation of how messages on IRC work, and how you can use this class to get useful information from the parsed message. More...

#include <Message.h>

+ Inheritance diagram for CMessage:

Public Types

enum  Type {
  Type::Unknown, Type::Account, Type::Action, Type::Away,
  Type::Capability, Type::CTCP, Type::Error, Type::Invite,
  Type::Join, Type::Kick, Type::Mode, Type::Nick,
  Type::Notice, Type::Numeric, Type::Part, Type::Ping,
  Type::Pong, Type::Quit, Type::Text, Type::Topic,
  Type::Wallops
}
 
enum  FormatFlags { IncludeAll = 0x0, ExcludePrefix = 0x1, ExcludeTags = 0x2 }
 

Public Member Functions

 CMessage (const CString &sMessage="")
 
 CMessage (const CNick &Nick, const CString &sCommand, const VCString &vsParams=VCString(), const MCString &mssTags=MCString::EmptyMap)
 
Type GetType () const
 
bool Equals (const CMessage &Other) const
 
void Clone (const CMessage &Other)
 
CIRCNetworkGetNetwork () const
 
void SetNetwork (CIRCNetwork *pNetwork)
 
CClientGetClient () const
 
void SetClient (CClient *pClient)
 
CChanGetChan () const
 
void SetChan (CChan *pChan)
 
CNickGetNick ()
 
const CNickGetNick () const
 
void SetNick (const CNick &Nick)
 
const CStringGetCommand () const
 
void SetCommand (const CString &sCommand)
 
const VCStringGetParams () const
 
VCString GetParamsSplit (unsigned int uIdx, unsigned int uLen=-1) const
 Get a subset of the message parameters. More...
 
void SetParams (const VCString &vsParams)
 
CString GetParams (unsigned int uIdx, unsigned int uLen=-1) const ZNC_MSG_DEPRECATED("Use GetParamsColon() instead")
 
CString GetParamsColon (unsigned int uIdx, unsigned int uLen=-1) const
 
CString GetParam (unsigned int uIdx) const
 
void SetParam (unsigned int uIdx, const CString &sParam)
 
const timeval & GetTime () const
 
void SetTime (const timeval &ts)
 
const MCStringGetTags () const
 
void SetTags (const MCString &mssTags)
 
CString GetTag (const CString &sKey) const
 
void SetTag (const CString &sKey, const CString &sValue)
 
CString ToString (unsigned int uFlags=IncludeAll) const
 
void Parse (const CString &sMessage)
 
template<typename M >
M & As () ZNC_LVREFQUAL
 
template<typename M >
const M & As () const ZNC_LVREFQUAL
 
template<typename M , typename = typename std::enable_if< std::is_base_of<CMessage, M>{}>::type>
 operator M& () ZNC_LVREFQUAL
 
template<typename M , typename = typename std::enable_if< std::is_base_of<CMessage, M>{}>::type>
 operator const M & () const ZNC_LVREFQUAL
 

Detailed Description

Here is a small explanation of how messages on IRC work, and how you can use this class to get useful information from the parsed message.

The output varies greatly and this advice may not apply to every message type, but this will hopefully help you understand how it works more accurately.

@t=some-tag :server.network.net 366 something #channel :End of /NAMES list. tags nick cmd 0 1 2

For certain events, like a PRIVMSG, convienience commands like GetChan() and GetNick() are available, this is not true for all CMessage extensions.

Member Enumeration Documentation

◆ FormatFlags

Enumerator
IncludeAll 
ExcludePrefix 
ExcludeTags 

◆ Type

enum CMessage::Type
strong
Enumerator
Unknown 
Account 
Action 
Away 
Capability 
CTCP 
Error 
Invite 
Join 
Kick 
Mode 
Nick 
Notice 
Numeric 
Part 
Ping 
Pong 
Quit 
Text 
Topic 
Wallops 

Constructor & Destructor Documentation

◆ CMessage() [1/2]

CMessage::CMessage ( const CString sMessage = "")
explicit

◆ CMessage() [2/2]

CMessage::CMessage ( const CNick Nick,
const CString sCommand,
const VCString vsParams = VCString(),
const MCString mssTags = MCString::EmptyMap 
)

Member Function Documentation

◆ As() [1/2]

template<typename M >
const M& CMessage::As ( ) const
inline

◆ As() [2/2]

template<typename M >
M& CMessage::As ( )
inline

◆ Clone()

void CMessage::Clone ( const CMessage Other)

◆ Equals()

bool CMessage::Equals ( const CMessage Other) const

Referenced by CBufLine::Equals().

◆ GetChan()

CChan* CMessage::GetChan ( ) const
inline

◆ GetClient()

CClient* CMessage::GetClient ( ) const
inline

◆ GetCommand()

const CString& CMessage::GetCommand ( ) const
inline

◆ GetNetwork()

CIRCNetwork* CMessage::GetNetwork ( ) const
inline

◆ GetNick() [1/2]

CNick& CMessage::GetNick ( )
inline

◆ GetNick() [2/2]

const CNick& CMessage::GetNick ( ) const
inline

◆ GetParam()

CString CMessage::GetParam ( unsigned int  uIdx) const

◆ GetParams() [1/2]

const VCString& CMessage::GetParams ( ) const
inline

◆ GetParams() [2/2]

CString CMessage::GetParams ( unsigned int  uIdx,
unsigned int  uLen = -1 
) const
inline

◆ GetParamsColon()

CString CMessage::GetParamsColon ( unsigned int  uIdx,
unsigned int  uLen = -1 
) const

◆ GetParamsSplit()

VCString CMessage::GetParamsSplit ( unsigned int  uIdx,
unsigned int  uLen = -1 
) const

Get a subset of the message parameters.

This allows accessing a vector of a specific range of parameters, allowing easy inline use, such as pChan->SetModes(Message.GetParam(2), Message.GetParamsSplit(3));

Parameters
uIdxThe index of the first parameter to retrieve
uLenHow many parameters to retrieve
Returns
A VCString containing the retrieved parameters

Referenced by CModeMessage::GetModeParams().

◆ GetTag()

CString CMessage::GetTag ( const CString sKey) const

◆ GetTags()

const MCString& CMessage::GetTags ( ) const
inline

Referenced by CBufLine::GetTags().

◆ GetTime()

const timeval& CMessage::GetTime ( ) const
inline

Referenced by CBufLine::GetTime().

◆ GetType()

Type CMessage::GetType ( ) const
inline

◆ operator const M &()

template<typename M , typename = typename std::enable_if< std::is_base_of<CMessage, M>{}>::type>
CMessage::operator const M & ( ) const
inline

◆ operator M&()

template<typename M , typename = typename std::enable_if< std::is_base_of<CMessage, M>{}>::type>
CMessage::operator M& ( )
inline

◆ Parse()

void CMessage::Parse ( const CString sMessage)

Referenced by CBufLine::SetFormat().

◆ SetChan()

void CMessage::SetChan ( CChan pChan)
inline

◆ SetClient()

void CMessage::SetClient ( CClient pClient)
inline

◆ SetCommand()

void CMessage::SetCommand ( const CString sCommand)

◆ SetNetwork()

void CMessage::SetNetwork ( CIRCNetwork pNetwork)
inline

◆ SetNick()

void CMessage::SetNick ( const CNick Nick)
inline

◆ SetParam()

void CMessage::SetParam ( unsigned int  uIdx,
const CString sParam 
)

◆ SetParams()

void CMessage::SetParams ( const VCString vsParams)

◆ SetTag()

void CMessage::SetTag ( const CString sKey,
const CString sValue 
)

◆ SetTags()

void CMessage::SetTags ( const MCString mssTags)
inline

Referenced by CBufLine::SetTags().

◆ SetTime()

void CMessage::SetTime ( const timeval &  ts)
inline

Referenced by CBufLine::SetTime().

◆ ToString()

CString CMessage::ToString ( unsigned int  uFlags = IncludeAll) const

Referenced by CBufLine::GetFormat().


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