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.

94 lines
2.5 KiB

  1. /* @doc
  2. *
  3. * @module XMLResponse.h |
  4. *
  5. * Header file for XMLResponse.cpp
  6. *
  7. * Author: Ying-ping Chen (t-ypchen)
  8. */
  9. #pragma once
  10. // @class CXMLResponse | XML response class for the XML client interface
  11. class CXMLResponse {
  12. // @access Public Members
  13. public:
  14. enum eResponseType {
  15. RESPONSE_UNDEFINED = 0,
  16. RESPONSE_SUCCESS,
  17. RESPONSE_FAIL,
  18. RESPONSE_TOTAL_NUM
  19. };
  20. // @cmember Constructor
  21. CXMLResponse
  22. ( LPCWSTR pwszNewTag,
  23. eResponseType rtNewType = RESPONSE_UNDEFINED
  24. );
  25. // @cmember Destructor
  26. ~CXMLResponse();
  27. // @cmember Get the response tag
  28. LPCWSTR GetResponseTag(void);
  29. // @cmember Set the response tag
  30. void SetResponseTag(LPCWSTR pwszNewTag);
  31. // @cmember Get the response type
  32. CXMLResponse::eResponseType GetType(void);
  33. // @cmember Set the response type
  34. void SetType(eResponseType rtNewType);
  35. // @cmember Convert the internal XML document to a string object
  36. void ToString(CStringW &cwszDoc);
  37. // @cmember Convert the internal XML document to a string object
  38. void ToString(CStringA &cszDoc);
  39. // @cmember Add an element to a specific node
  40. void AddElement
  41. ( const LPCWSTR pwszTag,
  42. IXMLDOMNode *pParentNode = NULL,
  43. IXMLDOMElement **ppChildElement = NULL,
  44. IXMLDOMNode **ppChildNode = NULL
  45. );
  46. // @cmember Add an element to a specific node with a text node
  47. void AddElement
  48. ( const LPCWSTR pwszTag,
  49. const LPCWSTR pwszText,
  50. IXMLDOMNode *pParentNode = NULL,
  51. IXMLDOMElement **ppChildElement = NULL,
  52. IXMLDOMNode **ppChildNode = NULL
  53. );
  54. // @cmember Add an element to a specific node with an attribute
  55. void AddElement
  56. ( const LPCWSTR pwszTag,
  57. const LPCWSTR pwszAttrName,
  58. const LPCWSTR pwszAttrValue,
  59. IXMLDOMNode *pParentNode = NULL,
  60. IXMLDOMElement **ppChildElement = NULL,
  61. IXMLDOMNode **ppChildNode = NULL
  62. );
  63. // @cmember Add an error code to the response object
  64. void AddErrorCode
  65. ( const LPCWSTR pwszErrorCode,
  66. IXMLDOMElement **ppChildElement = NULL,
  67. IXMLDOMNode **ppChildNode = NULL
  68. );
  69. // @access Protected Members
  70. protected:
  71. // @cmember The XML document
  72. CComPtr<IXMLDOMDocument> m_pXMLDoc;
  73. // @cmember The root node (interface)
  74. CComQIPtr<IXMLDOMNode> m_pXMLNode_Root;
  75. // @cmember The first-level node (interface)
  76. CComQIPtr<IXMLDOMNode> m_pXMLNode_L1;
  77. // @cmember The first-level element (interface)
  78. CComPtr<IXMLDOMElement> m_pXMLElement_L1;
  79. // @cmember The root tag of this response object
  80. CStringW m_cwszResponseTag;
  81. // @cmember The type of this response object
  82. eResponseType m_rtType;
  83. };