Serialize.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #ifndef LIBALMOND_SERIALIZE_H
  3. #define LIBALMOND_SERIALIZE_H
  4. #include <MandelUtil.h>
  5. #include "Gradient.h"
  6. #include <string>
  7. namespace tinyxml2
  8. {
  9. class XMLElement;
  10. class XMLDocument;
  11. }
  12. namespace alm
  13. {
  14. struct ImageView;
  15. template<typename T>
  16. tinyxml2::XMLElement* serialize(tinyxml2::XMLDocument& doc, const T&);
  17. template<typename T>
  18. std::string toXml(const T&);
  19. template<typename T>
  20. T deserialize(tinyxml2::XMLElement* xml);
  21. template<typename T>
  22. T fromXml(const std::string& xml);
  23. // specializations
  24. template<>
  25. tinyxml2::XMLElement* serialize<Gradient>(tinyxml2::XMLDocument& doc, const Gradient&);
  26. template<>
  27. std::string toXml<Gradient>(const Gradient&);
  28. template<>
  29. Gradient deserialize<Gradient>(tinyxml2::XMLElement* xml);
  30. template<>
  31. Gradient fromXml<Gradient>(const std::string& xml);
  32. }
  33. struct alm::ImageView
  34. {
  35. mnd::MandelInfo view;
  36. Gradient gradient;
  37. std::string toXml(void) const;
  38. static ImageView fromXml(const std::string& xml);
  39. };
  40. #endif // LIBALMOND_SERIALIZE_H