PandoraBotIRC  1.0.0
An irc bot that acts as a Pandora chatter bot
pbirc::irc::IRCMessage Class Reference

IRCMessage class represents an IRC message that corresponds with irc protocol. More...

#include <IRCMessage.hpp>

Public Member Functions

 IRCMessage ()=default
 Default constructor. More...
 
 ~IRCMessage ()=default
 Default destructor. More...
 
 IRCMessage (std::string const &sender, std::string const &command, std::string const &params, std::string const &data)
 Constructor (1) - Paremeter initialized. More...
 
 IRCMessage (std::string const &raw)
 Constructor (2) - Raw message initialized. More...
 
 IRCMessage (IRCMessage const &)=default
 Copy constructor is defaulted. More...
 
IRCMessageoperator= (IRCMessage const &rhs)
 Assignment operator allows assignment between IRCMessages. More...
 
bool operator== (IRCMessage const &rhs)
 Comparison operator allows comparison of IRCMessages. More...
 
std::string sender () const
 Gets sender. More...
 
std::string command () const
 Gets command. More...
 
std::string params () const
 Gets params. More...
 
std::string data () const
 Gets data. More...
 
void setSender (std::string const &sender)
 Sets sender. More...
 
void setCommand (std::string const &command)
 Sets command. More...
 
void setParams (std::string const &params)
 Sets params. More...
 
void setData (std::string const &data)
 Sets data. More...
 
template<typename... Params>
void addParams (std::string const &head, Params const &...tail)
 Uses varargs to add parameters. More...
 
void addParams ()
 Edge condition for the recursive addParams . More...
 
bool empty () const
 
std::string raw () const
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, IRCMessage const &rhs)
 Global std::ostream operator<< overload for IRCMessages. More...
 

Detailed Description

IRCMessage class represents an IRC message that corresponds with irc protocol.

IRC messages come in the form of ":<sender> <command> <params> :<data>\r\n" there may be multiple params, and data can be of any length. Sender, params, and data are optional fields.

IRCMessage may be constructed by raw IRC messages received from a server. This method will throw std::invalid_argument if the string supplied does not match the format of an IRC message.

You can construct IRCMessages two ways. You can initialize it with a raw irc message Or you can initialize it with parameters.

Usage

Raw IRC message initialized

The above code should output:

Parameter Initialized

The above code should output:

 

Constructor & Destructor Documentation

pbirc::irc::IRCMessage::IRCMessage ( )
default

Default constructor.

pbirc::irc::IRCMessage::~IRCMessage ( )
default

Default destructor.

pbirc::irc::IRCMessage::IRCMessage ( std::string const &  sender,
std::string const &  command,
std::string const &  params,
std::string const &  data 
)

Constructor (1) - Paremeter initialized.

Parameters
[in]sendera string that contains the sender bit of the message
[in]commanda string that contains the command bit of the message
[in]paramsa string that contains the parameters bit of the message
[in]dataa string that contains the data bit of the message.
pbirc::irc::IRCMessage::IRCMessage ( std::string const &  raw)
explicit

Constructor (2) - Raw message initialized.

This constructor takes a raw message received from an irc server and fills out the object accordingly.

Exceptions
std::invalid_argumentif 'raw' does not match the syntax of an irc message.
Parameters
[in]rawstring that contains the raw irc protocol message
pbirc::irc::IRCMessage::IRCMessage ( IRCMessage const &  )
default

Copy constructor is defaulted.

Member Function Documentation

template<typename... Params>
void pbirc::irc::IRCMessage::addParams ( std::string const &  head,
Params const &...  tail 
)
inline

Uses varargs to add parameters.

Allows for the syntax: addParams("Param1", "Param2", "Param3", ...). in the event that parameters need to be added one by one. (setParams does not allow this)

void pbirc::irc::IRCMessage::addParams ( )
inline

Edge condition for the recursive addParams .

std::string pbirc::irc::IRCMessage::command ( ) const
inline

Gets command.

std::string pbirc::irc::IRCMessage::data ( ) const
inline

Gets data.

bool pbirc::irc::IRCMessage::empty ( ) const
Returns
true if the object is empty false otherwise.
IRCMessage & pbirc::irc::IRCMessage::operator= ( IRCMessage const &  rhs)

Assignment operator allows assignment between IRCMessages.

bool pbirc::irc::IRCMessage::operator== ( IRCMessage const &  rhs)

Comparison operator allows comparison of IRCMessages.

std::string pbirc::irc::IRCMessage::params ( ) const
inline

Gets params.

std::string pbirc::irc::IRCMessage::raw ( ) const
Returns
the raw irc protocol message equivalent to the object.
std::string pbirc::irc::IRCMessage::sender ( ) const
inline

Gets sender.

void pbirc::irc::IRCMessage::setCommand ( std::string const &  command)
inline

Sets command.

void pbirc::irc::IRCMessage::setData ( std::string const &  data)
inline

Sets data.

void pbirc::irc::IRCMessage::setParams ( std::string const &  params)
inline

Sets params.

void pbirc::irc::IRCMessage::setSender ( std::string const &  sender)
inline

Sets sender.

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  os,
IRCMessage const &  rhs 
)
related

Global std::ostream operator<< overload for IRCMessages.

Outputs the IRC message in the following format:

Sender: 
Command:
Params:
Data:

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