Serialize.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. void serialize(tinyxml2::XMLElement* elem, 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. void serialize<Gradient>(tinyxml2::XMLElement* elem, const Gradient&);
  26. template<>
  27. Gradient deserialize<Gradient>(tinyxml2::XMLElement* xml);
  28. template<>
  29. std::string toXml<Gradient>(const Gradient&);
  30. template<>
  31. Gradient fromXml<Gradient>(const std::string& xml);
  32. template<>
  33. void serialize<mnd::MandelViewport>(tinyxml2::XMLElement* elem, const mnd::MandelViewport&);
  34. template<>
  35. mnd::MandelViewport deserialize<mnd::MandelViewport>(tinyxml2::XMLElement* xml);
  36. template<>
  37. void serialize<mnd::MandelInfo>(tinyxml2::XMLElement* elem, const mnd::MandelInfo&);
  38. template<>
  39. mnd::MandelInfo deserialize<mnd::MandelInfo>(tinyxml2::XMLElement* xml);
  40. template<>
  41. void serialize<ImageView>(tinyxml2::XMLElement* elem, const ImageView&);
  42. template<>
  43. ImageView deserialize<ImageView>(tinyxml2::XMLElement* xml);
  44. template<>
  45. std::string toXml<ImageView>(const ImageView&);
  46. template<>
  47. ImageView fromXml<ImageView>(const std::string& xml);
  48. }
  49. struct alm::ImageView
  50. {
  51. mnd::MandelInfo view;
  52. Gradient gradient;
  53. };
  54. #endif // LIBALMOND_SERIALIZE_H