Source: IRCMessage.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
 *
 * File:    IRCMessage.h
 * Created: Sat Dec 4 1999
 * (C) 1999 by David M. <captjay@superlink.net>
 *
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef IRCMESSAGE_H
#define IRCMESSAGE_H

#include "Message.h"
#include <qstring.h>
#include <vector>
/**
* @author David M.
* @short Parse and handle IRC-format messages.
*
* The IRCMessage class parses a raw IRC server message into an array
* of tokens, taking into account the special case ':' character.
*
*/
class IRCMessage : public Message  {
public:
	IRCMessage();
	/**
	* Construct a new IRCMessage from the string contained in rawMessage.
	*
	* @param rawMessage The string to parse.
	*/
	IRCMessage(const char* rawMessage);

  /**
  * Parse rawMessage string into its different components.
  *
  * @param rawMessage The string to parse.
  */	
	virtual void setMessage(const char* rawMessage);
	
	/**
	* Get the source of the message, as contained in the original string.
	* If the message originated from a client, getSourceNick() returns
	* only the nickname of that client. If the message was sent by a
	* server, getSourceNick() returns the full name of that server.
	*
	* @return The nick of the client who sent the message, or the
	*         name of the server if the message was sent by a server.
	*/
	const QString& getSourceNick() const;
	
	/**
	* Get the username of the client who sent the message.
	*
	* @return The username of the client who sent the message,
	*         or an empty string in case of a server message.
	*/
	const QString& getSourceUserName() const;
	
	/**
	* Get the host of the client who sent the message.
	*
	* @return The host of the client who sent the message,
	*         or an empty string in case of a server message.
	*/
	const QString& getSourceHost() const;
	
	/**
	* Get the numeric number of a numeric reply message. Constants
	* for the different replies are defined in numeric.h.
	*
	* PRECONDITIONS: @ref isNumericReply()
	*
	* @return The identifying number of the numeric reply.
	*/
	unsigned int getNumeric() const;
	
	/**
	* Determine wether the message is a numeric reply.
	* Numeric replies are in the format server 999 param1 param2.
	*
	* @return true if the message is a numeric reply, false otherwise.
	*/
	bool isNumericReply() const;
	
	/**
	* Determine wether the message was sent by a server.
	*
	* @return true if the source of the message is a server, false otherwise.
	*/
	bool sourceIsServer() const;

private:
  void updateSourceInfo();
  QString _nick;
  QString _userName;
  QString _host;
};

#endif

Generated by: nightsky@centauri on Sat Jan 15 23:06:10 2000, using kdoc 2.0a30.