Path: blob/master/libs/xml2/include/libxml/xmlregexp.h
4394 views
/*1* Summary: regular expressions handling2* Description: basic API for libxml regular expressions handling used3* for XML Schemas and validation.4*5* Copy: See Copyright for the status of this software.6*7* Author: Daniel Veillard8*/910#ifndef __XML_REGEXP_H__11#define __XML_REGEXP_H__1213#include <stdio.h>14#include <libxml/xmlversion.h>15#include <libxml/xmlstring.h>1617#ifdef LIBXML_REGEXP_ENABLED1819#ifdef __cplusplus20extern "C" {21#endif2223/**24* xmlRegexpPtr:25*26* A libxml regular expression, they can actually be far more complex27* thank the POSIX regex expressions.28*/29typedef struct _xmlRegexp xmlRegexp;30typedef xmlRegexp *xmlRegexpPtr;3132/**33* xmlRegExecCtxtPtr:34*35* A libxml progressive regular expression evaluation context36*/37typedef struct _xmlRegExecCtxt xmlRegExecCtxt;38typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;3940/*41* The POSIX like API42*/43XMLPUBFUN xmlRegexpPtr44xmlRegexpCompile (const xmlChar *regexp);45XMLPUBFUN void xmlRegFreeRegexp(xmlRegexpPtr regexp);46XMLPUBFUN int47xmlRegexpExec (xmlRegexpPtr comp,48const xmlChar *value);49XMLPUBFUN void50xmlRegexpPrint (FILE *output,51xmlRegexpPtr regexp);52XMLPUBFUN int53xmlRegexpIsDeterminist(xmlRegexpPtr comp);5455/**56* xmlRegExecCallbacks:57* @exec: the regular expression context58* @token: the current token string59* @transdata: transition data60* @inputdata: input data61*62* Callback function when doing a transition in the automata63*/64typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,65const xmlChar *token,66void *transdata,67void *inputdata);6869/*70* The progressive API71*/72XMLPUBFUN xmlRegExecCtxtPtr73xmlRegNewExecCtxt (xmlRegexpPtr comp,74xmlRegExecCallbacks callback,75void *data);76XMLPUBFUN void77xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);78XMLPUBFUN int79xmlRegExecPushString(xmlRegExecCtxtPtr exec,80const xmlChar *value,81void *data);82XMLPUBFUN int83xmlRegExecPushString2(xmlRegExecCtxtPtr exec,84const xmlChar *value,85const xmlChar *value2,86void *data);8788XMLPUBFUN int89xmlRegExecNextValues(xmlRegExecCtxtPtr exec,90int *nbval,91int *nbneg,92xmlChar **values,93int *terminal);94XMLPUBFUN int95xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,96const xmlChar **string,97int *nbval,98int *nbneg,99xmlChar **values,100int *terminal);101#ifdef LIBXML_EXPR_ENABLED102/*103* Formal regular expression handling104* Its goal is to do some formal work on content models105*/106107/* expressions are used within a context */108typedef struct _xmlExpCtxt xmlExpCtxt;109typedef xmlExpCtxt *xmlExpCtxtPtr;110111XMLPUBFUN void112xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);113XMLPUBFUN xmlExpCtxtPtr114xmlExpNewCtxt (int maxNodes,115xmlDictPtr dict);116117XMLPUBFUN int118xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);119XMLPUBFUN int120xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);121122/* Expressions are trees but the tree is opaque */123typedef struct _xmlExpNode xmlExpNode;124typedef xmlExpNode *xmlExpNodePtr;125126typedef enum {127XML_EXP_EMPTY = 0,128XML_EXP_FORBID = 1,129XML_EXP_ATOM = 2,130XML_EXP_SEQ = 3,131XML_EXP_OR = 4,132XML_EXP_COUNT = 5133} xmlExpNodeType;134135/*136* 2 core expressions shared by all for the empty language set137* and for the set with just the empty token138*/139XMLPUBVAR xmlExpNodePtr forbiddenExp;140XMLPUBVAR xmlExpNodePtr emptyExp;141142/*143* Expressions are reference counted internally144*/145XMLPUBFUN void146xmlExpFree (xmlExpCtxtPtr ctxt,147xmlExpNodePtr expr);148XMLPUBFUN void149xmlExpRef (xmlExpNodePtr expr);150151/*152* constructors can be either manual or from a string153*/154XMLPUBFUN xmlExpNodePtr155xmlExpParse (xmlExpCtxtPtr ctxt,156const char *expr);157XMLPUBFUN xmlExpNodePtr158xmlExpNewAtom (xmlExpCtxtPtr ctxt,159const xmlChar *name,160int len);161XMLPUBFUN xmlExpNodePtr162xmlExpNewOr (xmlExpCtxtPtr ctxt,163xmlExpNodePtr left,164xmlExpNodePtr right);165XMLPUBFUN xmlExpNodePtr166xmlExpNewSeq (xmlExpCtxtPtr ctxt,167xmlExpNodePtr left,168xmlExpNodePtr right);169XMLPUBFUN xmlExpNodePtr170xmlExpNewRange (xmlExpCtxtPtr ctxt,171xmlExpNodePtr subset,172int min,173int max);174/*175* The really interesting APIs176*/177XMLPUBFUN int178xmlExpIsNillable(xmlExpNodePtr expr);179XMLPUBFUN int180xmlExpMaxToken (xmlExpNodePtr expr);181XMLPUBFUN int182xmlExpGetLanguage(xmlExpCtxtPtr ctxt,183xmlExpNodePtr expr,184const xmlChar**langList,185int len);186XMLPUBFUN int187xmlExpGetStart (xmlExpCtxtPtr ctxt,188xmlExpNodePtr expr,189const xmlChar**tokList,190int len);191XMLPUBFUN xmlExpNodePtr192xmlExpStringDerive(xmlExpCtxtPtr ctxt,193xmlExpNodePtr expr,194const xmlChar *str,195int len);196XMLPUBFUN xmlExpNodePtr197xmlExpExpDerive (xmlExpCtxtPtr ctxt,198xmlExpNodePtr expr,199xmlExpNodePtr sub);200XMLPUBFUN int201xmlExpSubsume (xmlExpCtxtPtr ctxt,202xmlExpNodePtr expr,203xmlExpNodePtr sub);204XMLPUBFUN void205xmlExpDump (xmlBufferPtr buf,206xmlExpNodePtr expr);207#endif /* LIBXML_EXPR_ENABLED */208#ifdef __cplusplus209}210#endif211212#endif /* LIBXML_REGEXP_ENABLED */213214#endif /*__XML_REGEXP_H__ */215216217