CModVersion.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #if defined(__UCLIBC__) || defined(__FreeBSD__) || defined(__OpenBSD__)
  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(const std::string & from);
  28. std::string toString() const;
  29. bool operator !=(const CModVersion & other) const;
  30. bool operator ==(const CModVersion & other) const;
  31. bool compatible(const CModVersion & other, bool checkMinor = false, bool checkPatch = false) const;
  32. bool isNull() const;
  33. template <typename Handler> void serialize(Handler &h)
  34. {
  35. h & major;
  36. h & minor;
  37. h & patch;
  38. }
  39. };
  40. DLL_LINKAGE bool operator < (const CModVersion & lesser, const CModVersion & greater);
  41. VCMI_LIB_NAMESPACE_END