Leaked source code of windows server 2003
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.

202 lines
4.7 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 breakhr(a) hr = (a); if (FAILED(hr)) break;
  15. #define checkhr2(a) hr = a; if (FAILED(hr)) return hr;
  16. // resolve built-in entities.
  17. WCHAR BuiltinEntity(const WCHAR* text, ULONG len);
  18. HRESULT HexToUnicode(const WCHAR* text, ULONG len, WCHAR& ch);
  19. HRESULT DecimalToUnicode(const WCHAR* text, ULONG len, WCHAR& ch);
  20. // --------------------------------------------------------------------
  21. // A little helper class for setting a boolean flag and clearing it
  22. // on destruction.
  23. class BoolLock
  24. {
  25. bool* _pFlag;
  26. public:
  27. BoolLock(bool* pFlag)
  28. {
  29. _pFlag = pFlag;
  30. *pFlag = true;
  31. }
  32. ~BoolLock()
  33. {
  34. *_pFlag = false;
  35. }
  36. };
  37. //helper Functions
  38. int DecimalToBuffer(long, char*, int, long);
  39. int StrToBuffer(const WCHAR*, WCHAR*, int);
  40. bool StringEquals(const WCHAR*, const WCHAR*, long, bool);
  41. //////////////////////////////////////////////////////////
  42. enum
  43. {
  44. FWHITESPACE = 1,
  45. FDIGIT = 2,
  46. FLETTER = 4,
  47. FMISCNAME = 8,
  48. FSTARTNAME = 16,
  49. FCHARDATA = 32
  50. };
  51. static const short TABLE_SIZE = 128;
  52. static int g_anCharType[TABLE_SIZE] = {
  53. 0,
  54. 0,
  55. 0,
  56. 0,
  57. 0,
  58. 0,
  59. 0,
  60. 0,
  61. 0,
  62. 0 | FWHITESPACE | FCHARDATA,
  63. 0 | FWHITESPACE | FCHARDATA,
  64. 0,
  65. 0,
  66. 0 | FWHITESPACE | FCHARDATA,
  67. 0,
  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 | FWHITESPACE | FCHARDATA,
  86. 0 | 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 | FMISCNAME | FCHARDATA,
  99. 0 | FMISCNAME | FCHARDATA,
  100. 0 | FCHARDATA,
  101. 0 | FDIGIT | 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 | FSTARTNAME | FCHARDATA,
  112. 0 | FCHARDATA,
  113. 0 | FCHARDATA,
  114. 0 | FCHARDATA,
  115. 0 | FCHARDATA,
  116. 0 | FCHARDATA,
  117. 0 | FCHARDATA,
  118. 0 | FLETTER | 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 | FCHARDATA,
  145. 0 | FCHARDATA,
  146. 0 | FCHARDATA,
  147. 0 | FCHARDATA,
  148. 0 | FMISCNAME | FSTARTNAME | FCHARDATA,
  149. 0 | FCHARDATA,
  150. 0 | FLETTER | 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 | FCHARDATA,
  177. 0 | FCHARDATA,
  178. 0 | FCHARDATA,
  179. 0 | FCHARDATA,
  180. 0 | FCHARDATA,
  181. };
  182. bool isDigit(WCHAR ch);
  183. bool isHexDigit(WCHAR ch);
  184. bool isLetter(WCHAR ch);
  185. int isStartNameChar(WCHAR ch);
  186. bool isCombiningChar(WCHAR ch);
  187. bool isExtender(WCHAR ch);
  188. bool isAlphaNumeric(WCHAR ch);
  189. int isNameChar(WCHAR ch);
  190. int isCharData(WCHAR ch);
  191. #endif