| 608 | namespace sfh |
| 609 | { |
| 610 | void WriteDocumentToFile(wil::com_ptr<IStream> stream, wil::com_ptr<IXMLDOMDocument> document) |
| 611 | { |
| 612 | auto mxWriter = wil::CoCreateInstance<IMXWriter>(CLSID_MXXMLWriter30); |
| 613 | auto saxReader = wil::CoCreateInstance<ISAXXMLReader>(CLSID_SAXXMLReader30); |
| 614 | |
| 615 | wil::unique_variant output; |
| 616 | wil::unique_variant unk; |
| 617 | |
| 618 | THROW_IF_FAILED(mxWriter->put_encoding(wil::make_bstr(L"UTF-8").get())); |
| 619 | THROW_IF_FAILED(mxWriter->put_standalone(VARIANT_TRUE)); |
| 620 | THROW_IF_FAILED(mxWriter->put_indent(VARIANT_TRUE)); |
| 621 | InitVariantFromUnknown(stream.query<IUnknown>().get(), unk.reset_and_addressof()); |
| 622 | THROW_IF_FAILED(mxWriter->put_output(unk)); |
| 623 | |
| 624 | THROW_IF_FAILED(saxReader->putContentHandler(mxWriter.query<ISAXContentHandler>().get())); |
| 625 | InitVariantFromUnknown(mxWriter.query<IUnknown>().get(), unk.reset_and_addressof()); |
| 626 | THROW_IF_FAILED(saxReader->putProperty(L"http://xml.org/sax/properties/lexical-handler", unk)); |
| 627 | THROW_IF_FAILED(saxReader->putProperty(L"http://xml.org/sax/properties/declaration-handler", unk)); |
| 628 | InitVariantFromUnknown(document.query<IUnknown>().get(), unk.reset_and_addressof()); |
| 629 | THROW_IF_FAILED(saxReader->parse(unk)); |
| 630 | } |
| 631 | |
| 632 | wil::com_ptr<IXMLDOMDocument> ConfigFileToDocument(const ConfigFile& config) |
| 633 | { |