Index: GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSerializer.cpp
===================================================================
--- GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSerializer.cpp	(revision 980)
+++ GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSerializer.cpp	(revision 1009)
@@ -1,243 +1,281 @@
 #include "GeoSerializer.h"
 
-
-namespace Geometry
-{
-	//---------------------------------------------------------------------
-	Serializer::Serializer(String name, Mode mode)
-		: mMode(mode)
-		{
-			char *char_mode = 0;
-			switch (mMode)
-			{
-				case READ : 
-					char_mode = "rb"; 
-					break;
-				case APPEND:
-					char_mode = "a+b";
-					break;
-				case WRITE:
-					char_mode = "wb";
-					break;
-			}
-
-			mFile = fopen(name.c_str(),char_mode);
-			mSize = 0;
-			assert(mFile);
-		}
-
-	//---------------------------------------------------------------------
-	Serializer::~Serializer()
-	{
-		fflush(mFile);
-		fclose(mFile);
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const float* const pFloat, size_t count)
-	{
-#	if GEO_ENDIAN == GEO_ENDIAN_BIG
-		float *float_to_write = (float *)malloc(sizeof(float) * count);
-		memcpy(float_to_write, pFloat, sizeof(float) * count);
-
-		flipToLittleEndian(float_to_write, sizeof(float), count);
-		writeData(float_to_write, sizeof(float), count);
-
-		free(float_to_write);
+using	namespace	Geometry;
+
+//---------------------------------------------------------------------------
+//	Constructor.
+//---------------------------------------------------------------------------
+Serializer::Serializer(String name, Mode mode): mMode(mode)
+{
+	char *char_mode = 0;
+
+	switch (mMode)
+	{
+		case READ : 
+			char_mode = "rb"; 
+			break;
+		case APPEND:
+			char_mode = "a+b";
+			break;
+		case WRITE:
+			char_mode = "wb";
+			break;
+	}
+
+	mFile = fopen(name.c_str(),char_mode);
+	mSize = 0;
+
+	assert(mFile);
+}
+
+//---------------------------------------------------------------------------
+//	Destroyer.
+//---------------------------------------------------------------------------
+Serializer::~Serializer()
+{
+	fflush(mFile);
+	fclose(mFile);
+}
+
+//---------------------------------------------------------------------------
+//	Write array of floats.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const float* const pFloat, size_t count)
+{
+#	if GEO_ENDIAN == GEO_ENDIAN_BIG
+	float *float_to_write = (float *)malloc(sizeof(float) * count);
+	memcpy(float_to_write, pFloat, sizeof(float) * count);
+
+	flipToLittleEndian(float_to_write, sizeof(float), count);
+	writeData(float_to_write, sizeof(float), count);
+
+	free(float_to_write);
 # 	else
-		WriteData(pFloat, sizeof(float), count);
-#	endif
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const uint16* const pShort, size_t count = 1)
-	{
-#	if GEO_ENDIAN == GEO_ENDIAN_BIG
-		unsigned short *short_to_write = (unsigned short *)malloc(sizeof(unsigned short) * count);
-		memcpy(short_to_write, pShort, sizeof(unsigned short) * count);
-
-		flipToLittleEndian(short_to_write, sizeof(unsigned short), count);
-		WriteData(short_to_write, sizeof(unsigned short), count);
-
-		free(short_to_write);
+	WriteData(pFloat, sizeof(float), count);
+#	endif
+}
+
+//---------------------------------------------------------------------------
+//	Write array of shots.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const uint16* const pShort, size_t count = 1)
+{
+#	if GEO_ENDIAN == GEO_ENDIAN_BIG
+	unsigned short *short_to_write = (unsigned short *)malloc(sizeof(unsigned short) * count);
+	memcpy(short_to_write, pShort, sizeof(unsigned short) * count);
+
+	flipToLittleEndian(short_to_write, sizeof(unsigned short), count);
+	WriteData(short_to_write, sizeof(unsigned short), count);
+
+	free(short_to_write);
 # 	else
-		WriteData(pShort, sizeof(unsigned short), count);
-#	endif
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const uint32* const pInt, size_t count = 1)
-	{
-#	if GEO_ENDIAN == GEO_ENDIAN_BIG
-		unsigned int *int_to_write = (unsigned int *)malloc(sizeof(unsigned int) * count);
-		memcpy(int_to_write, pInt, sizeof(unsigned int) * count);
-
-		FlipToLittleEndian(int_to_write, sizeof(unsigned int), count);
-		WriteData(int_to_write, sizeof(unsigned int), count);
-
-		free(int_to_write);
+	WriteData(pShort, sizeof(unsigned short), count);
+#	endif
+}
+	
+//---------------------------------------------------------------------------
+//	Write array of integers.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const uint32* const pInt, size_t count = 1)
+{
+#	if GEO_ENDIAN == GEO_ENDIAN_BIG
+	unsigned int *int_to_write = (unsigned int *)malloc(sizeof(unsigned int) * count);
+	memcpy(int_to_write, pInt, sizeof(unsigned int) * count);
+
+	FlipToLittleEndian(int_to_write, sizeof(unsigned int), count);
+	WriteData(int_to_write, sizeof(unsigned int), count);
+
+	free(int_to_write);
 # 	else
-		WriteData(pInt, sizeof(unsigned int), count);
-#	endif
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const bool* const pBool, size_t count = 1)
-	{
-		//TODO: Apple has problems 
-		WriteData(pBool, sizeof(bool), count);
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const Vector3* const pDest, size_t count)
-	{
-		for(size_t i = 0; i < count; ++i)
-		{
-			WriteArray(pDest[i].val,3);
-		}
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::WriteArray(const Vector2* const pDest, size_t count)
-	{
-		for(size_t i = 0; i < count; ++i)
-		{
-			WriteArray(pDest[i].val,2);
-		}
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::WriteData(const void* const buf, size_t size, size_t count)
-	{
-		size_t wcount = fwrite((void* const)buf, size, count, mFile);
-		assert(wcount == count);
-		mSize += size*count;
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::ReadData(void *pDest, size_t size, size_t count)
-	{
-		size_t rcount = fread(pDest,size,count,mFile);
-		assert(rcount == count);
-		mSize += size*count;
-	};
-
-
-	// JGA
-	char * Serializer::miReadData(char *pDest, size_t pDestsize)
-	{
-		return fgets(pDest, (int)pDestsize, mFile);
-	};
-
-	void Serializer::miReadData2(void *pDest, size_t size, size_t count)
-	{
-		size_t rcount = fread(pDest,size,count,mFile);
-		assert(rcount == count);
-		mSize += size*count;
-	};
-	// fin JGA
-
-	//	GPR.
-	void	Serializer::WriteData(const	String	&string)
-	{
-		fputs(string.c_str(), mFile);
-
-		// Write terminating newline char
-		//fputc('\n', mFile);
-
-		mSize	+=	string.length();
-	}
-	//	fin	GPR
-
-	void	Serializer::WriteData(const char	*string)
-	{
-		fputs(string, mFile);
-
-		// Write terminating newline char
-		//fputc('\n', mFile);
-
-		mSize	+=	strlen(string) /*+ 1*/;
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(bool *pDest, size_t count)
-	{
-		//TODO:: Apple has problmes with bools
-		ReadData(pDest,sizeof(bool), count);
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(float *pDest, size_t count)
-	{
-		ReadData(pDest, sizeof(float), count);
-		FlipFromLittleEndian(pDest, sizeof(float), count);
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(unsigned short *pDest, size_t count)
-	{
-		ReadData(pDest, sizeof(unsigned short), count);
-		FlipFromLittleEndian(pDest, sizeof(unsigned short), count);
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(unsigned int *pDest, size_t count)
-	{
-		ReadData(pDest, sizeof(unsigned int), count);
-		FlipFromLittleEndian(pDest, sizeof(unsigned int), count);
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(Vector3 *pDest, size_t count)
-	{
-		for(size_t i = 0; i < count; ++i)
-		{
-			ReadArray(pDest[i].val,3);
-		}
-	}
-	
-	//---------------------------------------------------------------------
-	void Serializer::ReadArray(Vector2 *pDest, size_t count)
-	{
-		for(size_t i = 0; i < count; ++i)
-		{
-			ReadArray(pDest[i].val,2);
-		}
-	}
-
-	//---------------------------------------------------------------------
-	void Serializer::FlipToLittleEndian(void *pData, size_t size, size_t count)
-	{
-#	if GEO_ENDIAN == GEO_ENDIAN_BIG
-		FlipEndian(pData, size, count);
-#	endif
-	}
-
-	void Serializer::FlipFromLittleEndian(void *pData, size_t size, size_t count)
-	{
-#	if GEO_ENDIAN == GEO_ENDIAN_BIG
-		FlipEndian(pData, size, count);
-#	endif
-	}
-
-	void Serializer::FlipEndian(void *pData, size_t size, size_t count)
-	{
-		for(unsigned int index = 0; index < count; index++)
-		{
-			FlipEndian((void *)((char*)pData + (index * size)), size);
-		}
-	}
-
-	void Serializer::FlipEndian(void *pData, size_t size)
-	{
-		char swapByte;
-		for(unsigned int byteIndex = 0; byteIndex < size/2; byteIndex++)
-		{
-			swapByte = *((char *)pData + byteIndex);
-			*((char *)pData + byteIndex) = *((char *)pData + size - byteIndex - 1);
-			*((char *)pData + size - byteIndex - 1) = swapByte;
-		}
-	}
-
-}
-
+	WriteData(pInt, sizeof(unsigned int), count);
+#	endif
+}
+
+//---------------------------------------------------------------------------
+//	Write array of booleans.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const bool* const pBool, size_t count = 1)
+{
+	//TODO: Apple has problems 
+	WriteData(pBool, sizeof(bool), count);
+}
+	
+//---------------------------------------------------------------------------
+//	Write array of Vector3.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const Vector3* const pDest, size_t count)
+{
+	for(size_t i = 0; i < count; ++i)
+	{
+		WriteArray(pDest[i].val,3);
+	}
+}
+	
+//---------------------------------------------------------------------------
+//	Write array of Vector2.
+//---------------------------------------------------------------------------
+void Serializer::WriteArray(const Vector2* const pDest, size_t count)
+{
+	for(size_t i = 0; i < count; ++i)
+	{
+		WriteArray(pDest[i].val,2);
+	}
+}
+
+//---------------------------------------------------------------------------
+//	Write data.
+//---------------------------------------------------------------------------
+void Serializer::WriteData(const void* const buf, size_t size, size_t count)
+{
+	size_t wcount = fwrite((void* const)buf, size, count, mFile);
+	assert(wcount == count);
+	mSize += size*count;
+}
+
+//---------------------------------------------------------------------------
+//	Read data.
+//---------------------------------------------------------------------------
+void Serializer::ReadData(void *pDest, size_t size, size_t count)
+{
+	size_t rcount = fread(pDest,size,count,mFile);
+	assert(rcount == count);
+	mSize += size*count;
+}
+
+//---------------------------------------------------------------------------
+//	Read data.
+//---------------------------------------------------------------------------
+char * Serializer::ReadData(char *pDest, size_t pDestsize)
+{
+	return fgets(pDest, (int)pDestsize, mFile);
+}
+
+//---------------------------------------------------------------------------
+//	Write data.
+//---------------------------------------------------------------------------
+void	Serializer::WriteData(const	String	&string)
+{
+	fputs(string.c_str(), mFile);
+
+	// Write terminating newline char
+	//fputc('\n', mFile);
+
+	mSize	+=	string.length();
+}
+
+//---------------------------------------------------------------------------
+//	Write string data.
+//---------------------------------------------------------------------------
+void	Serializer::WriteData(const char	*string)
+{
+	fputs(string, mFile);
+
+	// Write terminating newline char
+	//fputc('\n', mFile);
+
+	mSize	+=	strlen(string) /*+ 1*/;
+}
+
+//---------------------------------------------------------------------------
+//	Read array of booleans.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(bool *pDest, size_t count)
+{
+	//TODO:: Apple has problmes with bools
+	ReadData(pDest,sizeof(bool), count);
+}
+
+//---------------------------------------------------------------------------
+//	Read array of floats.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(float *pDest, size_t count)
+{
+	ReadData(pDest, sizeof(float), count);
+	FlipFromLittleEndian(pDest, sizeof(float), count);
+}
+	
+//---------------------------------------------------------------------------
+//	Read array of unsigned shots.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(unsigned short *pDest, size_t count)
+{
+	ReadData(pDest, sizeof(unsigned short), count);
+	FlipFromLittleEndian(pDest, sizeof(unsigned short), count);
+}
+	
+//---------------------------------------------------------------------------
+//	Read array of unsigned integers.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(unsigned int *pDest, size_t count)
+{
+	ReadData(pDest, sizeof(unsigned int), count);
+	FlipFromLittleEndian(pDest, sizeof(unsigned int), count);
+}
+	
+//---------------------------------------------------------------------------
+//	Read array of Vector3.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(Vector3 *pDest, size_t count)
+{
+	for(size_t i = 0; i < count; ++i)
+	{
+		ReadArray(pDest[i].val,3);
+	}
+}
+	
+//---------------------------------------------------------------------------
+//	Read array of Vector2.
+//---------------------------------------------------------------------------
+void Serializer::ReadArray(Vector2 *pDest, size_t count)
+{
+	for(size_t i = 0; i < count; ++i)
+	{
+		ReadArray(pDest[i].val,2);
+	}
+}
+
+//---------------------------------------------------------------------------
+//	Flip to Little Endian.
+//---------------------------------------------------------------------------
+void Serializer::FlipToLittleEndian(void *pData, size_t size, size_t count)
+{
+#	if GEO_ENDIAN == GEO_ENDIAN_BIG
+	FlipEndian(pData, size, count);
+#	endif
+}
+
+//---------------------------------------------------------------------------
+//	Flip from Little Endian.
+//---------------------------------------------------------------------------
+void Serializer::FlipFromLittleEndian(void *pData, size_t size, size_t count)
+{
+#	if GEO_ENDIAN == GEO_ENDIAN_BIG
+	FlipEndian(pData, size, count);
+#	endif
+}
+
+//---------------------------------------------------------------------------
+//	Flip Endian.
+//---------------------------------------------------------------------------
+void Serializer::FlipEndian(void *pData, size_t size, size_t count)
+{
+	for(unsigned int index = 0; index < count; index++)
+	{
+		FlipEndian((void *)((char*)pData + (index * size)), size);
+	}
+}
+
+//---------------------------------------------------------------------------
+//	Flip Endian.
+//---------------------------------------------------------------------------
+void Serializer::FlipEndian(void *pData, size_t size)
+{
+	char swapByte;
+	for(unsigned int byteIndex = 0; byteIndex < size/2; byteIndex++)
+	{
+		swapByte = *((char *)pData + byteIndex);
+		*((char *)pData + byteIndex) = *((char *)pData + size - byteIndex - 1);
+		*((char *)pData + size - byteIndex - 1) = swapByte;
+	}
+}
+
