Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. //
  9. // MessageBuffer - handy for packing and upacking
  10. // structures to be sent as messages
  11. //
  12. #ifndef _MESSAGEBUFFER
  13. #define _MESSAGEBUFFER
  14. #include <stdio.h>
  15. #define DEFAULT_MESSAGE_BUFFER_SIZE 2048
  16. class MessageBuffer {
  17. public:
  18. char * data;
  19. MessageBuffer();
  20. MessageBuffer(int size);
  21. ~MessageBuffer();
  22. int getSize();
  23. int getLen();
  24. int setLen(int len);
  25. int getOffset();
  26. int setOffset(int offset);
  27. int write(void const * p, int bytes);
  28. int update(int loc, void const * p, int bytes);
  29. int extract(int loc, void * p, int bytes);
  30. int read(void * p, int bytes);
  31. int WriteString( const char *pString );
  32. int ReadString( char *pOut, int bufferLength );
  33. void clear();
  34. void clear(int minsize);
  35. void reset(int minsize);
  36. void print(FILE * ofile, int num);
  37. void *GetReadPointer()
  38. {
  39. return ( void * )( data + offset );
  40. }
  41. int GetReadBytesLeft()
  42. {
  43. return len - offset;
  44. }
  45. private:
  46. void resize(int minsize);
  47. int size;
  48. int offset;
  49. int len;
  50. };
  51. #endif