2
0

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