Daniel Veillard | 29a11cc | 2000-10-25 13:32:39 +0000 | [diff] [blame^] | 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)) \ |
| 41 | XP_ERROR(XPATH_INVALID_TYPE) \ |
| 42 | |
| 43 | #define CHECK_ARITY(x) \ |
| 44 | if (nargs != (x)) { \ |
| 45 | XP_ERROR(XPATH_INVALID_ARITY); \ |
| 46 | } \ |
| 47 | |
| 48 | void xmlXPatherror (xmlXPathParserContextPtr ctxt, |
| 49 | const char *file, |
| 50 | int line, |
| 51 | int no); |
| 52 | |
| 53 | void xmlXPathDebugDumpObject (FILE *output, |
| 54 | xmlXPathObjectPtr cur, |
| 55 | int depth); |
| 56 | |
| 57 | /** |
| 58 | * Extending a context |
| 59 | */ |
| 60 | int xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, |
| 61 | const xmlChar *name, |
| 62 | xmlXPathFunction f); |
| 63 | int xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, |
| 64 | const xmlChar *name, |
| 65 | xmlXPathObjectPtr value); |
| 66 | xmlXPathFunction xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, |
| 67 | const xmlChar *name); |
| 68 | void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt); |
| 69 | xmlXPathObjectPtr xmlXPathVariableLookup (xmlXPathContextPtr ctxt, |
| 70 | const xmlChar *name); |
| 71 | void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); |
| 72 | |
| 73 | /** |
| 74 | * Utilities to extend XPath |
| 75 | */ |
| 76 | xmlXPathParserContextPtr |
| 77 | xmlXPathNewParserContext (const xmlChar *str, |
| 78 | xmlXPathContextPtr ctxt); |
| 79 | void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); |
| 80 | |
| 81 | xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt); |
| 82 | int valuePush (xmlXPathParserContextPtr ctxt, |
| 83 | xmlXPathObjectPtr value); |
| 84 | |
| 85 | xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val); |
| 86 | xmlXPathObjectPtr xmlXPathNewCString (const char *val); |
| 87 | xmlXPathObjectPtr xmlXPathNewFloat (double val); |
| 88 | xmlXPathObjectPtr xmlXPathNewBoolean (int val); |
| 89 | xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val); |
| 90 | void xmlXPathNodeSetAdd (xmlNodeSetPtr cur, |
| 91 | xmlNodePtr val); |
| 92 | |
| 93 | |
| 94 | void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt, |
| 95 | int nargs); |
| 96 | void xmlXPathRoot (xmlXPathParserContextPtr ctxt); |
| 97 | void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); |
| 98 | xmlChar * xmlXPathParseName (xmlXPathParserContextPtr ctxt); |
| 99 | |
| 100 | /* |
| 101 | * Debug |
| 102 | */ |
| 103 | #ifdef LIBXML_DEBUG_ENABLED |
| 104 | double xmlXPathStringEvalNumber(const xmlChar *str); |
| 105 | void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth); |
| 106 | #endif |
| 107 | /* |
| 108 | * Existing functions |
| 109 | */ |
| 110 | |
| 111 | void xmlXPathInit(void); |
| 112 | void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 113 | void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt); |
| 114 | xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val); |
| 115 | void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val); |
| 116 | xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2); |
| 117 | void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val); |
| 118 | void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val); |
| 119 | void xmlXPathFreeNodeSet(xmlNodeSetPtr obj); |
| 120 | xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val); |
| 121 | xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val); |
| 122 | xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val); |
| 123 | void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj); |
| 124 | |
| 125 | |
| 126 | xmlXPathObjectPtr xmlXPathNewFloat(double val); |
| 127 | xmlXPathObjectPtr xmlXPathNewBoolean(int val); |
| 128 | xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val); |
| 129 | xmlXPathObjectPtr xmlXPathNewCString(const char *val); |
| 130 | void xmlXPathFreeObject(xmlXPathObjectPtr obj); |
| 131 | xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc); |
| 132 | void xmlXPathFreeContext(xmlXPathContextPtr ctxt); |
| 133 | |
| 134 | int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); |
| 135 | int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); |
| 136 | void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); |
| 137 | void xmlXPathAddValues(xmlXPathParserContextPtr ctxt); |
| 138 | void xmlXPathSubValues(xmlXPathParserContextPtr ctxt); |
| 139 | void xmlXPathMultValues(xmlXPathParserContextPtr ctxt); |
| 140 | void xmlXPathDivValues(xmlXPathParserContextPtr ctxt); |
| 141 | void xmlXPathModValues(xmlXPathParserContextPtr ctxt); |
| 142 | |
| 143 | /* |
| 144 | * The official core of XPath functions |
| 145 | */ |
| 146 | void xmlXPathRoot(xmlXPathParserContextPtr ctxt); |
| 147 | void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 148 | void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 149 | void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 150 | void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 151 | void xmlXPathLocalPartFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 152 | void xmlXPathNamespaceFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 153 | void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 154 | void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 155 | void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 156 | void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 157 | void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 158 | void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 159 | void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 160 | void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 161 | void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 162 | void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 163 | void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 164 | void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 165 | void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 166 | void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 167 | void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 168 | void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 169 | void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 170 | void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 171 | void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 172 | #ifdef __cplusplus |
| 173 | } |
| 174 | #endif |
| 175 | #endif /* ! __XML_XPATH_INTERNALS_H__ */ |