codekingpro/portable-devtools
115k
1/*2 * Summary: regular expressions handling3 * Description: basic API for libxml regular expressions handling used4 * for XML Schemas and validation.5 *6 * Copy: See Copyright for the status of this software.7 *8 * Author: Daniel Veillard9 */10 11#ifndef __XML_REGEXP_H__12#define __XML_REGEXP_H__13 14#include <libxml/xmlversion.h>15 16#ifdef LIBXML_REGEXP_ENABLED17 18#ifdef __cplusplus19extern "C" {20#endif21 22/**23 * xmlRegexpPtr:24 *25 * A libxml regular expression, they can actually be far more complex26 * thank the POSIX regex expressions.27 */28typedef struct _xmlRegexp xmlRegexp;29typedef xmlRegexp *xmlRegexpPtr;30 31/**32 * xmlRegExecCtxtPtr:33 *34 * A libxml progressive regular expression evaluation context35 */36typedef struct _xmlRegExecCtxt xmlRegExecCtxt;37typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;38 39#ifdef __cplusplus40}41#endif42#include <libxml/tree.h>43#include <libxml/dict.h>44#ifdef __cplusplus45extern "C" {46#endif47 48/*49 * The POSIX like API50 */51XMLPUBFUN xmlRegexpPtr52 xmlRegexpCompile (const xmlChar *regexp);53XMLPUBFUN void xmlRegFreeRegexp(xmlRegexpPtr regexp);54XMLPUBFUN int55 xmlRegexpExec (xmlRegexpPtr comp,56 const xmlChar *value);57XMLPUBFUN void58 xmlRegexpPrint (FILE *output,59 xmlRegexpPtr regexp);60XMLPUBFUN int61 xmlRegexpIsDeterminist(xmlRegexpPtr comp);62 63/**64 * xmlRegExecCallbacks:65 * @exec: the regular expression context66 * @token: the current token string67 * @transdata: transition data68 * @inputdata: input data69 *70 * Callback function when doing a transition in the automata71 */72typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,73 const xmlChar *token,74 void *transdata,75 void *inputdata);76 77/*78 * The progressive API79 */80XMLPUBFUN xmlRegExecCtxtPtr81 xmlRegNewExecCtxt (xmlRegexpPtr comp,82 xmlRegExecCallbacks callback,83 void *data);84XMLPUBFUN void85 xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);86XMLPUBFUN int87 xmlRegExecPushString(xmlRegExecCtxtPtr exec,88 const xmlChar *value,89 void *data);90XMLPUBFUN int91 xmlRegExecPushString2(xmlRegExecCtxtPtr exec,92 const xmlChar *value,93 const xmlChar *value2,94 void *data);95 96XMLPUBFUN int97 xmlRegExecNextValues(xmlRegExecCtxtPtr exec,98 int *nbval,99 int *nbneg,100 xmlChar **values,101 int *terminal);102XMLPUBFUN int103 xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,104 const xmlChar **string,105 int *nbval,106 int *nbneg,107 xmlChar **values,108 int *terminal);109#ifdef LIBXML_EXPR_ENABLED110/*111 * Formal regular expression handling112 * Its goal is to do some formal work on content models113 */114 115/* expressions are used within a context */116typedef struct _xmlExpCtxt xmlExpCtxt;117typedef xmlExpCtxt *xmlExpCtxtPtr;118 119XMLPUBFUN void120 xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);121XMLPUBFUN xmlExpCtxtPtr122 xmlExpNewCtxt (int maxNodes,123 xmlDictPtr dict);124 125XMLPUBFUN int126 xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);127XMLPUBFUN int128 xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);129 130/* Expressions are trees but the tree is opaque */131typedef struct _xmlExpNode xmlExpNode;132typedef xmlExpNode *xmlExpNodePtr;133 134typedef enum {135 XML_EXP_EMPTY = 0,136 XML_EXP_FORBID = 1,137 XML_EXP_ATOM = 2,138 XML_EXP_SEQ = 3,139 XML_EXP_OR = 4,140 XML_EXP_COUNT = 5141} xmlExpNodeType;142 143/*144 * 2 core expressions shared by all for the empty language set145 * and for the set with just the empty token146 */147XMLPUBVAR xmlExpNodePtr forbiddenExp;148XMLPUBVAR xmlExpNodePtr emptyExp;149 150/*151 * Expressions are reference counted internally152 */153XMLPUBFUN void154 xmlExpFree (xmlExpCtxtPtr ctxt,155 xmlExpNodePtr expr);156XMLPUBFUN void157 xmlExpRef (xmlExpNodePtr expr);158 159/*160 * constructors can be either manual or from a string161 */162XMLPUBFUN xmlExpNodePtr163 xmlExpParse (xmlExpCtxtPtr ctxt,164 const char *expr);165XMLPUBFUN xmlExpNodePtr166 xmlExpNewAtom (xmlExpCtxtPtr ctxt,167 const xmlChar *name,168 int len);169XMLPUBFUN xmlExpNodePtr170 xmlExpNewOr (xmlExpCtxtPtr ctxt,171 xmlExpNodePtr left,172 xmlExpNodePtr right);173XMLPUBFUN xmlExpNodePtr174 xmlExpNewSeq (xmlExpCtxtPtr ctxt,175 xmlExpNodePtr left,176 xmlExpNodePtr right);177XMLPUBFUN xmlExpNodePtr178 xmlExpNewRange (xmlExpCtxtPtr ctxt,179 xmlExpNodePtr subset,180 int min,181 int max);182/*183 * The really interesting APIs184 */185XMLPUBFUN int186 xmlExpIsNillable(xmlExpNodePtr expr);187XMLPUBFUN int188 xmlExpMaxToken (xmlExpNodePtr expr);189XMLPUBFUN int190 xmlExpGetLanguage(xmlExpCtxtPtr ctxt,191 xmlExpNodePtr expr,192 const xmlChar**langList,193 int len);194XMLPUBFUN int195 xmlExpGetStart (xmlExpCtxtPtr ctxt,196 xmlExpNodePtr expr,197 const xmlChar**tokList,198 int len);199XMLPUBFUN xmlExpNodePtr200 xmlExpStringDerive(xmlExpCtxtPtr ctxt,201 xmlExpNodePtr expr,202 const xmlChar *str,203 int len);204XMLPUBFUN xmlExpNodePtr205 xmlExpExpDerive (xmlExpCtxtPtr ctxt,206 xmlExpNodePtr expr,207 xmlExpNodePtr sub);208XMLPUBFUN int209 xmlExpSubsume (xmlExpCtxtPtr ctxt,210 xmlExpNodePtr expr,211 xmlExpNodePtr sub);212XMLPUBFUN void213 xmlExpDump (xmlBufferPtr buf,214 xmlExpNodePtr expr);215#endif /* LIBXML_EXPR_ENABLED */216#ifdef __cplusplus217}218#endif219 220#endif /* LIBXML_REGEXP_ENABLED */221 222#endif /*__XML_REGEXP_H__ */223 