PageRenderTime 45ms CodeModel.GetById 37ms app.highlight 7ms RepoModel.GetById 0ms app.codeStats 0ms

/src/IO_BinaryFileStream/BinaryFileStream_Load.cpp

http://github.com/Akranar/daguerreo
C++ | 109 lines | 98 code | 11 blank | 0 comment | 4 complexity | a24dcb0328b37c7539336d48b4af35b4 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
  1#include "BinaryFileStream.h"
  2#include <Core_ObjectFactory.h>
  3
  4bool BinaryFileStream::Load(Serializable *& val)
  5{
  6	const Serializable * old_address = (const Serializable *) endian.ReadIntType<void*>(stream);
  7	if (old_address == NULL)
  8	{
  9		val = NULL;
 10		return true;
 11	}
 12	if (ShouldUnserialize(old_address, val))
 13	{
 14		char * object_type_id;
 15		Load(object_type_id);
 16		val = load_factory->Create(object_type_id);
 17		delete object_type_id;
 18		SetOldToNew(old_address, val);
 19		val->Unserialize(*this);
 20		
 21	}
 22	return true;
 23}
 24
 25bool BinaryFileStream::Load(char *& val, int)
 26{
 27	unsigned int string_length = endian.ReadIntType<unsigned int>(stream);
 28	char * rtn = new char[string_length + 1];
 29	rtn[string_length] = 0;
 30	for (unsigned int i = 0; i < string_length; ++i)
 31	{
 32		rtn[i] = stream.get();
 33	}
 34	val = rtn;
 35	return true;
 36}
 37
 38bool BinaryFileStream::Load(Serializable & val)
 39{
 40	val.Unserialize(*this);
 41	return true;
 42}
 43
 44bool BinaryFileStream::Load(unsigned int & val)
 45{
 46	val = endian.ReadIntType<unsigned int>(stream);
 47	return true;
 48}
 49bool BinaryFileStream::Load(unsigned char & val)
 50{
 51	val = endian.ReadIntType<unsigned char>(stream);
 52	return true;
 53}
 54bool BinaryFileStream::Load(unsigned short & val)
 55{
 56	val = endian.ReadIntType<unsigned short>(stream);
 57	return true;
 58}
 59bool BinaryFileStream::Load(unsigned long & val)
 60{
 61	val = endian.ReadIntType<unsigned long>(stream);
 62	return true;
 63}
 64
 65
 66bool BinaryFileStream::Load(int & val)
 67{
 68	val = endian.ReadIntType<int>(stream);
 69	return true;
 70}
 71bool BinaryFileStream::Load(float & val)
 72{
 73	val = endian.ReadIntType<float>(stream);
 74	return true;
 75}
 76bool BinaryFileStream::Load(double & val)
 77{
 78	val = endian.ReadIntType<double>(stream);
 79	return true;
 80}
 81bool BinaryFileStream::Load(char & val)
 82{
 83	val = endian.ReadIntType<char>(stream);
 84	return true;
 85}
 86
 87bool BinaryFileStream::Load(bool & val)
 88{
 89	val = endian.ReadIntType<bool>(stream);
 90	return true;
 91}
 92
 93bool BinaryFileStream::Load(short & val)
 94{
 95	val = endian.ReadIntType<short>(stream);
 96	return true;
 97}
 98bool BinaryFileStream::Load(long & val)
 99{
100	val = endian.ReadIntType<long>(stream);
101	return true;
102}
103
104bool BinaryFileStream::Load(long double & val)
105{
106	val = endian.ReadIntType<long double>(stream);
107	return true;
108}
109