packet.h
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   This program is free software; you can redistribute it and/or modify  *
  4.  *   it under the terms of the GNU General Public License as published by  *
  5.  *   the Free Software Foundation; either version 2 of the License, or     *
  6.  *   (at your option) any later version.                                   *
  7.  *                                                                         *
  8.  *   copyright            : (C) 2002 by Zhang Yong                         *
  9.  *   email                : z-yong163@163.com                              *
  10.  ***************************************************************************/
  11. #ifndef _PACKET_H
  12. #define _PACKET_H
  13. #include "icqtypes.h"
  14. class Packet {
  15. public:
  16. virtual const char *getData() = 0;
  17. virtual int getSize() = 0;
  18. };
  19. class OutPacket : public Packet {
  20. public:
  21. virtual OutPacket &operator <<(uint8 b) = 0;
  22. virtual OutPacket &operator <<(uint16 w) = 0;
  23. virtual OutPacket &operator <<(uint32 dw) = 0;
  24. virtual OutPacket &operator <<(const char *str) = 0;
  25. virtual OutPacket &operator <<(string &s) = 0;
  26. virtual void writeData(const char *buf, int n) = 0;
  27. };
  28. class InPacket : public Packet {
  29. public:
  30. virtual InPacket &operator >>(uint8 &b) = 0;
  31. virtual InPacket &operator >>(uint16 &w) = 0;
  32. virtual InPacket &operator >>(uint32 &dw) = 0;
  33. virtual InPacket &operator >>(const char *&str) = 0;
  34. virtual InPacket &operator >>(string &s) = 0;
  35. virtual uint16 getCmd() = 0;
  36. virtual const char *readData(int &n) = 0;
  37. };
  38. #endif