CModVersion.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * CModVersion.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. #ifdef __UCLIBC__
  12. #undef major
  13. #undef minor
  14. #undef patch
  15. #endif
  16. VCMI_LIB_NAMESPACE_BEGIN
  17. struct DLL_LINKAGE CModVersion
  18. {
  19. static const int Any = -1;
  20. int major = Any;
  21. int minor = Any;
  22. int patch = Any;
  23. CModVersion() = default;
  24. CModVersion(int mj, int mi, int p): major(mj), minor(mi), patch(p) {}
  25. static CModVersion GameVersion();
  26. static CModVersion fromString(std::string from);
  27. std::string toString() const;
  28. bool compatible(const CModVersion & other, bool checkMinor = false, bool checkPatch = false) const;
  29. bool isNull() const;
  30. template <typename Handler> void serialize(Handler &h, const int version)
  31. {
  32. h & major;
  33. h & minor;
  34. h & patch;
  35. }
  36. };
  37. DLL_LINKAGE bool operator < (const CModVersion & lesser, const CModVersion & greater);
  38. VCMI_LIB_NAMESPACE_END