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.

190 lines
4.2 KiB

  1. //////////////////////////////////////////////////////////////////////
  2. // XMLReader.h : Declaration of CXMLContent
  3. // Copyright (c)1997-2001 Microsoft Corporation
  4. //
  5. // Original Create Date: 5/25/2001
  6. // Original Author: shawnwu
  7. //////////////////////////////////////////////////////////////////////
  8. #pragma once
  9. #include "globals.h"
  10. /*
  11. Class description
  12. Naming:
  13. CXMLContent stands for XML Content handler.
  14. Base class:
  15. (1) CComObjectRootEx for threading model and IUnknown.
  16. (2) ISAXContentHandler which implements handler.
  17. Purpose of class:
  18. (1) To support reading of XML file content handler. This handles events sent
  19. by MSXML parser.
  20. Design:
  21. (1) Just a typical COM object.
  22. Use:
  23. (1) Just call the static function.
  24. */
  25. #include <msxml2.h>
  26. class ATL_NO_VTABLE CXMLContent :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public ISAXContentHandler
  29. {
  30. protected:
  31. CXMLContent();
  32. virtual ~CXMLContent();
  33. public:
  34. BEGIN_COM_MAP(CXMLContent)
  35. COM_INTERFACE_ENTRY(ISAXContentHandler)
  36. END_COM_MAP()
  37. DECLARE_NOT_AGGREGATABLE( CXMLContent )
  38. DECLARE_REGISTRY_RESOURCEID(IDR_NETSECPROV)
  39. public:
  40. //
  41. // ISAXContentHandler
  42. //
  43. STDMETHOD(startElement) (
  44. IN const wchar_t * pwchNamespaceUri,
  45. IN int cchNamespaceUri,
  46. IN const wchar_t * pwchLocalName,
  47. IN int cchLocalName,
  48. IN const wchar_t * pwchQName,
  49. IN int cchQName,
  50. IN ISAXAttributes * pAttributes
  51. );
  52. STDMETHOD(endElement) (
  53. IN const wchar_t * pwchNamespaceUri,
  54. IN int cchNamespaceUri,
  55. IN const wchar_t * pwchLocalName,
  56. IN int cchLocalName,
  57. IN const wchar_t * pwchQName,
  58. IN int cchQName
  59. );
  60. STDMETHOD(startDocument) ();
  61. STDMETHOD(endDocument) ();
  62. STDMETHOD(putDocumentLocator) (
  63. IN ISAXLocator *pLocator
  64. );
  65. STDMETHOD(startPrefixMapping) (
  66. IN const wchar_t * pwchPrefix,
  67. IN int cchPrefix,
  68. IN const wchar_t * pwchUri,
  69. IN int cchUri
  70. );
  71. STDMETHOD(endPrefixMapping) (
  72. IN const wchar_t * pwchPrefix,
  73. IN int cchPrefix
  74. );
  75. STDMETHOD(characters) (
  76. IN const wchar_t * pwchChars,
  77. IN int cchChars
  78. );
  79. STDMETHOD(ignorableWhitespace) (
  80. IN const wchar_t * pwchChars,
  81. IN int cchChars
  82. );
  83. STDMETHOD(processingInstruction) (
  84. IN const wchar_t * pwchTarget,
  85. IN int cchTarget,
  86. IN const wchar_t * pwchData,
  87. IN int cchData
  88. );
  89. STDMETHOD(skippedEntity) (
  90. IN const wchar_t * pwchName,
  91. IN int cchName
  92. );
  93. //
  94. // other public functions for our handler
  95. //
  96. void SetOutputFile (
  97. IN LPCWSTR pszFileName
  98. )
  99. {
  100. m_bstrOutputFile = pszFileName;
  101. }
  102. void SetSection (
  103. IN LPCWSTR pszSecArea,
  104. IN LPCWSTR pszElement,
  105. IN bool bOneAreaOnly
  106. );
  107. bool ParseComplete()const
  108. {
  109. return m_bFinished;
  110. }
  111. private:
  112. bool GetAttributeValue (
  113. IN ISAXAttributes * pAttributes,
  114. IN LPCWSTR pszAttrName,
  115. OUT LPWSTR * ppszAttrVal
  116. );
  117. bool GetAttributeValue (
  118. IN ISAXAttributes * pAttributes,
  119. IN int iIndex,
  120. OUT LPWSTR * ppszAttrName,
  121. OUT LPWSTR * ppszAttrVal
  122. );
  123. void WriteContent (
  124. IN LPCWSTR pszName,
  125. IN LPCWSTR pszValue
  126. );
  127. CComBSTR m_bstrOutputFile;
  128. CComBSTR m_bstrSecArea;
  129. CComBSTR m_bstrElement;
  130. HANDLE m_hOutFile;
  131. DWORD m_dwTotalElements;
  132. bool m_bFinished;
  133. bool m_bSingleArea;
  134. bool m_bInSection;
  135. bool m_bInElement;
  136. };