MessageIn Class Reference

#include <messagein.hpp>

List of all members.


Detailed Description

Used for parsing an incoming message.

Definition at line 34 of file messagein.hpp.

Public Member Functions

 MessageIn (const char *data, int length)
 Constructor.
int getId ()
 Returns the message ID.
int readByte ()
 Reads a byte.
int readShort ()
 Reads a short.
int readLong ()
 Reads a long.
std::string readString (int length=-1)
 Reads a string.
int getUnreadLength ()
 Returns the length of unread data.

Private Attributes

const char * mData
 Packet data.
unsigned short mLength
 Length of data in bytes.
unsigned short mId
 The message ID.
unsigned short mPos
 Actual position in the packet.


Constructor & Destructor Documentation

MessageIn::MessageIn const char *  data,
int  length
 

Constructor.

Definition at line 29 of file messagein.cpp.


Member Function Documentation

int MessageIn::getId  )  [inline]
 

Returns the message ID.

Definition at line 42 of file messagein.hpp.

int MessageIn::getUnreadLength  )  [inline]
 

Returns the length of unread data.

Definition at line 58 of file messagein.hpp.

int MessageIn::readByte  ) 
 

Reads a byte.

Definition at line 38 of file messagein.cpp.

int MessageIn::readLong  ) 
 

Reads a long.

Definition at line 62 of file messagein.cpp.

int MessageIn::readShort  ) 
 

Reads a short.

Definition at line 49 of file messagein.cpp.

std::string MessageIn::readString int  length = -1  ) 
 

Reads a string.

If a length is not given (-1), it is assumed that the length of the string is stored in a short at the start of the string.

Definition at line 75 of file messagein.cpp.


Member Data Documentation

const char* MessageIn::mData [private]
 

Packet data.

Definition at line 61 of file messagein.hpp.

unsigned short MessageIn::mId [private]
 

The message ID.

Definition at line 63 of file messagein.hpp.

unsigned short MessageIn::mLength [private]
 

Length of data in bytes.

Definition at line 62 of file messagein.hpp.

unsigned short MessageIn::mPos [private]
 

Actual position in the packet.

From 0 to packet->length. A value bigger than packet->length means EOP was reached when reading it.

Definition at line 69 of file messagein.hpp.


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 15:39:18 2007 for TMW Server by  doxygen 1.3.9.1