/// This method creates the entire XML-tree structure from the string- based /// medium specification object. I know, indentation is not necessary for this, /// but my OCD kicked in... std::string makeMedium(Medium const& m) { std::stringstream medium; medium << indent(2) << "<medium>\n"; medium << makePhases(m.phases); medium << makeProperties(6, m.property); medium << indent(2) << "</medium>\n"; return medium.str(); }
/// This method creates an XML-snippet of a single component. std::string makeComponent(Component const& c) { std::stringstream component; component << indent(12) << "<component>\n"; component << indent(14) << "<name>" << c.property[MPL::name] << "</name>\n"; component << makeProperties(14, c.property); component << indent(12) << "</component>\n"; return component.str(); }
/// This method creates an XML-snippet of a single material phase. std::string makePhase(Phase const& p) { std::stringstream phase; phase << indent(8) << "<phase>\n"; phase << indent(10) << "<type>" << p.property[MPL::name] << "</type>\n"; phase << makeComponents(p.component); phase << makeProperties(8, p.property); phase << indent(8) << "</phase>\n"; return phase.str(); }
void mergePropSet(MatchNode* parent, int sourceLayer, const PropertySpecSet& ps) { auto properties = makeProperties(ps.properties, sourceLayer); for (const auto& rawSelector : ps.selectors) { auto* node = parent; auto selector = transformSelector(rawSelector); for (auto sel = selector.rbegin(), end = std::prev(selector.rend()); sel != end; ++sel) { node = matchAndInsertSel(node, *sel, nullptr); } node = matchAndInsertSel(node, selector.front(), &properties); } }