Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
8.5 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. MPC_xml.h
  5. Abstract:
  6. This file contains the declaration of the XmlUtil class,
  7. the support class for handling XML data.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 05/08/99
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___MPC___XML_H___)
  13. #define __INCLUDED___MPC___XML_H___
  14. #include <MPC_main.h>
  15. #include <MPC_utils.h>
  16. /////////////////////////////////////////////////////////////////////////
  17. namespace MPC
  18. {
  19. class XmlUtil
  20. {
  21. CComPtr<IXMLDOMDocument> m_xddDoc;
  22. CComPtr<IXMLDOMNode> m_xdnRoot;
  23. HANDLE m_hEvent; // Used to abort a download.
  24. DWORD m_dwTimeout; // Used to limit a download.
  25. void Init ();
  26. void Clean();
  27. HRESULT LoadPost( /*[in] */ LPCWSTR szRootTag ,
  28. /*[out]*/ bool& fLoaded ,
  29. /*[out]*/ bool* fFound );
  30. HRESULT CreateParser();
  31. public:
  32. XmlUtil( /*[in]*/ const XmlUtil& xml );
  33. XmlUtil( /*[in]*/ IXMLDOMDocument* xddDoc , /*[in]*/ LPCWSTR szRootTag = NULL );
  34. XmlUtil( /*[in]*/ IXMLDOMNode* xdnRoot = NULL, /*[in]*/ LPCWSTR szRootTag = NULL );
  35. ~XmlUtil();
  36. XmlUtil& operator=( /*[in]*/ const XmlUtil& xml );
  37. XmlUtil& operator=( /*[in]*/ IXMLDOMNode* xdnRoot );
  38. HRESULT DumpError();
  39. HRESULT New ( /*[in]*/ IXMLDOMNode* xdnRoot , /*[in] */ BOOL fDeep = false );
  40. HRESULT New ( /*[in]*/ LPCWSTR szRootTag, /*[in] */ LPCWSTR szEncoding = L"unicode" );
  41. HRESULT Load ( /*[in ]*/ LPCWSTR szFile , /*[in]*/ LPCWSTR szRootTag, /*[out]*/ bool& fLoaded, /*[out]*/ bool* fFound = NULL );
  42. HRESULT LoadAsStream( /*[in ]*/ IUnknown* pStream , /*[in]*/ LPCWSTR szRootTag, /*[out]*/ bool& fLoaded, /*[out]*/ bool* fFound = NULL );
  43. HRESULT LoadAsString( /*[in ]*/ BSTR bstrData, /*[in]*/ LPCWSTR szRootTag, /*[out]*/ bool& fLoaded, /*[out]*/ bool* fFound = NULL );
  44. HRESULT Save ( /*[in ]*/ LPCWSTR szFile );
  45. HRESULT SaveAsStream( /*[out]*/ IUnknown* *ppStream );
  46. HRESULT SaveAsString( /*[out]*/ BSTR *pbstrData );
  47. HRESULT SetTimeout( /*[in]*/ DWORD dwTimeout );
  48. HRESULT Abort ( );
  49. HRESULT SetVersionAndEncoding( /*[in]*/ LPCWSTR szVersion, /*[in]*/ LPCWSTR szEncoding );
  50. HRESULT GetDocument ( /*[out]*/ IXMLDOMDocument* * pVal ) const;
  51. HRESULT GetRoot ( /*[out]*/ IXMLDOMNode* * pVal ) const;
  52. HRESULT GetNodes ( /*[in]*/ LPCWSTR szTag, /*[out]*/ IXMLDOMNodeList* * pVal ) const;
  53. HRESULT GetNode ( /*[in]*/ LPCWSTR szTag, /*[out]*/ IXMLDOMNode* * pVal ) const;
  54. HRESULT CreateNode ( /*[in]*/ LPCWSTR szTag, /*[out]*/ IXMLDOMNode* * pVal, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  55. HRESULT GetAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[out]*/ IXMLDOMAttribute* * pValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  56. HRESULT GetAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[out]*/ CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  57. HRESULT GetAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[out]*/ MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  58. HRESULT GetAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[out]*/ LONG& lValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  59. HRESULT GetValue ( /*[in]*/ LPCWSTR szTag, /*[out]*/ CComVariant& vValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  60. HRESULT GetValue ( /*[in]*/ LPCWSTR szTag, /*[out]*/ CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  61. HRESULT GetValue ( /*[in]*/ LPCWSTR szTag, /*[out]*/ MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  62. HRESULT ModifyAttribute( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ const CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  63. HRESULT ModifyAttribute( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ const MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  64. HRESULT ModifyAttribute( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ LPCWSTR szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  65. HRESULT ModifyAttribute( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ LONG lValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  66. HRESULT ModifyValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const CComVariant& vValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  67. HRESULT ModifyValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  68. HRESULT ModifyValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  69. HRESULT PutAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ IXMLDOMAttribute* * pValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  70. HRESULT PutAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ const CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  71. HRESULT PutAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ const MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  72. HRESULT PutAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ LPCWSTR szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  73. HRESULT PutAttribute ( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in] */ LONG lValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  74. HRESULT PutValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const CComVariant& vValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  75. HRESULT PutValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const CComBSTR& bstrValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  76. HRESULT PutValue ( /*[in]*/ LPCWSTR szTag, /*[in] */ const MPC::wstring& szValue, /*[out]*/ bool& fFound, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  77. HRESULT RemoveAttribute( /*[in]*/ LPCWSTR szTag, /*[in]*/ LPCWSTR szAttr, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  78. HRESULT RemoveValue ( /*[in]*/ LPCWSTR szTag, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  79. HRESULT RemoveNode ( /*[in]*/ LPCWSTR szTag, /*[in]*/ IXMLDOMNode* pxdnNode = NULL );
  80. };
  81. ////////////////////////////////////////////////////////////////////////////////
  82. HRESULT ConvertFromRegistryToXML( /*[in]*/ const MPC::RegKey& rkKey, /*[out]*/ MPC::XmlUtil& xml );
  83. HRESULT ConvertFromXMLToRegistry( /*[in]*/ const MPC::XmlUtil& xml , /*[out]*/ MPC::RegKey& rkKey );
  84. }; // namespace
  85. /////////////////////////////////////////////////////////////////////////
  86. #endif // !defined(__INCLUDED___MPC___XML_H___)