xmlregexp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * Summary: regular expressions handling
  3. * Description: basic API for libxml regular expressions handling used
  4. * for XML Schemas and validation.
  5. *
  6. * Copy: See Copyright for the status of this software.
  7. *
  8. * Author: Daniel Veillard
  9. */
  10. #ifndef __XML_REGEXP_H__
  11. #define __XML_REGEXP_H__
  12. #include <libxml/xmlversion.h>
  13. #ifdef LIBXML_REGEXP_ENABLED
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /**
  18. * xmlRegexpPtr:
  19. *
  20. * A libxml regular expression, they can actually be far more complex
  21. * thank the POSIX regex expressions.
  22. */
  23. typedef struct _xmlRegexp xmlRegexp;
  24. typedef xmlRegexp *xmlRegexpPtr;
  25. /**
  26. * xmlRegExecCtxtPtr:
  27. *
  28. * A libxml progressive regular expression evaluation context
  29. */
  30. typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
  31. typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
  32. #ifdef __cplusplus
  33. }
  34. #endif
  35. #include <libxml/tree.h>
  36. #include <libxml/dict.h>
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /*
  41. * The POSIX like API
  42. */
  43. XMLPUBFUN xmlRegexpPtr XMLCALL
  44. xmlRegexpCompile (const xmlChar *regexp);
  45. XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp);
  46. XMLPUBFUN int XMLCALL
  47. xmlRegexpExec (xmlRegexpPtr comp,
  48. const xmlChar *value);
  49. XMLPUBFUN void XMLCALL
  50. xmlRegexpPrint (FILE *output,
  51. xmlRegexpPtr regexp);
  52. XMLPUBFUN int XMLCALL
  53. xmlRegexpIsDeterminist(xmlRegexpPtr comp);
  54. /*
  55. * Callback function when doing a transition in the automata
  56. */
  57. typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
  58. const xmlChar *token,
  59. void *transdata,
  60. void *inputdata);
  61. /*
  62. * The progressive API
  63. */
  64. XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
  65. xmlRegNewExecCtxt (xmlRegexpPtr comp,
  66. xmlRegExecCallbacks callback,
  67. void *data);
  68. XMLPUBFUN void XMLCALL
  69. xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);
  70. XMLPUBFUN int XMLCALL
  71. xmlRegExecPushString(xmlRegExecCtxtPtr exec,
  72. const xmlChar *value,
  73. void *data);
  74. XMLPUBFUN int XMLCALL
  75. xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
  76. const xmlChar *value,
  77. const xmlChar *value2,
  78. void *data);
  79. XMLPUBFUN int XMLCALL
  80. xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
  81. int *nbval,
  82. int *nbneg,
  83. xmlChar **values,
  84. int *terminal);
  85. XMLPUBFUN int XMLCALL
  86. xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
  87. const xmlChar **string,
  88. int *nbval,
  89. int *nbneg,
  90. xmlChar **values,
  91. int *terminal);
  92. #ifdef LIBXML_EXPR_ENABLED
  93. /*
  94. * Formal regular expression handling
  95. * Its goal is to do some formal work on content models
  96. */
  97. /* expressions are used within a context */
  98. typedef struct _xmlExpCtxt xmlExpCtxt;
  99. typedef xmlExpCtxt *xmlExpCtxtPtr;
  100. XMLPUBFUN void XMLCALL
  101. xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);
  102. XMLPUBFUN xmlExpCtxtPtr XMLCALL
  103. xmlExpNewCtxt (int maxNodes,
  104. xmlDictPtr dict);
  105. XMLPUBFUN int XMLCALL
  106. xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
  107. XMLPUBFUN int XMLCALL
  108. xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
  109. /* Expressions are trees but the tree is opaque */
  110. typedef struct _xmlExpNode xmlExpNode;
  111. typedef xmlExpNode *xmlExpNodePtr;
  112. typedef enum {
  113. XML_EXP_EMPTY = 0,
  114. XML_EXP_FORBID = 1,
  115. XML_EXP_ATOM = 2,
  116. XML_EXP_SEQ = 3,
  117. XML_EXP_OR = 4,
  118. XML_EXP_COUNT = 5
  119. } xmlExpNodeType;
  120. /*
  121. * 2 core expressions shared by all for the empty language set
  122. * and for the set with just the empty token
  123. */
  124. XMLPUBVAR xmlExpNodePtr forbiddenExp;
  125. XMLPUBVAR xmlExpNodePtr emptyExp;
  126. /*
  127. * Expressions are reference counted internally
  128. */
  129. XMLPUBFUN void XMLCALL
  130. xmlExpFree (xmlExpCtxtPtr ctxt,
  131. xmlExpNodePtr expr);
  132. XMLPUBFUN void XMLCALL
  133. xmlExpRef (xmlExpNodePtr expr);
  134. /*
  135. * constructors can be either manual or from a string
  136. */
  137. XMLPUBFUN xmlExpNodePtr XMLCALL
  138. xmlExpParse (xmlExpCtxtPtr ctxt,
  139. const char *expr);
  140. XMLPUBFUN xmlExpNodePtr XMLCALL
  141. xmlExpNewAtom (xmlExpCtxtPtr ctxt,
  142. const xmlChar *name,
  143. int len);
  144. XMLPUBFUN xmlExpNodePtr XMLCALL
  145. xmlExpNewOr (xmlExpCtxtPtr ctxt,
  146. xmlExpNodePtr left,
  147. xmlExpNodePtr right);
  148. XMLPUBFUN xmlExpNodePtr XMLCALL
  149. xmlExpNewSeq (xmlExpCtxtPtr ctxt,
  150. xmlExpNodePtr left,
  151. xmlExpNodePtr right);
  152. XMLPUBFUN xmlExpNodePtr XMLCALL
  153. xmlExpNewRange (xmlExpCtxtPtr ctxt,
  154. xmlExpNodePtr subset,
  155. int min,
  156. int max);
  157. /*
  158. * The really interesting APIs
  159. */
  160. XMLPUBFUN int XMLCALL
  161. xmlExpIsNillable(xmlExpNodePtr expr);
  162. XMLPUBFUN int XMLCALL
  163. xmlExpMaxToken (xmlExpNodePtr expr);
  164. XMLPUBFUN int XMLCALL
  165. xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
  166. xmlExpNodePtr expr,
  167. const xmlChar**langList,
  168. int len);
  169. XMLPUBFUN int XMLCALL
  170. xmlExpGetStart (xmlExpCtxtPtr ctxt,
  171. xmlExpNodePtr expr,
  172. const xmlChar**tokList,
  173. int len);
  174. XMLPUBFUN xmlExpNodePtr XMLCALL
  175. xmlExpStringDerive(xmlExpCtxtPtr ctxt,
  176. xmlExpNodePtr expr,
  177. const xmlChar *str,
  178. int len);
  179. XMLPUBFUN xmlExpNodePtr XMLCALL
  180. xmlExpExpDerive (xmlExpCtxtPtr ctxt,
  181. xmlExpNodePtr expr,
  182. xmlExpNodePtr sub);
  183. XMLPUBFUN int XMLCALL
  184. xmlExpSubsume (xmlExpCtxtPtr ctxt,
  185. xmlExpNodePtr expr,
  186. xmlExpNodePtr sub);
  187. XMLPUBFUN void XMLCALL
  188. xmlExpDump (xmlBufferPtr buf,
  189. xmlExpNodePtr expr);
  190. #endif /* LIBXML_EXPR_ENABLED */
  191. #ifdef __cplusplus
  192. }
  193. #endif
  194. #endif /* LIBXML_REGEXP_ENABLED */
  195. #endif /*__XML_REGEXP_H__ */