summaryrefslogtreecommitdiff
path: root/public/tier1/kvpacker.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/tier1/kvpacker.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/tier1/kvpacker.h')
-rw-r--r--public/tier1/kvpacker.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/public/tier1/kvpacker.h b/public/tier1/kvpacker.h
new file mode 100644
index 0000000..7e47fa1
--- /dev/null
+++ b/public/tier1/kvpacker.h
@@ -0,0 +1,49 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef KVPACKER_H
+#define KVPACKER_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "KeyValues.h"
+
+//-----------------------------------------------------------------------------
+// Purpose: Handles packing KeyValues binary packing and unpacking in a a
+// consistent way across all branches, including Steam. If you change
+// this packing format you need to do so in a backward compatible way
+// so that the Steam servers and all the various GCs can still talk to
+// each other.
+//-----------------------------------------------------------------------------
+class KVPacker
+{
+public:
+ bool WriteAsBinary( KeyValues *pNode, CUtlBuffer &buffer );
+ bool ReadAsBinary( KeyValues *pNode, CUtlBuffer &buffer );
+
+private:
+ // These types are used for serialization of KeyValues nodes.
+ // Do not renumber them or you will break serialization across
+ // branches.
+ enum EPackType
+ {
+ PACKTYPE_NONE = 0,
+ PACKTYPE_STRING,
+ PACKTYPE_INT,
+ PACKTYPE_FLOAT,
+ PACKTYPE_PTR,
+ PACKTYPE_WSTRING,
+ PACKTYPE_COLOR,
+ PACKTYPE_UINT64,
+ PACKTYPE_NULLMARKER, // used to mark the end of a block in the binary format
+ };
+};
+
+
+#endif // KVPACKER_H