CLoadFile.h 795 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * CLoadFile.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "BinaryDeserializer.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class DLL_LINKAGE CLoadFile : public IBinaryReader
  14. {
  15. BinaryDeserializer serializer;
  16. std::string fName;
  17. std::fstream sfile;
  18. int read(std::byte * data, unsigned size) override; //throws!
  19. public:
  20. CLoadFile(const boost::filesystem::path & fname, IGameCallback * cb); //throws!
  21. template<class T>
  22. void load(T & data)
  23. {
  24. static_assert(is_serializeable<BinaryDeserializer, T>::value, "This class can't be deserialized (possible pointer?)");
  25. serializer & data;
  26. }
  27. };
  28. VCMI_LIB_NAMESPACE_END