ModIncompatibility.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * ModIncompatibility.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. VCMI_LIB_NAMESPACE_BEGIN
  12. class DLL_LINKAGE ModIncompatibility: public std::exception
  13. {
  14. public:
  15. using ModListWithVersion = std::vector<std::pair<const std::string, const std::string>>;
  16. using ModList = std::vector<const std::string>;
  17. ModIncompatibility(const ModListWithVersion & _missingMods)
  18. {
  19. std::ostringstream _ss;
  20. for(const auto & m : _missingMods)
  21. _ss << m.first << ' ' << m.second << std::endl;
  22. messageMissingMods = _ss.str();
  23. }
  24. ModIncompatibility(const ModListWithVersion & _missingMods, ModList & _excessiveMods)
  25. : ModIncompatibility(_missingMods)
  26. {
  27. std::ostringstream _ss;
  28. for(const auto & m : _excessiveMods)
  29. _ss << m << std::endl;
  30. messageExcessiveMods = _ss.str();
  31. }
  32. const char * what() const noexcept override
  33. {
  34. static const std::string w("Mod incompatibility exception");
  35. return w.c_str();
  36. }
  37. const std::string & whatMissing() const noexcept
  38. {
  39. return messageMissingMods;
  40. }
  41. const std::string & whatExcessive() const noexcept
  42. {
  43. return messageExcessiveMods;
  44. }
  45. private:
  46. std::string messageMissingMods, messageExcessiveMods;
  47. };
  48. VCMI_LIB_NAMESPACE_END