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.

199 lines
6.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: ncxml.h
  7. //
  8. // Contents: helper functions for doing remarkably simple things
  9. // with the XML DOM.
  10. //
  11. //----------------------------------------------------------------------------
  12. #ifndef __NCXML_H_
  13. #define __NCXML_H_
  14. /*
  15. * Enum SST_DATA_TYPE
  16. *
  17. * Possible types of state variables
  18. */
  19. enum SST_DATA_TYPE // Type returned by msxml
  20. { // ----------------------
  21. SDT_STRING = 0, // VT_BSTR
  22. SDT_NUMBER, // VT_BSTR
  23. SDT_INT, // VT_I4
  24. SDT_FIXED_14_4, // VT_CY
  25. SDT_BOOLEAN, // VT_BOOL
  26. SDT_DATETIME_ISO8601, // VT_DATE
  27. SDT_DATETIME_ISO8601TZ, // VT_DATE
  28. SDT_DATE_ISO8601, // VT_DATE
  29. SDT_TIME_ISO8601, // VT_DATE
  30. SDT_TIME_ISO8601TZ, // VT_DATE
  31. SDT_I1, // VT_I1
  32. SDT_I2, // VT_I2
  33. SDT_I4, // VT_I4
  34. SDT_UI1, // VT_UI1
  35. SDT_UI2, // VT_UI2
  36. SDT_UI4, // VT_UI4
  37. SDT_R4, // VT_FLOAT
  38. SDT_R8, // VT_DOUBLE
  39. SDT_FLOAT, // VT_DOUBLE
  40. SDT_UUID, // VT_BSTR
  41. SDT_BIN_BASE64, // VT_ARRAY
  42. SDT_BIN_HEX, // VT_ARRAY
  43. SDT_CHAR, // VT_UI2 (a wchar)
  44. SDT_URI, // VT_BSTR
  45. //
  46. // note(cmr): ADD NEW VALUES IMMEDIATELY BEFORE THIS COMMENT
  47. //
  48. SDT_INVALID
  49. };
  50. // Reading values from elements
  51. HRESULT HrGetTypedValueFromElement(IXMLDOMNode * pxdn,
  52. CONST LPCWSTR pszDataType,
  53. VARIANT * pvarOut);
  54. HRESULT HrGetTypedValueFromChildElement(IXMLDOMNode * pxdn,
  55. CONST LPCWSTR * arypszTokens,
  56. CONST ULONG cTokens,
  57. CONST LPCWSTR pszDataType,
  58. VARIANT * pvarOut);
  59. HRESULT HrGetTextValueFromElement(IXMLDOMNode * pxdn,
  60. BSTR * pbstrOut);
  61. HRESULT HrGetTextValueFromChildElement(IXMLDOMNode * pxde,
  62. const LPCWSTR * arypszTokens,
  63. const ULONG cTokens,
  64. BSTR * pbstrOut);
  65. // Navigating the tree
  66. BOOL FIsThisTheNodeName(IXMLDOMNode * pxdn,
  67. LPCWSTR pszNodeName);
  68. BOOL
  69. FIsThisTheNodeNameWithNamespace(IXMLDOMNode * pxdn,
  70. LPCWSTR pszNodeName,
  71. LPCWSTR pszNamespaceURI);
  72. BOOL
  73. FIsThisTheNodeTextValue(
  74. IN IXMLDOMNode * pxdn,
  75. IN LPCWSTR cszTextValue);
  76. BOOL
  77. FAreNodeValuesEqual(
  78. IN IXMLDOMNode * pxdn1,
  79. IN IXMLDOMNode * pxdn2);
  80. HRESULT
  81. HrAreThereDuplicatesInChildNodeTextValues(
  82. IN IXMLDOMNode * pxdn,
  83. IN LPCWSTR cszXSLPattern,
  84. IN BOOL fCaseSensitive,
  85. OUT BOOL * pfDuplicatesExist);
  86. HRESULT HrGetFirstChildElement(IXMLDOMNode * pxdn,
  87. LPCWSTR pszNodeName,
  88. IXMLDOMNode ** ppxdn);
  89. HRESULT HrGetNextChildElement(IXMLDOMNode * pxdnLastChild,
  90. LPCWSTR pszNodeName,
  91. IXMLDOMNode ** ppxde);
  92. HRESULT HrGetNestedChildElement(IXMLDOMNode * pxdeRoot,
  93. const LPCWSTR * arypszTokens,
  94. const ULONG cTokens,
  95. IXMLDOMNode ** ppxde);
  96. // Parsing nodes
  97. struct DevicePropertiesParsingStruct
  98. {
  99. BOOL m_fOptional;
  100. BOOL m_fIsUrl;
  101. BOOL m_fValidateUrl;
  102. LPCWSTR m_pszTagName;
  103. };
  104. HRESULT HrAreElementTagsValid(IXMLDOMNode *pxdnRoot,
  105. const ULONG cElems,
  106. const DevicePropertiesParsingStruct dppsInfo []);
  107. HRESULT HrIsElementPresentOnce(IXMLDOMNode * pxdnRoot,
  108. LPCWSTR pszNodeName );
  109. HRESULT HrCheckForDuplicateElement(IXMLDOMNode * pxdnRoot,
  110. LPCWSTR pszNodeName );
  111. HRESULT HrReadElementWithParseData (IXMLDOMNode * pxdn,
  112. const ULONG cElems,
  113. const DevicePropertiesParsingStruct dppsInfo [],
  114. LPCWSTR pszBaseUrl,
  115. LPWSTR arypszReadValues []);
  116. BOOL fAreReadValuesComplete (const ULONG cElems,
  117. const DevicePropertiesParsingStruct dppsInfo [],
  118. const LPCWSTR arypszReadValues []);
  119. HRESULT
  120. HrGetTextValueFromAttribute(
  121. IN IXMLDOMNode * pxdn,
  122. IN LPCWSTR szAttrName,
  123. OUT BSTR * pbstrAttrValue);
  124. // Creating nodes
  125. HRESULT HrSetTextAttribute(IXMLDOMElement * pElement,
  126. LPCWSTR pcwszAttrName,
  127. LPCWSTR pcwszValue);
  128. HRESULT HrCreateElementWithType(IN IXMLDOMDocument * pDoc,
  129. IN LPCWSTR pcwszElementName,
  130. IN LPCWSTR pszDataType,
  131. IN VARIANT varData,
  132. OUT IXMLDOMElement ** ppElement);
  133. HRESULT HrCreateElementWithTextValue(IN IXMLDOMDocument * pDoc,
  134. IN LPCWSTR pcwszElementName,
  135. IN LPCWSTR pcwszTextValue,
  136. OUT IXMLDOMElement ** ppElement);
  137. HRESULT HrCreateElement(
  138. IN IXMLDOMDocument * pxdd,
  139. IN LPCWSTR pcwszElementName,
  140. IN LPCWSTR pcwszNamespaceURI,
  141. OUT IXMLDOMNode ** ppxdnNewElt);
  142. HRESULT HrAppendProcessingInstruction(
  143. IN IXMLDOMDocument * pxdd,
  144. IN LPCWSTR pcwszName,
  145. IN LPCWSTR pcwszValue);
  146. extern
  147. LPCWSTR
  148. GetStringFromType(CONST SST_DATA_TYPE sdt);
  149. extern
  150. SST_DATA_TYPE
  151. GetTypeFromString(LPCWSTR pszTypeString);
  152. extern
  153. VARTYPE
  154. GetVarTypeFromString(LPCWSTR pszTypeString);
  155. #endif // __NCXML_H_