ZeroElementRule.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "ZeroElementRule.h"
  4. #include "XMLSerialization.h"
  5. #include "OTSFileSys.h"
  6. #include "Element.h"
  7. using namespace OTSTools;
  8. using namespace OTSDATA;
  9. using namespace xmls;
  10. void ZeroElementRule::Serialize(bool isStoring, tinyxml2::XMLDocument* classDoc, tinyxml2::XMLElement* rootNode)
  11. {
  12. xmls::xString xUsingElementListStr;
  13. xmls::xString xUsingConstants;
  14. xmls::xString xImgPropertyListStr;
  15. xmls::xString xOtherPropertyListStr;
  16. xmls::xString xExpstr;
  17. xmls::xString xZeroEleName;
  18. xmls::Slo slo;
  19. slo.Register("ZeroElement", &xZeroEleName);
  20. slo.Register("UsingElementList", &xUsingElementListStr);
  21. slo.Register("UsingConstants", &xUsingConstants);
  22. slo.Register("UsingImgPropertyList", &xImgPropertyListStr);
  23. slo.Register("UsingOtherPropertyList", &xOtherPropertyListStr);
  24. slo.Register("Expression", &xExpstr);
  25. if (isStoring)
  26. {
  27. xZeroEleName = m_ZeroElementName;
  28. CString s = "";
  29. for (auto poElement : m_UsingelementList)
  30. {
  31. s += poElement->GetName() + ",";
  32. }
  33. s = s.TrimRight(",");
  34. xUsingElementListStr = s;
  35. s = "";
  36. for (auto pName : m_ImgPropertyList)
  37. {
  38. s += pName.c_str();
  39. s += ",";
  40. }
  41. s = s.TrimRight(",");
  42. xImgPropertyListStr = s;
  43. s = "";
  44. for (auto pName : m_OtherpropertyList)
  45. {
  46. s += pName.c_str();
  47. s += ",";
  48. }
  49. s = s.TrimRight(",");
  50. xOtherPropertyListStr = s;
  51. slo.Serialize(true, classDoc, rootNode);
  52. }
  53. else
  54. {
  55. slo.Serialize(false, classDoc, rootNode);
  56. SetExpressionStr(xExpstr.value());
  57. m_ZeroElementName = xZeroEleName.value();
  58. std::vector<string> eles;
  59. std::string elements = xUsingElementListStr.c_str();
  60. xmls::SplitString(elements, eles, ",");
  61. for (int i = 0; i < eles.size(); ++i)
  62. {
  63. CString ss = eles[i].c_str();
  64. m_UsingelementList.push_back(CElementPtr(new CElement(ss)));
  65. }
  66. std::string propertynames = xImgPropertyListStr.c_str();
  67. xmls::SplitString(propertynames, m_ImgPropertyList, ",");
  68. std::string otherPropertynames = xOtherPropertyListStr.c_str();
  69. xmls::SplitString(otherPropertynames, m_OtherpropertyList, ",");
  70. xmls::SplitString(xUsingConstants.value(), m_usingConstants, ",");
  71. }
  72. }