CModVersion.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. using TModID = std::string;
  18. struct DLL_LINKAGE CModVersion
  19. {
  20. static const int Any = -1;
  21. int major = Any;
  22. int minor = Any;
  23. int patch = Any;
  24. CModVersion() = default;
  25. CModVersion(int mj, int mi, int p): major(mj), minor(mi), patch(p) {}
  26. static CModVersion GameVersion();
  27. static CModVersion fromString(std::string from);
  28. std::string toString() const;
  29. bool compatible(const CModVersion & other, bool checkMinor = false, bool checkPatch = false) const;
  30. bool isNull() const;
  31. template <typename Handler> void serialize(Handler &h, const int version)
  32. {
  33. h & major;
  34. h & minor;
  35. h & patch;
  36. }
  37. };
  38. DLL_LINKAGE bool operator < (const CModVersion & lesser, const CModVersion & greater);
  39. VCMI_LIB_NAMESPACE_END