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.

203 lines
4.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // fusion\xmlparser\xmlhelper.hxx
  4. //
  5. /////////////////////////////////////////////////////////////////////////////////
  6. #ifndef _FUSION_XMLPARSER__XMLHELPER_H_INCLUDE_
  7. #define _FUSION_XMLPARSER__XMLHELPER_H_INCLUDE_
  8. #pragma once
  9. #include <stdio.h>
  10. #include <wchar.h>
  11. #include <string.h>
  12. #include <windows.h>
  13. #include "core.hxx"
  14. #define checknull(a) if (!(a)) { hr = E_OUTOFMEMORY; goto error; }
  15. #define breakhr(a) hr = (a); if (hr != S_OK) break;
  16. #define checkhr2(a) hr = a; if (hr != S_OK) return hr;
  17. // resolve built-in entities.
  18. WCHAR BuiltinEntity(const WCHAR* text, ULONG len);
  19. HRESULT HexToUnicode(const WCHAR* text, ULONG len, WCHAR& ch);
  20. HRESULT DecimalToUnicode(const WCHAR* text, ULONG len, WCHAR& ch);
  21. // --------------------------------------------------------------------
  22. // A little helper class for setting a boolean flag and clearing it
  23. // on destruction.
  24. class BoolLock
  25. {
  26. bool* _pFlag;
  27. public:
  28. BoolLock(bool* pFlag)
  29. {
  30. _pFlag = pFlag;
  31. *pFlag = true;
  32. }
  33. ~BoolLock()
  34. {
  35. *_pFlag = false;
  36. }
  37. };
  38. //helper Functions
  39. int DecimalToBuffer(long, char*, int, long);
  40. int StrToBuffer(const WCHAR*, WCHAR*, int);
  41. bool StringEquals(const WCHAR*, const WCHAR*, long, bool);
  42. //////////////////////////////////////////////////////////
  43. enum
  44. {
  45. FWHITESPACE = 1,
  46. FDIGIT = 2,
  47. FLETTER = 4,
  48. FMISCNAME = 8,
  49. FSTARTNAME = 16,
  50. FCHARDATA = 32
  51. };
  52. static const short TABLE_SIZE = 128;
  53. static int g_anCharType[TABLE_SIZE] = {
  54. 0,
  55. 0,
  56. 0,
  57. 0,
  58. 0,
  59. 0,
  60. 0,
  61. 0,
  62. 0,
  63. 0 | FWHITESPACE | FCHARDATA,
  64. 0 | FWHITESPACE | FCHARDATA,
  65. 0,
  66. 0,
  67. 0 | FWHITESPACE | FCHARDATA,
  68. 0,
  69. 0,
  70. 0,
  71. 0,
  72. 0,
  73. 0,
  74. 0,
  75. 0,
  76. 0,
  77. 0,
  78. 0,
  79. 0,
  80. 0,
  81. 0,
  82. 0,
  83. 0,
  84. 0,
  85. 0,
  86. 0 | FWHITESPACE | FCHARDATA,
  87. 0 | FCHARDATA,
  88. 0 | FCHARDATA,
  89. 0 | FCHARDATA,
  90. 0 | FCHARDATA,
  91. 0 | FCHARDATA,
  92. 0 | FCHARDATA,
  93. 0 | FCHARDATA,
  94. 0 | FCHARDATA,
  95. 0 | FCHARDATA,
  96. 0 | FCHARDATA,
  97. 0 | FCHARDATA,
  98. 0 | FCHARDATA,
  99. 0 | FMISCNAME | FCHARDATA,
  100. 0 | FMISCNAME | FCHARDATA,
  101. 0 | FCHARDATA,
  102. 0 | FDIGIT | FCHARDATA,
  103. 0 | FDIGIT | FCHARDATA,
  104. 0 | FDIGIT | FCHARDATA,
  105. 0 | FDIGIT | FCHARDATA,
  106. 0 | FDIGIT | FCHARDATA,
  107. 0 | FDIGIT | FCHARDATA,
  108. 0 | FDIGIT | FCHARDATA,
  109. 0 | FDIGIT | FCHARDATA,
  110. 0 | FDIGIT | FCHARDATA,
  111. 0 | FDIGIT | FCHARDATA,
  112. 0 | FSTARTNAME | FCHARDATA,
  113. 0 | FCHARDATA,
  114. 0 | FCHARDATA,
  115. 0 | FCHARDATA,
  116. 0 | FCHARDATA,
  117. 0 | FCHARDATA,
  118. 0 | FCHARDATA,
  119. 0 | FLETTER | FCHARDATA,
  120. 0 | FLETTER | FCHARDATA,
  121. 0 | FLETTER | FCHARDATA,
  122. 0 | FLETTER | FCHARDATA,
  123. 0 | FLETTER | FCHARDATA,
  124. 0 | FLETTER | FCHARDATA,
  125. 0 | FLETTER | FCHARDATA,
  126. 0 | FLETTER | FCHARDATA,
  127. 0 | FLETTER | FCHARDATA,
  128. 0 | FLETTER | FCHARDATA,
  129. 0 | FLETTER | FCHARDATA,
  130. 0 | FLETTER | FCHARDATA,
  131. 0 | FLETTER | FCHARDATA,
  132. 0 | FLETTER | FCHARDATA,
  133. 0 | FLETTER | FCHARDATA,
  134. 0 | FLETTER | FCHARDATA,
  135. 0 | FLETTER | FCHARDATA,
  136. 0 | FLETTER | FCHARDATA,
  137. 0 | FLETTER | FCHARDATA,
  138. 0 | FLETTER | FCHARDATA,
  139. 0 | FLETTER | FCHARDATA,
  140. 0 | FLETTER | FCHARDATA,
  141. 0 | FLETTER | FCHARDATA,
  142. 0 | FLETTER | FCHARDATA,
  143. 0 | FLETTER | FCHARDATA,
  144. 0 | FLETTER | FCHARDATA,
  145. 0 | FCHARDATA,
  146. 0 | FCHARDATA,
  147. 0 | FCHARDATA,
  148. 0 | FCHARDATA,
  149. 0 | FMISCNAME | FSTARTNAME | FCHARDATA,
  150. 0 | FCHARDATA,
  151. 0 | FLETTER | FCHARDATA,
  152. 0 | FLETTER | FCHARDATA,
  153. 0 | FLETTER | FCHARDATA,
  154. 0 | FLETTER | FCHARDATA,
  155. 0 | FLETTER | FCHARDATA,
  156. 0 | FLETTER | FCHARDATA,
  157. 0 | FLETTER | FCHARDATA,
  158. 0 | FLETTER | FCHARDATA,
  159. 0 | FLETTER | FCHARDATA,
  160. 0 | FLETTER | FCHARDATA,
  161. 0 | FLETTER | FCHARDATA,
  162. 0 | FLETTER | FCHARDATA,
  163. 0 | FLETTER | FCHARDATA,
  164. 0 | FLETTER | FCHARDATA,
  165. 0 | FLETTER | FCHARDATA,
  166. 0 | FLETTER | FCHARDATA,
  167. 0 | FLETTER | FCHARDATA,
  168. 0 | FLETTER | FCHARDATA,
  169. 0 | FLETTER | FCHARDATA,
  170. 0 | FLETTER | FCHARDATA,
  171. 0 | FLETTER | FCHARDATA,
  172. 0 | FLETTER | FCHARDATA,
  173. 0 | FLETTER | FCHARDATA,
  174. 0 | FLETTER | FCHARDATA,
  175. 0 | FLETTER | FCHARDATA,
  176. 0 | FLETTER | FCHARDATA,
  177. 0 | FCHARDATA,
  178. 0 | FCHARDATA,
  179. 0 | FCHARDATA,
  180. 0 | FCHARDATA,
  181. 0 | FCHARDATA,
  182. };
  183. bool isDigit(WCHAR ch);
  184. bool isHexDigit(WCHAR ch);
  185. bool isLetter(WCHAR ch);
  186. int isStartNameChar(WCHAR ch);
  187. bool isCombiningChar(WCHAR ch);
  188. bool isExtender(WCHAR ch);
  189. bool isAlphaNumeric(WCHAR ch);
  190. int isNameChar(WCHAR ch);
  191. int isCharData(WCHAR ch);
  192. #endif