2011-05-21 21:02:37 +02:00
|
|
|
#ifndef OUTPUTMESSAGE_H
|
|
|
|
#define OUTPUTMESSAGE_H
|
|
|
|
|
2011-07-28 01:01:33 +02:00
|
|
|
#include "netdeclarations.h"
|
2011-05-21 21:02:37 +02:00
|
|
|
|
|
|
|
class OutputMessage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum {
|
2011-05-30 05:11:12 +02:00
|
|
|
BUFFER_MAXSIZE = 1024,
|
|
|
|
HEADER_POS = 0,
|
|
|
|
HEADER_LENGTH = 2,
|
|
|
|
CHECKSUM_POS = 2,
|
|
|
|
CHECKSUM_LENGTH = 4,
|
|
|
|
DATA_POS = 6
|
2011-05-21 21:02:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
OutputMessage();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
void addU8(uint8 value);
|
|
|
|
void addU16(uint16 value);
|
|
|
|
void addU32(uint32 value);
|
|
|
|
void addU64(uint64 value);
|
|
|
|
void addString(const char* value);
|
|
|
|
void addString(const std::string &value);
|
2011-05-30 05:11:12 +02:00
|
|
|
void addPaddingBytes(int bytes, uint8 byte = 0);
|
|
|
|
|
2011-07-28 01:01:33 +02:00
|
|
|
uint8* getBuffer() { return m_buffer; }
|
2011-05-30 05:11:12 +02:00
|
|
|
uint16 getMessageSize() { return m_messageSize; }
|
2011-08-12 02:06:01 +02:00
|
|
|
void setMessageSize(uint16 messageSize) { m_messageSize = messageSize; }
|
2011-05-30 05:11:12 +02:00
|
|
|
void setWritePos(uint16 writePos) { m_writePos = writePos; }
|
2011-05-21 21:02:37 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool canWrite(int bytes);
|
|
|
|
|
2011-05-30 05:11:12 +02:00
|
|
|
uint16 m_writePos;
|
|
|
|
uint16 m_messageSize;
|
|
|
|
uint8 m_buffer[BUFFER_MAXSIZE];
|
2011-05-21 21:02:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|