summaryrefslogtreecommitdiffstats
path: root/code/utility.h
diff options
context:
space:
mode:
Diffstat (limited to 'code/utility.h')
-rw-r--r--code/utility.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/code/utility.h b/code/utility.h
new file mode 100644
index 0000000..32120cb
--- /dev/null
+++ b/code/utility.h
@@ -0,0 +1,16 @@
+#pragma once
+#include <algorithm>
+
+int VarIntRead(unsigned char *data, size_t &readed);
+
+size_t VarIntWrite(unsigned int value, unsigned char *data);
+
+long long int ReadVarLong(unsigned char *data, int &readed);
+
+unsigned char *WriteVarLong(unsigned long long int value, int &len);
+
+template<class T>
+void endswap(T *objp) {
+ unsigned char *memp = reinterpret_cast<unsigned char *>(objp);
+ std::reverse(memp, memp + sizeof(T));
+} \ No newline at end of file