JsonDeserializer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * JsonDeserializer.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 "JsonSerializeFormat.h"
  12. class JsonNode;
  13. class JsonDeserializer: public JsonSerializeFormat
  14. {
  15. public:
  16. JsonDeserializer(const IInstanceResolver * instanceResolver_, 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. protected:
  22. void serializeInternal(const std::string & fieldName, boost::logic::tribool & value) override;
  23. void serializeInternal(const std::string & fieldName, si32 & value, const boost::optional<si32> & defaultValue, const TDecoder & decoder, const TEncoder & encoder) override;
  24. void serializeInternal(const std::string & fieldName, std::vector<si32> & value, const TDecoder & decoder, const TEncoder & encoder) override;
  25. void serializeInternal(const std::string & fieldName, double & value, const boost::optional<double> & defaultValue) override;
  26. void serializeInternal(const std::string & fieldName, si64 & value, const boost::optional<si64> & defaultValue) override;
  27. void serializeInternal(const std::string & fieldName, si32 & value, const boost::optional<si32> & defaultValue, const std::vector<std::string> & enumMap) override;
  28. private:
  29. void readLICPart(const JsonNode & part, const TDecoder & decoder, const bool val, std::vector<bool> & value);
  30. void readLICPart(const JsonNode & part, const TDecoder & decoder, std::set<si32> & value);
  31. };