2023-11-11 00:39:08 +02:00
|
|
|
/*
|
|
|
|
* CLoadFile.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BinaryDeserializer.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class DLL_LINKAGE CLoadFile : public IBinaryReader
|
|
|
|
{
|
|
|
|
BinaryDeserializer serializer;
|
2025-04-12 21:25:23 +03:00
|
|
|
std::fstream sfile;
|
2023-11-11 00:39:08 +02:00
|
|
|
|
2024-02-02 02:36:57 +02:00
|
|
|
int read(std::byte * data, unsigned size) override; //throws!
|
2023-11-11 00:39:08 +02:00
|
|
|
|
2025-04-12 21:25:23 +03:00
|
|
|
public:
|
|
|
|
CLoadFile(const boost::filesystem::path & fname, IGameCallback * cb); //throws!
|
2023-11-11 00:39:08 +02:00
|
|
|
|
|
|
|
template<class T>
|
2025-04-12 21:25:23 +03:00
|
|
|
void load(T & data)
|
2023-11-11 00:39:08 +02:00
|
|
|
{
|
2025-04-12 21:25:23 +03:00
|
|
|
serializer & data;
|
2023-11-11 00:39:08 +02:00
|
|
|
}
|
2025-04-16 17:05:52 +03:00
|
|
|
|
|
|
|
bool hasFeature(BinaryDeserializer::Version v) const
|
|
|
|
{
|
|
|
|
return serializer.version >= v;
|
|
|
|
}
|
2023-11-11 00:39:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|