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