summaryrefslogtreecommitdiffstats
path: root/axiom/src/xpath/xpath_internals.h
blob: 891d54304293cfabb5b653176475791fec39ada0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef AXIOM_XPATH_INTERNALS_H
#define AXIOM_XPATH_INTERNALS_H

#ifdef __cplusplus
extern "C"
{
#endif

    /**
     * @defgroup axiom_xpath_internals internals
     * @ingroup axiom_xpath
     * @{
     */


    /** Get operation at index ind */
#define AXIOM_XPATH_OPR_GET(ind) (axiom_xpath_operation_t *) \
 axutil_array_list_get(context->expr->operations, context->env, ind)

    /**
      * An error has occured while parsing
      */
#define AXIOM_XPATH_PARSE_ERROR -2

    /**
      * XPath expression was successfully compiled
      */
#define AXIOM_XPATH_PARSE_SUCCESS 0

    /**
      * End of expression reached
      */
#define AXIOM_XPATH_PARSE_END -1

    /* Types */

    /**
      * XPath operation
      * Contains the operands and parameters
      */
    typedef struct axiom_xpath_operation axiom_xpath_operation_t;

    /**
      * XPath node test
      * Stores the components of a node test
      */
    typedef struct axiom_xpath_node_test axiom_xpath_node_test_t;

    /**
      * Functions to process a XPath operator
      */
    typedef int (*axiom_xpath_operator_t)(axiom_xpath_context_t *context,
            axiom_xpath_operation_t * op);

    /**
      * Functions to iterate through different XPath axes
      */
    typedef int (*axiom_xpath_iterator_t)(axiom_xpath_context_t *context,
            int op_node_test,
            int op_next,
            int op_predicate);

    /**
      * XPath node test types
      */
    typedef enum axiom_xpath_node_test_type_t
    {
        AXIOM_XPATH_NODE_TEST_NONE = 0,
        AXIOM_XPATH_NODE_TEST_ALL,
        AXIOM_XPATH_NODE_TYPE_COMMENT,
        AXIOM_XPATH_NODE_TYPE_NODE,
        AXIOM_XPATH_NODE_TYPE_PI,
        AXIOM_XPATH_NODE_TYPE_TEXT,
        AXIOM_XPATH_NODE_TEST_STANDARD
    } axiom_xpath_node_test_type_t;

    /**
      * XPath operations
      */
    typedef enum axiom_xpath_operation_type_t
    {
        AXIOM_XPATH_OPERATION_ROOT_NODE = 0,
        AXIOM_XPATH_OPERATION_CONTEXT_NODE,
        AXIOM_XPATH_OPERATION_NODE_TEST,
        AXIOM_XPATH_OPERATION_STEP,
        AXIOM_XPATH_OPERATION_RESULT,
        AXIOM_XPATH_OPERATION_UNION,
        AXIOM_XPATH_OPERATION_EQUAL_EXPR,
        AXIOM_XPATH_OPERATION_AND_EXPR,
        AXIOM_XPATH_OPERATION_OR_EXPR,
        AXIOM_XPATH_OPERATION_PREDICATE,
        AXIOM_XPATH_OPERATION_LITERAL,
        AXIOM_XPATH_OPERATION_NUMBER,
        AXIOM_XPATH_OPERATION_PATH_EXPRESSION,
        AXIOM_XPATH_OPERATION_FUNCTION_CALL,
        AXIOM_XPATH_OPERATION_ARGUMENT
    } axiom_xpath_operation_type_t;

    /**
      * XPath axes
      */
    typedef enum axiom_xpath_axis_t
    {
        AXIOM_XPATH_AXIS_NONE = -1,
        AXIOM_XPATH_AXIS_CHILD,
        AXIOM_XPATH_AXIS_DESCENDANT,
        AXIOM_XPATH_AXIS_PARENT,
        AXIOM_XPATH_AXIS_ANCESTOR,
        AXIOM_XPATH_AXIS_FOLLOWING_SIBLING,
        AXIOM_XPATH_AXIS_PRECEDING_SIBLING,
        AXIOM_XPATH_AXIS_FOLLOWING,
        AXIOM_XPATH_AXIS_PRECEDING,
        AXIOM_XPATH_AXIS_ATTRIBUTE,
        AXIOM_XPATH_AXIS_NAMESPACE,
        AXIOM_XPATH_AXIS_SELF,
        AXIOM_XPATH_AXIS_DESCENDANT_OR_SELF,
        AXIOM_XPATH_AXIS_ANCESTOR_OR_SELF
    } axiom_xpath_axis_t;

    /**
      * XPath node test structure
      */
    struct axiom_xpath_node_test
    {
        /** Node test type */
        axiom_xpath_node_test_type_t type;

        /**  Prefix
          * NULL if no prefix
          */
        axis2_char_t *prefix;

        /** Name */
        axis2_char_t *name;

        /** Literal for processing instruction (PI)  */
        axis2_char_t *lit;
    };

    /**
      * XPath operation structure
      */
    struct axiom_xpath_operation
    {
        /** Type of operator */
        axiom_xpath_operation_type_t opr;

        /** Parameters of the operation */
        void *par1;
        void *par2;

        /**  Position: Used for predicate evaluation
          */
        int pos;

        /** Operands pointing to other operations */
        int op1;
        int op2;
    };

    /**
      * Copies an XPath expression to a context
      *
      * No data is duplicated just the reference is assigned.
      * Some parameters in the expression are reset.
      * - pos in every operation
      *
      * @param context XPath context must not be NULL
      * @param expr Expression to be copied
      */
    void axiom_xpath_expression_copy(
        axiom_xpath_context_t *context,
        axiom_xpath_expression_t* expr);

    /** @} */

#ifdef __cplusplus
}
#endif

#endif