MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / ConfigFileToDocument

Function ConfigFileToDocument

PersistantDataLib/PersistantData.cpp:632–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630 }
631
632 wil::com_ptr<IXMLDOMDocument> ConfigFileToDocument(const ConfigFile& config)
633 {
634 auto document = wil::CoCreateInstance<IXMLDOMDocument>(CLSID_DOMDocument30);
635
636 wil::com_ptr<IXMLDOMElement> rootElement;
637 THROW_IF_FAILED(document->createElement(wil::make_bstr(L"ConfigFile").get(), rootElement.put()));
638 wil::unique_variant value;
639 InitVariantFromString(std::to_wstring(config.wmiPollInterval).c_str(), value.addressof());
640 THROW_IF_FAILED(rootElement->setAttribute(wil::make_bstr(L"wmiPollInterval").get(), value));
641 InitVariantFromString(std::to_wstring(config.lruSize).c_str(), value.addressof());
642 THROW_IF_FAILED(rootElement->setAttribute(wil::make_bstr(L"lruSize").get(), value));
643 for (auto& indexFile : config.m_indexFile)
644 {
645 wil::com_ptr<IXMLDOMElement> indexFileElement;
646 THROW_IF_FAILED(document->createElement(wil::make_bstr(L"IndexFile").get(), indexFileElement.put()));
647
648 THROW_IF_FAILED(indexFileElement->put_text(wil::make_bstr(indexFile.m_path.c_str()).get()));
649 THROW_IF_FAILED(rootElement->appendChild(indexFileElement.get(), nullptr));
650 }
651 for (auto& monitorProcess : config.m_monitorProcess)
652 {
653 wil::com_ptr<IXMLDOMElement> monitorProcessElement;
654 THROW_IF_FAILED(
655 document->createElement(wil::make_bstr(L"MonitorProcess").get(), monitorProcessElement.put()));
656
657 THROW_IF_FAILED(monitorProcessElement->put_text(wil::make_bstr(monitorProcess.m_name.c_str()).get()));
658 THROW_IF_FAILED(rootElement->appendChild(monitorProcessElement.get(), nullptr));
659 }
660
661 THROW_IF_FAILED(document->putref_documentElement(rootElement.get()));
662
663 return document;
664 }
665
666 wil::com_ptr<IXMLDOMDocument> FontDatabaseToDocument(const FontDatabase& db)
667 {

Callers 1

WriteToFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected