aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/html/htmlprotobuf.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/public/html/htmlprotobuf.h
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'sp/src/public/html/htmlprotobuf.h')
-rw-r--r--sp/src/public/html/htmlprotobuf.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/sp/src/public/html/htmlprotobuf.h b/sp/src/public/html/htmlprotobuf.h
new file mode 100644
index 00000000..38ee6400
--- /dev/null
+++ b/sp/src/public/html/htmlprotobuf.h
@@ -0,0 +1,71 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//=============================================================================//
+
+#ifndef HTML_PROTOBUF
+#define HTML_PROTOBUF
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier1/utlbuffer.h"
+#include "html/htmlmessages.h"
+
+namespace google
+{
+ namespace protobuf
+ {
+ class MessageLite;
+ }
+}
+
+class CHTMLBaseProtoBufMsg
+{
+public:
+ void SerializeCrossProc( CUtlBuffer *pBuffer ) const;
+ bool BDeserializeCrossProc( CUtlBuffer *pBuffer );
+
+protected:
+ void *m_pMsg;
+ bool m_bIsValid;
+};
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Base class for protobuf objects
+//-----------------------------------------------------------------------------
+template< typename PB_OBJECT_TYPE >
+class CHTMLProtoBufMsg : public CHTMLBaseProtoBufMsg
+{
+public:
+ CHTMLProtoBufMsg( EHTMLCommands eMsg )
+ {
+ m_pMsg = new PB_OBJECT_TYPE;
+ m_bIsValid = true;
+ }
+
+ // Construct and deserialize in one
+ CHTMLProtoBufMsg( CUtlBuffer *pBuffer )
+ {
+ m_pMsg = NULL;
+ m_bIsValid = BDeserializeCrossProc( pBuffer );
+ }
+
+ // Destructor
+ virtual ~CHTMLProtoBufMsg()
+ {
+ delete (PB_OBJECT_TYPE *)m_pMsg;
+ }
+
+ bool BIsValid() { return m_bIsValid; }
+
+ // Accessors
+ PB_OBJECT_TYPE &Body() { return *((PB_OBJECT_TYPE*)( (google::protobuf::MessageLite *)m_pMsg )); }
+ const PB_OBJECT_TYPE &BodyConst() const { return *((const PB_OBJECT_TYPE*)( (google::protobuf::MessageLite *)m_pMsg )); }
+
+};
+
+
+#endif // HTML_PROTOBUF