aboutsummaryrefslogtreecommitdiff
path: root/dep/g3dlite/G3D/serialize.h
diff options
context:
space:
mode:
Diffstat (limited to 'dep/g3dlite/G3D/serialize.h')
-rw-r--r--dep/g3dlite/G3D/serialize.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/dep/g3dlite/G3D/serialize.h b/dep/g3dlite/G3D/serialize.h
new file mode 100644
index 00000000000..2382c0ee0fd
--- /dev/null
+++ b/dep/g3dlite/G3D/serialize.h
@@ -0,0 +1,30 @@
+#ifndef G3D_SERIALIZE_H
+#define G3D_SERIALIZE_H
+
+#include "G3D/BinaryInput.h"
+#include "G3D/BinaryOutput.h"
+#include "G3D/Array.h"
+
+namespace G3D {
+
+
+template<typename T>
+void serialize(const Array<T>& array, BinaryOutput& b) {
+ b.writeInt32(array.size());
+ for (int i = 0; i < array.size(); ++i) {
+ serialize(array[i], b);
+ }
+}
+
+template<typename T>
+void deserialize(Array<T>& array, BinaryInput& b) {
+ int N = b.readInt32();
+ array.resize(N);
+ for (int i = 0; i < array.size(); ++i) {
+ deserialize(array[i], b);
+ }
+}
+
+}
+
+#endif