Annotation of XML/xpathInternals.h, revision 1.4

1.1       veillard    1: /*
                      2:  * xpath.c: internal interfaces for XML Path Language implementation
                      3:  *          used to build new modules on top of XPath
                      4:  *
                      5:  * See COPYRIGHT for the status of this software
                      6:  *
                      7:  * Author: Daniel.Veillard@w3.org
                      8:  */
                      9: 
                     10: #ifndef __XML_XPATH_INTERNALS_H__
                     11: #define __XML_XPATH_INTERNALS_H__
                     12: 
                     13: #include <libxml/xpath.h>
                     14: 
                     15: #ifdef __cplusplus
                     16: extern "C" {
                     17: #endif
                     18: 
                     19: /************************************************************************
                     20:  *                                                                     *
                     21:  *                     Helpers                                         *
                     22:  *                                                                     *
                     23:  ************************************************************************/
                     24: 
                     25: #define CHECK_ERROR                                                    \
                     26:     if (ctxt->error != XPATH_EXPRESSION_OK) return
                     27: 
                     28: #define CHECK_ERROR0                                                   \
                     29:     if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
                     30: 
                     31: #define XP_ERROR(X)                                                    \
                     32:     { xmlXPatherror(ctxt, __FILE__, __LINE__, X);                      \
                     33:       ctxt->error = (X); return; }
                     34: 
                     35: #define XP_ERROR0(X)                                                   \
                     36:     { xmlXPatherror(ctxt, __FILE__, __LINE__, X);                      \
                     37:       ctxt->error = (X); return(0); }
                     38: 
                     39: #define CHECK_TYPE(typeval)                                            \
                     40:     if ((ctxt->value == NULL) || (ctxt->value->type != typeval))       \
1.3       veillard   41:         XP_ERROR(XPATH_INVALID_TYPE)
1.1       veillard   42: 
                     43: #define CHECK_ARITY(x)                                                 \
1.3       veillard   44:     if (nargs != (x))                                                  \
                     45:         XP_ERROR(XPATH_INVALID_ARITY);
                     46: 
                     47: #define CAST_TO_STRING                                                 \
                     48:     if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING))  \
                     49:         xmlXPathStringFunction(ctxt, 1);
                     50: 
                     51: #define CAST_TO_NUMBER                                                 \
                     52:     if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER))  \
                     53:         xmlXPathNumberFunction(ctxt, 1);
                     54: 
                     55: #define CAST_TO_BOOLEAN                                                        \
                     56:     if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
                     57:         xmlXPathBooleanFunction(ctxt, 1);
1.1       veillard   58: 
                     59: void           xmlXPatherror   (xmlXPathParserContextPtr ctxt,
                     60:                                 const char *file,
                     61:                                 int line,
                     62:                                 int no);
                     63: 
                     64: void           xmlXPathDebugDumpObject (FILE *output,
                     65:                                         xmlXPathObjectPtr cur,
                     66:                                         int depth);
                     67: 
                     68: /**
                     69:  * Extending a context
                     70:  */
                     71: int               xmlXPathRegisterFunc         (xmlXPathContextPtr ctxt,
                     72:                                                 const xmlChar *name,
                     73:                                                 xmlXPathFunction f);
1.3       veillard   74: int               xmlXPathRegisterFuncNS       (xmlXPathContextPtr ctxt,
                     75:                                                 const xmlChar *name,
                     76:                                                 const xmlChar *ns_uri,
                     77:                                                 xmlXPathFunction f);
1.1       veillard   78: int               xmlXPathRegisterVariable     (xmlXPathContextPtr ctxt,
                     79:                                                 const xmlChar *name,
                     80:                                                 xmlXPathObjectPtr value);
1.3       veillard   81: int               xmlXPathRegisterVariableNS   (xmlXPathContextPtr ctxt,
                     82:                                                 const xmlChar *name,
                     83:                                                 const xmlChar *ns_uri,
                     84:                                                 xmlXPathObjectPtr value);
1.1       veillard   85: xmlXPathFunction   xmlXPathFunctionLookup      (xmlXPathContextPtr ctxt,
                     86:                                                 const xmlChar *name);
1.3       veillard   87: xmlXPathFunction   xmlXPathFunctionLookupNS    (xmlXPathContextPtr ctxt,
                     88:                                                 const xmlChar *name,
                     89:                                                 const xmlChar *ns_uri);
1.1       veillard   90: void              xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt);
                     91: xmlXPathObjectPtr  xmlXPathVariableLookup      (xmlXPathContextPtr ctxt,
                     92:                                                 const xmlChar *name);
1.3       veillard   93: xmlXPathObjectPtr  xmlXPathVariableLookupNS    (xmlXPathContextPtr ctxt,
                     94:                                                 const xmlChar *name,
                     95:                                                 const xmlChar *ns_uri);
1.1       veillard   96: void              xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
                     97: 
                     98: /**
                     99:  * Utilities to extend XPath
                    100:  */
                    101: xmlXPathParserContextPtr
                    102:                  xmlXPathNewParserContext      (const xmlChar *str,
                    103:                                                 xmlXPathContextPtr ctxt);
                    104: void             xmlXPathFreeParserContext     (xmlXPathParserContextPtr ctxt);
                    105: 
                    106: xmlXPathObjectPtr valuePop                     (xmlXPathParserContextPtr ctxt);
                    107: int              valuePush                     (xmlXPathParserContextPtr ctxt,
                    108:                                                xmlXPathObjectPtr value);
                    109: 
                    110: xmlXPathObjectPtr xmlXPathNewString            (const xmlChar *val);
                    111: xmlXPathObjectPtr xmlXPathNewCString           (const char *val);
                    112: xmlXPathObjectPtr xmlXPathNewFloat             (double val);
                    113: xmlXPathObjectPtr xmlXPathNewBoolean           (int val);
                    114: xmlXPathObjectPtr xmlXPathNewNodeSet           (xmlNodePtr val);
                    115: void             xmlXPathNodeSetAdd            (xmlNodeSetPtr cur,
                    116:                                                 xmlNodePtr val);
                    117: 
                    118: 
                    119: void             xmlXPathIdFunction            (xmlXPathParserContextPtr ctxt,
                    120:                                                int nargs);
                    121: void             xmlXPathRoot                  (xmlXPathParserContextPtr ctxt);
                    122: void             xmlXPathEvalExpr              (xmlXPathParserContextPtr ctxt);
                    123: xmlChar *        xmlXPathParseName             (xmlXPathParserContextPtr ctxt);
                    124: 
                    125: /*
                    126:  * Debug
                    127:  */
                    128: #ifdef LIBXML_DEBUG_ENABLED
                    129: double xmlXPathStringEvalNumber(const xmlChar *str);
                    130: void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth);
                    131: #endif
                    132: /*
                    133:  * Existing functions
                    134:  */
                    135: 
1.4     ! veillard  136: int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt, 
        !           137:                                     xmlXPathObjectPtr res);
1.1       veillard  138: void xmlXPathInit(void);
                    139: void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    140: void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
                    141: xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val);
                    142: void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val);
                    143: xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2);
                    144: void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val);
                    145: void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val);
                    146: void xmlXPathFreeNodeSet(xmlNodeSetPtr obj);
                    147: xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val);
                    148: xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val);
                    149: xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val);
                    150: void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj);
                    151: 
                    152: 
                    153: xmlXPathObjectPtr xmlXPathNewFloat(double val);
                    154: xmlXPathObjectPtr xmlXPathNewBoolean(int val);
                    155: xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val);
                    156: xmlXPathObjectPtr xmlXPathNewCString(const char *val);
                    157: void xmlXPathFreeObject(xmlXPathObjectPtr obj);
                    158: xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc);
                    159: void xmlXPathFreeContext(xmlXPathContextPtr ctxt);
                    160: 
                    161: int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
                    162: int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
                    163: void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
                    164: void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
                    165: void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
                    166: void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
                    167: void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
                    168: void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
                    169: 
                    170: /*
                    171:  * The official core of XPath functions
                    172:  */
                    173: void xmlXPathRoot(xmlXPathParserContextPtr ctxt);
                    174: void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    175: void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    176: void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    177: void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
1.2       veillard  178: void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    179: void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
1.1       veillard  180: void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    181: void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    182: void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    183: void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    184: void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    185: void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    186: void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    187: void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    188: void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    189: void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    190: void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    191: void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    192: void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    193: void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    194: void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    195: void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    196: void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    197: void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    198: void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
                    199: #ifdef __cplusplus
                    200: }
                    201: #endif
                    202: #endif /* ! __XML_XPATH_INTERNALS_H__ */

Webmaster