aboutsummaryrefslogtreecommitdiff
path: root/sp/src/utils/vmpi/messbuf.h
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /sp/src/utils/vmpi/messbuf.h
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'sp/src/utils/vmpi/messbuf.h')
-rw-r--r--sp/src/utils/vmpi/messbuf.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/sp/src/utils/vmpi/messbuf.h b/sp/src/utils/vmpi/messbuf.h
new file mode 100644
index 00000000..2f09e884
--- /dev/null
+++ b/sp/src/utils/vmpi/messbuf.h
@@ -0,0 +1,52 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//
+// MessageBuffer - handy for packing and upacking
+// structures to be sent as messages
+//
+#ifndef _MESSAGEBUFFER
+#define _MESSAGEBUFFER
+
+#include <stdio.h>
+#define DEFAULT_MESSAGE_BUFFER_SIZE 2048
+
+class MessageBuffer {
+ public:
+ char * data;
+
+ MessageBuffer();
+ MessageBuffer(int size);
+ ~MessageBuffer();
+
+ int getSize();
+ int getLen();
+ int setLen(int len);
+ int getOffset();
+ int setOffset(int offset);
+
+ int write(void const * p, int bytes);
+ int update(int loc, void const * p, int bytes);
+ int extract(int loc, void * p, int bytes);
+ int read(void * p, int bytes);
+
+ int WriteString( const char *pString );
+ int ReadString( char *pOut, int bufferLength );
+
+ void clear();
+ void clear(int minsize);
+ void reset(int minsize);
+ void print(FILE * ofile, int num);
+
+ private:
+ void resize(int minsize);
+ int size;
+ int offset;
+ int len;
+};
+
+#endif