2011-08-25 19:08:55 +08:00
|
|
|
/*
|
|
|
|
* Summary: regular expressions handling
|
|
|
|
* Description: basic API for libxml regular expressions handling used
|
|
|
|
* for XML Schemas and validation.
|
|
|
|
*
|
|
|
|
* Copy: See Copyright for the status of this software.
|
|
|
|
*
|
|
|
|
* Author: Daniel Veillard
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __XML_REGEXP_H__
|
|
|
|
#define __XML_REGEXP_H__
|
|
|
|
|
|
|
|
#include <libxml/xmlversion.h>
|
|
|
|
|
|
|
|
#ifdef LIBXML_REGEXP_ENABLED
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xmlRegexpPtr:
|
|
|
|
*
|
|
|
|
* A libxml regular expression, they can actually be far more complex
|
|
|
|
* thank the POSIX regex expressions.
|
|
|
|
*/
|
|
|
|
typedef struct _xmlRegexp xmlRegexp;
|
|
|
|
typedef xmlRegexp *xmlRegexpPtr;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* xmlRegExecCtxtPtr:
|
|
|
|
*
|
|
|
|
* A libxml progressive regular expression evaluation context
|
|
|
|
*/
|
|
|
|
typedef struct _xmlRegExecCtxt xmlRegExecCtxt;
|
|
|
|
typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#include <libxml/dict.h>
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The POSIX like API
|
|
|
|
*/
|
|
|
|
XMLPUBFUN xmlRegexpPtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegexpCompile (const xmlChar *regexp);
|
|
|
|
XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegexpExec (xmlRegexpPtr comp,
|
|
|
|
const xmlChar *value);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegexpPrint (FILE *output,
|
|
|
|
xmlRegexpPtr regexp);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegexpIsDeterminist(xmlRegexpPtr comp);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* xmlRegExecCallbacks:
|
|
|
|
* @exec: the regular expression context
|
|
|
|
* @token: the current token string
|
|
|
|
* @transdata: transition data
|
|
|
|
* @inputdata: input data
|
|
|
|
*
|
|
|
|
* Callback function when doing a transition in the automata
|
|
|
|
*/
|
|
|
|
typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
|
2012-04-19 14:35:52 +08:00
|
|
|
const xmlChar *token,
|
|
|
|
void *transdata,
|
|
|
|
void *inputdata);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The progressive API
|
|
|
|
*/
|
|
|
|
XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegNewExecCtxt (xmlRegexpPtr comp,
|
|
|
|
xmlRegExecCallbacks callback,
|
|
|
|
void *data);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegExecPushString(xmlRegExecCtxtPtr exec,
|
|
|
|
const xmlChar *value,
|
|
|
|
void *data);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
|
|
|
|
const xmlChar *value,
|
|
|
|
const xmlChar *value2,
|
|
|
|
void *data);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
|
|
|
|
int *nbval,
|
|
|
|
int *nbneg,
|
|
|
|
xmlChar **values,
|
|
|
|
int *terminal);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
|
|
|
|
const xmlChar **string,
|
|
|
|
int *nbval,
|
|
|
|
int *nbneg,
|
|
|
|
xmlChar **values,
|
|
|
|
int *terminal);
|
2011-08-25 19:08:55 +08:00
|
|
|
#ifdef LIBXML_EXPR_ENABLED
|
|
|
|
/*
|
|
|
|
* Formal regular expression handling
|
|
|
|
* Its goal is to do some formal work on content models
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* expressions are used within a context */
|
|
|
|
typedef struct _xmlExpCtxt xmlExpCtxt;
|
|
|
|
typedef xmlExpCtxt *xmlExpCtxtPtr;
|
|
|
|
|
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpFreeCtxt (xmlExpCtxtPtr ctxt);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpCtxtPtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpNewCtxt (int maxNodes,
|
|
|
|
xmlDictPtr dict);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
/* Expressions are trees but the tree is opaque */
|
|
|
|
typedef struct _xmlExpNode xmlExpNode;
|
|
|
|
typedef xmlExpNode *xmlExpNodePtr;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
XML_EXP_EMPTY = 0,
|
|
|
|
XML_EXP_FORBID = 1,
|
|
|
|
XML_EXP_ATOM = 2,
|
|
|
|
XML_EXP_SEQ = 3,
|
|
|
|
XML_EXP_OR = 4,
|
|
|
|
XML_EXP_COUNT = 5
|
|
|
|
} xmlExpNodeType;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2 core expressions shared by all for the empty language set
|
|
|
|
* and for the set with just the empty token
|
|
|
|
*/
|
|
|
|
XMLPUBVAR xmlExpNodePtr forbiddenExp;
|
|
|
|
XMLPUBVAR xmlExpNodePtr emptyExp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Expressions are reference counted internally
|
|
|
|
*/
|
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpFree (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpRef (xmlExpNodePtr expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* constructors can be either manual or from a string
|
|
|
|
*/
|
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpParse (xmlExpCtxtPtr ctxt,
|
|
|
|
const char *expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpNewAtom (xmlExpCtxtPtr ctxt,
|
|
|
|
const xmlChar *name,
|
|
|
|
int len);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpNewOr (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr left,
|
|
|
|
xmlExpNodePtr right);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpNewSeq (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr left,
|
|
|
|
xmlExpNodePtr right);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpNewRange (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr subset,
|
|
|
|
int min,
|
|
|
|
int max);
|
2011-08-25 19:08:55 +08:00
|
|
|
/*
|
|
|
|
* The really interesting APIs
|
|
|
|
*/
|
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpIsNillable(xmlExpNodePtr expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpMaxToken (xmlExpNodePtr expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpGetLanguage(xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr,
|
|
|
|
const xmlChar**langList,
|
|
|
|
int len);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpGetStart (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr,
|
|
|
|
const xmlChar**tokList,
|
|
|
|
int len);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpStringDerive(xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr,
|
|
|
|
const xmlChar *str,
|
|
|
|
int len);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN xmlExpNodePtr XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpExpDerive (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr,
|
|
|
|
xmlExpNodePtr sub);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN int XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpSubsume (xmlExpCtxtPtr ctxt,
|
|
|
|
xmlExpNodePtr expr,
|
|
|
|
xmlExpNodePtr sub);
|
2011-08-25 19:08:55 +08:00
|
|
|
XMLPUBFUN void XMLCALL
|
2012-04-19 14:35:52 +08:00
|
|
|
xmlExpDump (xmlBufferPtr buf,
|
|
|
|
xmlExpNodePtr expr);
|
2011-08-25 19:08:55 +08:00
|
|
|
#endif /* LIBXML_EXPR_ENABLED */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* LIBXML_REGEXP_ENABLED */
|
|
|
|
|
|
|
|
#endif /*__XML_REGEXP_H__ */
|