JsonUpdater.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * JsonUpdater.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. #include "JsonTreeSerializer.h"
  12. class CBonusSystemNode;
  13. class DLL_LINKAGE JsonUpdater: public JsonTreeSerializer<const JsonNode *>
  14. {
  15. public:
  16. JsonUpdater(const IInstanceResolver * instanceResolver_, const JsonNode & root_);
  17. void serializeLIC(const std::string & fieldName, const TDecoder & decoder, const TEncoder & encoder, const std::vector<bool> & standard, std::vector<bool> & value) override;
  18. void serializeLIC(const std::string & fieldName, LIC & value) override;
  19. void serializeLIC(const std::string & fieldName, LICSet & value) override;
  20. void serializeString(const std::string & fieldName, std::string & value) override;
  21. void serializeRaw(const std::string & fieldName, JsonNode & value, const boost::optional<const JsonNode &> defaultValue) override;
  22. void serializeBonuses(const std::string & fieldName, CBonusSystemNode * value);
  23. protected:
  24. void serializeInternal(const std::string & fieldName, boost::logic::tribool & value) override;
  25. void serializeInternal(const std::string & fieldName, si32 & value, const boost::optional<si32> & defaultValue, const TDecoder & decoder, const TEncoder & encoder) override;
  26. void serializeInternal(const std::string & fieldName, std::vector<si32> & value, const TDecoder & decoder, const TEncoder & encoder) override;
  27. void serializeInternal(const std::string & fieldName, double & value, const boost::optional<double> & defaultValue) override;
  28. void serializeInternal(const std::string & fieldName, si64 & value, const boost::optional<si64> & defaultValue) override;
  29. void serializeInternal(const std::string & fieldName, si32 & value, const boost::optional<si32> & defaultValue, const std::vector<std::string> & enumMap) override;
  30. void serializeInternal(std::string & value) override;
  31. void serializeInternal(int64_t & value) override;
  32. private:
  33. void readLICPart(const JsonNode & part, const TDecoder & decoder, const bool val, std::vector<bool> & value);
  34. void readLICPart(const JsonNode & part, const TDecoder & decoder, std::set<si32> & value);
  35. };