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.

108 lines
3.6 KiB

  1. #ifndef __XMLUTIL_
  2. #define __XMLUTIL_
  3. inline BOOL CompareNoCase(LPCWSTR lpsz1, LPCWSTR lpsz2)
  4. {
  5. if ((lpsz1 == NULL) && (lpsz2 == NULL))
  6. return TRUE;
  7. if ((lpsz1 == NULL) || (lpsz2 == NULL))
  8. return FALSE;
  9. return (wcscmp(lpsz1, lpsz2) == 0);
  10. }
  11. inline BOOL CompareXMLTags(LPCWSTR lpsz1, LPCWSTR lpsz2)
  12. {
  13. return CompareNoCase(lpsz1, lpsz2);
  14. }
  15. // helpers for encoding and decoding of C++
  16. // data structures to and from XML PCDATA fields
  17. HRESULT EncodeBlobToBSTR(BYTE* pBlob, ULONG nBytes, BSTR* pBstr);
  18. HRESULT DecodeBSTRtoBlob(BSTR bstr, BYTE** ppByte, ULONG* pnBytes);
  19. HRESULT DecodeBSTRtoStruct(BSTR bstr, BYTE* pByte, ULONG nBytes);
  20. HRESULT EncodeBoolToBSTR(BOOL b, BSTR* pBstr);
  21. HRESULT DecodeBSTRtoBool(BSTR bstr, BOOL* pb);
  22. //HRESULT EncodeIntToBSTR(int n, BSTR* pBstr);
  23. //HRESULT DecodeIntToBool(BSTR bstr, int* pN);
  24. BOOL XMLIsNodeName(IXMLDOMNode* pXDN, LPCWSTR lpszName);
  25. // helper functions to read XML nodes and convert to C++ data
  26. HRESULT XML_GetNodeText(IXMLDOMNode* pXDN, BSTR* pBstr);
  27. HRESULT XML_GetNodeStruct(IXMLDOMNode* pXDN, BYTE* pByte, ULONG nBytes);
  28. HRESULT XML_GetNodeBlob(IXMLDOMNode* pXDN, BYTE** ppByte, ULONG* pnBytes);
  29. HRESULT XML_GetNodeBOOL(IXMLDOMNode* pXDN, BOOL* pb);
  30. HRESULT XML_GetNodeDWORD(IXMLDOMNode* pXDN, DWORD* pdw);
  31. HRESULT XML_FindSubtreeNode(IXMLDOMNode* pXMLCurrentRootNode,
  32. LPCWSTR lpszNodeTag,
  33. IXMLDOMNode** ppXMLNode);
  34. // debugging helper function
  35. void XML_PrintTreeRaw(IXMLDOMNode* pXDN, int nLevel);
  36. void PrintIdentation(int iLevel);
  37. ///////////////////////////////////////////////////////////////////
  38. HRESULT XML_CreateDOMNode(IXMLDOMDocument* pDoc,
  39. DOMNodeType type, LPCWSTR lpszName,
  40. IXMLDOMNode** ppXMLDOMNode);
  41. HRESULT XML_AppendChildDOMNode(IXMLDOMNode* pXMLContainerNode,
  42. IXMLDOMNode* pXMLChildNode);
  43. // helper functions to write C++ data to XML nodes
  44. HRESULT XML_CreateTextDataNode(IXMLDOMDocument* pXMLDoc,
  45. LPCWSTR lpszNodeTag,
  46. LPCWSTR lpszNodeData,
  47. IXMLDOMNode** ppNode);
  48. HRESULT XML_CreateStructDataNode(IXMLDOMDocument* pXMLDoc,
  49. LPCWSTR lpszNodeTag,
  50. BYTE* pByte, ULONG nBytes,
  51. IXMLDOMNode** ppNode);
  52. HRESULT XML_CreateBOOLDataNode(IXMLDOMDocument* pXMLDoc,
  53. LPCWSTR lpszNodeTag,
  54. BOOL b,
  55. IXMLDOMNode** ppNode);
  56. HRESULT XML_CreateDWORDDataNode(IXMLDOMDocument* pXMLDoc,
  57. LPCWSTR lpszNodeTag,
  58. DWORD dwVal,
  59. IXMLDOMNode** ppNode);
  60. // helpers to append a node to an XML document
  61. HRESULT XML_AppendTextDataNode(IXMLDOMDocument* pXMLDoc,
  62. IXMLDOMNode* pXMLNode,
  63. LPCWSTR lpszNodeTag,
  64. LPCWSTR lpszNodeData);
  65. HRESULT XML_AppendBOOLDataNode(IXMLDOMDocument* pXMLDoc,
  66. IXMLDOMNode* pXMLNode,
  67. LPCWSTR lpszNodeTag,
  68. BOOL b);
  69. HRESULT XML_AppendStructDataNode(IXMLDOMDocument* pXMLDoc,
  70. IXMLDOMNode* pXMLNode,
  71. LPCWSTR lpszNodeTag,
  72. BYTE* pByte,
  73. ULONG nBytes);
  74. HRESULT XML_AppendDWORDDataNode(IXMLDOMDocument* pXMLDoc,
  75. IXMLDOMNode* pXMLNode,
  76. LPCWSTR lpszNodeTag,
  77. DWORD dwVal);
  78. #endif // __XMLUTIL_