1 /*
2  * PROJECT:     ReactOS Applications
3  * LICENSE:     LGPL - See COPYING in the top level directory
4  * FILE:        base/applications/msconfig_new/xmldomparser.cpp
5  * PURPOSE:     XML DOM Parser
6  * COPYRIGHT:   Copyright 2011-2012 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr>
7  */
8 
9 #pragma once
10 
11 /*
12  *
13  * MSXML Version    Header File Name    Library File Name    DLL File Name
14  * =======================================================================
15  *     2.x              msxml.h              msxml.lib         msxml2.dll
16  *     3.0              msxml2.h             msxml2.lib        msxml3.dll
17  *     4.0              msxml2.h             msxml2.lib        msxml4.dll
18  *     6.0              msxml6.h             msxml6.lib        msxml6.dll
19  */
20 // #pragma comment(lib, "msxml2.lib")
21 #include <initguid.h>
22 #define _COM_NO_STANDARD_GUIDS_
23 #include <comdef.h>
24 // #include <comutil.h> // comdef.h includes comutil.h
25 #include <ole2.h>
26 #include <msxml2.h>
27 
28 //
29 // About macro while(0) trick : see http://cnicholson.net/2009/03/stupid-c-tricks-dowhile0-and-c4127/
30 //
31 // Macro that releases a COM object if not NULL.
32 #define SAFE_RELEASE(p) \
33     do { if ((p)) { (p)->Release(); (p) = NULL; } } while (0)
34 
35 #if 0
36 //  IID_PPV_ARGS(ppType)
37 //      ppType is the variable of type IType that will be filled
38 //
39 //      RESULTS in:  IID_IType, ppvType
40 //      will create a compiler error if wrong level of indirection is used.
41 //
42 // See ObjBase.h - Only in Windows 7 SDK.
43 #ifndef IID_PPV_ARGS
44 extern "C++"
45 {
46     template<typename T> void** IID_PPV_ARGS_Helper(T** pp)
47     {
48         static_cast<IUnknown*>(*pp);    // make sure everyone derives from IUnknown
49         return reinterpret_cast<void**>(pp);
50     }
51 }
52 
53 #define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)
54 #endif
55 #else
56 // See include/reactos/shellutils.h
57 #ifdef __cplusplus
58 #   define IID_PPV_ARG(Itype, ppType) IID_##Itype, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
59 #   define IID_NULL_PPV_ARG(Itype, ppType) IID_##Itype, NULL, reinterpret_cast<void**>((static_cast<Itype**>(ppType)))
60 #else
61 #   define IID_PPV_ARG(Itype, ppType) IID_##Itype, (void**)(ppType)
62 #   define IID_NULL_PPV_ARG(Itype, ppType) IID_##Itype, NULL, (void**)(ppType)
63 #endif
64 #endif
65 
66 HRESULT InitXMLDOMParser(void);
67 void UninitXMLDOMParser(void);
68 
69 HRESULT CreateAndInitXMLDOMDocument(IXMLDOMDocument** ppDoc);
70 BOOL LoadXMLDocumentFromResource(IXMLDOMDocument* pXMLDom, LPCWSTR lpszXMLResName);
71 BOOL LoadXMLDocumentFromFile(IXMLDOMDocument* pXMLDom, LPCWSTR lpszFilename, BOOL bIgnoreErrorsIfNonExistingFile = FALSE);
72