#pragma once #include "stdafx.h" #include "ZeroElementRule.h" #include "XMLSerialization.h" #include "OTSFileSys.h" #include "Element.h" using namespace OTSTools; using namespace OTSDATA; using namespace xmls; void ZeroElementRule::Serialize(bool isStoring, tinyxml2::XMLDocument* classDoc, tinyxml2::XMLElement* rootNode) { xmls::xString xUsingElementListStr; xmls::xString xUsingConstants; xmls::xString xImgPropertyListStr; xmls::xString xOtherPropertyListStr; xmls::xString xExpstr; xmls::xString xZeroEleName; xmls::Slo slo; slo.Register("ZeroElement", &xZeroEleName); slo.Register("UsingElementList", &xUsingElementListStr); slo.Register("UsingConstants", &xUsingConstants); slo.Register("UsingImgPropertyList", &xImgPropertyListStr); slo.Register("UsingOtherPropertyList", &xOtherPropertyListStr); slo.Register("Expression", &xExpstr); if (isStoring) { xZeroEleName = m_ZeroElementName; CString s = ""; for (auto poElement : m_UsingelementList) { s += poElement->GetName() + ","; } s = s.TrimRight(","); xUsingElementListStr = s; s = ""; for (auto pName : m_ImgPropertyList) { s += pName.c_str(); s += ","; } s = s.TrimRight(","); xImgPropertyListStr = s; s = ""; for (auto pName : m_OtherpropertyList) { s += pName.c_str(); s += ","; } s = s.TrimRight(","); xOtherPropertyListStr = s; slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); SetExpressionStr(xExpstr.value()); m_ZeroElementName = xZeroEleName.value(); std::vector eles; std::string elements = xUsingElementListStr.c_str(); xmls::SplitString(elements, eles, ","); for (int i = 0; i < eles.size(); ++i) { CString ss = eles[i].c_str(); m_UsingelementList.push_back(CElementPtr(new CElement(ss))); } std::string propertynames = xImgPropertyListStr.c_str(); xmls::SplitString(propertynames, m_ImgPropertyList, ","); std::string otherPropertynames = xOtherPropertyListStr.c_str(); xmls::SplitString(otherPropertynames, m_OtherpropertyList, ","); xmls::SplitString(xUsingConstants.value(), m_usingConstants, ","); } }