Source code of Windows XP (NT5)
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.

73 lines
2.4 KiB

  1. /*
  2. * Filename: NLB_XMLParser.h
  3. * Description:
  4. * Author: shouse, 04.10.01
  5. */
  6. #ifndef __NLB_XMLPARSER_H__
  7. #define __NLB_XMLPARSER_H__
  8. #include "NLB_Common.h"
  9. #include "NLB_Cluster.h"
  10. #include "NLB_Host.h"
  11. #include "NLB_PortRule.h"
  12. #include "NLB_XMLError.h"
  13. #define CHECKHR(x) {hr = x; if (FAILED(hr)) {goto CleanUp;}}
  14. #define CHECKALLOC(x) {if (!x) {hr = E_FAIL; goto CleanUp;}}
  15. #define SAFERELEASE(p) {if (p) {(p)->Release(); p = NULL;}}
  16. #define SAFEFREESTRING(p) {if (p) {SysFreeString(p); p = NULL;}}
  17. class NLB_XMLParser {
  18. public:
  19. NLB_XMLParser ();
  20. NLB_XMLParser (bool bSilent);
  21. ~NLB_XMLParser ();
  22. HRESULT Parse (WCHAR * wszFileName);
  23. HRESULT Parse (WCHAR * wszFileName, bool bPrintTree);
  24. HRESULT Parse (WCHAR * wszFileName, vector<NLB_Cluster> * pClusters);
  25. void Print ();
  26. void Print (vector<NLB_Cluster> Clusters);
  27. void GetParseError(NLB_XMLError * pError);
  28. private:
  29. BSTR AsciiToBSTR (const char * pszName);
  30. CHAR * BSTRToAscii (const WCHAR * pwszName);
  31. NLB_IPAddress::NLB_IPAddressType StringToIPAddressType (const WCHAR * pwszType);
  32. NLB_ClusterMode::NLB_ClusterModeType StringToClusterMode (const WCHAR * pwszType);
  33. NLB_RemoteControl::NLB_RemoteControlEnabled StringToRemoteControlEnabled (const WCHAR * pwszType);
  34. NLB_HostState::NLB_HostStateType StringToHostState (const WCHAR * pwszState);
  35. HRESULT LoadDocument (BSTR pBURL);
  36. HRESULT CheckDocumentLoad ();
  37. void SetParseError (HRESULT hrCode, PWSTR pwszReason);
  38. HRESULT PrintTree (MSXML2::IXMLDOMNode* node, int level);
  39. HRESULT ParseCluster (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  40. HRESULT ParseClusterProperties (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  41. HRESULT ParseClusterHosts (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  42. HRESULT ParseClusterPortRules (MSXML2::IXMLDOMNode * pNode, NLB_Cluster * pCluster);
  43. HRESULT ParseIPAddress (MSXML2::IXMLDOMNode * pNode, NLB_IPAddress * pIPAddress);
  44. HRESULT ParseAdapter (MSXML2::IXMLDOMNode * pNode, NLB_Adapter * pAdapter);
  45. HRESULT ParseRemoteControl (MSXML2::IXMLDOMNode * pNode, NLB_RemoteControl * pControl);
  46. HRESULT ParseHost (MSXML2::IXMLDOMNode * pNode, NLB_Host * pHost);
  47. private:
  48. vector<NLB_Cluster> ClusterList;
  49. MSXML2::IXMLDOMDocument2 * pDoc;
  50. MSXML2::IXMLDOMSchemaCollection * pSchema;
  51. NLB_XMLError ParseError;
  52. bool bShowErrorPopups;
  53. };
  54. #endif