JsonSerializer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * JsonSerializer.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 JsonSerializer: public JsonSerializeFormat
  14. {
  15. public:
  16. JsonSerializer(JsonNode & root_);
  17. void serializeBool(const std::string & fieldName, bool & value) override;
  18. void serializeEnum(const std::string & fieldName, const std::string & trueValue, const std::string & falseValue, bool & value) override;
  19. void serializeLIC(const std::string & fieldName, const TDecoder & decoder, const TEncoder & encoder, const std::vector<bool> & standard, std::vector<bool> & value) override;
  20. void serializeLIC(const std::string & fieldName, LIC & value) override;
  21. void serializeString(const std::string & fieldName, std::string & value) override;
  22. protected:
  23. void serializeFloat(const std::string & fieldName, double & value) override;
  24. void serializeIntEnum(const std::string & fieldName, const std::vector<std::string> & enumMap, const si32 defaultValue, si32 & value) override;
  25. void serializeIntId(const std::string & fieldName, const TDecoder & decoder, const TEncoder & encoder, const si32 defaultValue, si32 & value) override;
  26. private:
  27. void writeLICPart(const std::string & fieldName, const std::string & partName, const TEncoder & encoder, const std::vector<bool> & data);
  28. };