Esempio n. 1
0
void Format::Integer::Traverse(std::basic_ifstream<Char> &from, Extension &ext) const
{
	if(size == 1)
	{
		from.read((Char*)&ext.ByteValue, sizeof(ext.ByteValue));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Byte);
	}
	else if(size == 2)
	{
		from.read((Char*)&ext.ShortValue, sizeof(ext.ShortValue)/sizeof(Char));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Short);
	}
	else if(size == 4)
	{
		from.read((Char*)&ext.IntValue, sizeof(ext.IntValue)/sizeof(Char));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Int);
	}
	else if(size == 8)
	{
		from.read((Char*)&ext.LongValue, sizeof(ext.LongValue)/sizeof(Char));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Long);
	}
	else
	{
		ext.GenerateError(_T("Unkown Size; not Byte, Short, Int, or Long"));
	}
}
Esempio n. 2
0
void Format::Float::Traverse(std::basic_ifstream<Char> &from, Extension &ext) const
{
	if(doub)
	{
		from.read((Char*)&ext.DoubleValue, sizeof(ext.DoubleValue)/sizeof(Char));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Double);
	}
	else
	{
		from.read((Char*)&ext.FloatValue, sizeof(ext.FloatValue)/sizeof(Char));
		ext.Runtime.GenerateEvent(Extension::Trigger::Load::Float);
	}
}
Esempio n. 3
0
Format::ItemGroup::ItemGroup(std::basic_ifstream<Char> &from, const String &nam) : Item(nam) //Deserialize
{
	String n;
	int c;
	items_t::size_type size;
	from.read((Char*)&size, sizeof(size)/sizeof(Char));
	for(items_t::size_type i = 0; i < size; ++i)
	{
		for(n.clear(); c = from.get(); n += char(c));
		if((c = from.get()) == ItemGroup::TypeID)
		{
			items.push_back(new ItemGroup(from, n));
		}
		else if(c == Integer::TypeID)
		{
			items.push_back(new Integer(from, n));
		}
		else if(c == Float::TypeID)
		{
			items.push_back(new Float(from, n));
		}
		else if(c == Str::TypeID)
		{
			items.push_back(new Str(from, n));
		}
		else if(c == Raw::TypeID)
		{
			items.push_back(new Raw(from, n));
		}
		else
		{
			throw this;
		}
	}
}
Esempio n. 4
0
static Script::String loadFile(std::basic_ifstream<Script::Char>& instream, const std::string& filename) {
	Script::String chars;
	Script::Char* buffer = new Script::Char[1024 * 1024];
	try {
		while (!instream.eof()) {
			if (instream.bad())
				throw Script::Xception(Script::String("Error reading from file: ") += Pika::escape(filename));
			instream.read(buffer, 1024 * 1024);
			chars += Script::String(buffer, static_cast<Script::String::size_type>(instream.gcount()));
		}
		instream.close();
	}
	catch (...) {
		delete [] buffer;
		throw;
	}
	delete [] buffer;
	return chars;
}
Esempio n. 5
0
		Str(std::basic_ifstream<Char> &from, const String &n) : Item(n) //Deserialize
		{
			Char u;
			from.read(&u, sizeof(u)/sizeof(Char));
			unicode = u?true:false;
		}
Esempio n. 6
0
		Float(std::basic_ifstream<Char> &from, const String &n) : Item(n) //Deserialize
		{
			Char d;
			from.read(&d, sizeof(d)/sizeof(Char));
			doub = d?true:false;
		}
Esempio n. 7
0
		Integer(std::basic_ifstream<Char> &from, const String &n) : Item(n) //Deserialize
		{
			from.read((Char*)&size, sizeof(size)/sizeof(Char));
		}