CLoadFile.h 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. public:
  16. BinaryDeserializer serializer;
  17. std::string fName;
  18. std::unique_ptr<std::fstream> sfile;
  19. CLoadFile(const boost::filesystem::path & fname, ESerializationVersion minimalVersion = ESerializationVersion::CURRENT); //throws!
  20. virtual ~CLoadFile();
  21. int read(void * data, unsigned size) override; //throws!
  22. void openNextFile(const boost::filesystem::path & fname, ESerializationVersion minimalVersion); //throws!
  23. void clear();
  24. void reportState(vstd::CLoggerBase * out) override;
  25. void checkMagicBytes(const std::string & text);
  26. template<class T>
  27. CLoadFile & operator>>(T &t)
  28. {
  29. serializer & t;
  30. return * this;
  31. }
  32. };
  33. VCMI_LIB_NAMESPACE_END