-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoPilot.h
221 lines (171 loc) · 5.67 KB
/
autoPilot.h
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/*
* Copyright (C) 2002-2015 XimpleWare, info@ximpleware.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*VTD-XML is protected by US patent 7133857, 7260652, an 7761459*/
#ifndef AUTOPILOT_H
#define AUTOPILOT_H
#include "customTypes.h"
#include "vtdNav.h"
#include "cexcept.h"
#include "helper.h"
/* iter_type defines the type of iteration, to be used in function iterateAP*/
typedef enum iter_type { UNDEFINED,
SIMPLE,
SIMPLE_NS,
DESCENDANT,
DESCENDANT_NS,
FOLLOWING,
FOLLOWING_NS,
PRECEDING,
PRECEDING_NS,
ATTR,
ATTR_NS,
NAMESPACE,
SIMPLE_NODE,
DESCENDANT_NODE,
FOLLOWING_NODE,
PRECEDING_NODE} iterType;
typedef struct autoPilot{
UCSChar *URL;
UCSChar *localName;
UCSChar *elementName;
UCSChar *elementName2;
int depth;
VTDNav *vn;
int index; /* for iterAttr*/
int endIndex;
Boolean ft;
Boolean special;
iterType it;
int size; /* iterAttr*/
struct Expr *xpe; /* xpath Expr*/
int *contextCopy; /* for preceding axis */
int stackSize; /* record stack size for xpath evaluation */
FastIntBuffer *fib;
Boolean cachingOption;
} AutoPilot;
/*create AutoPilot */
AutoPilot *createAutoPilot(VTDNav *v);
AutoPilot *createAutoPilot2();
void printExprString(AutoPilot *ap);
/* bind */
void apBind(AutoPilot *ap, VTDNav *vn);
/* free AutoPilot*/
void freeAutoPilot(AutoPilot *ap);
/* Select an attribute name for iteration, * choose all attributes of an element*/
void selectAttr(AutoPilot *ap, UCSChar *an);
/* Select an attribute name, both local part and namespace URL part*/
void selectAttrNS(AutoPilot *ap, UCSChar *URL, UCSChar *ln);
/*Select the element name before iterating*/
void selectElement(AutoPilot *ap, UCSChar *en);
/*Select the element name (name space version) before iterating.
// * URL, if set to *, matches every namespace
// * URL, if set to null, indicates the namespace is undefined.
// * localname, if set to *, matches any localname*/
void selectElementNS(AutoPilot *ap, UCSChar *URL, UCSChar *ln);
/**
* Select all descendent elements along the descendent axis, without ns awareness
* This function is not intended to be called directly
* @param en
*/
void selectElement_D(AutoPilot *ap, UCSChar *en);
/**
* Select all descendent elements along the Descendent axis, with ns awareness
* This function is not intended to be called directly
*/
void selectElementNS_D(AutoPilot *ap, UCSChar *URL, UCSChar *ln);
/**
* Select all descendent elements along the following axis, without ns awareness
* This function is not intended to be called directly
* @param en
*/
void selectElement_F(AutoPilot *ap, UCSChar *en);
/**
* Select all descendent elements along the following axis, with ns awareness
* This function is not intended to be called directly
*/
void selectElementNS_F(AutoPilot *ap, UCSChar *URL, UCSChar *ln);
/**
* Select all descendent elements along the preceding axis, without ns awareness
* This function is not intended to be called directly
* @param en
*/
void selectElement_P(AutoPilot *ap, UCSChar *en);
/**
* This function is not intended to be called directly
* Select all descendent elements along the preceding axis, with ns awareness
*/
void selectElementNS_P(AutoPilot *ap, UCSChar *URL, UCSChar *ln);
void selectNode(AutoPilot *ap);
void selectPrecedingNode(AutoPilot *ap);
void selectFollowingNode(AutoPilot *ap);
void selectDescendantNode(AutoPilot *ap);
/**
* Setspecial is used by XPath evaluator to distinguish between
* node() and *
* node() corresponding to b= true;
* This function is not intended to be called directly
*/
void setSpecial(AutoPilot *ap, Boolean b);
//Iterate over all the selected element nodes.
Boolean iterateAP(AutoPilot *ap);
Boolean iterateAP2(AutoPilot *ap);
// Normal iterate Attribute nodes...
int iterateAttr(AutoPilot *ap);
// This method implements the attribute axis for XPath
int iterateAttr2(AutoPilot *ap);
/*
* This function selects the string representing XPath expression
* Usually evalXPath is called afterwards
* return true is the XPath is valid
*/
Boolean selectXPath(AutoPilot *ap, UCSChar *s);
/*
* Evaluate XPath to a boolean
*/
Boolean evalXPathToBoolean(AutoPilot *ap);
/*
* Evaluate XPath to a String
*/
UCSChar* evalXPathToString(AutoPilot *ap);
/*
* Evaluate XPath to a number
*/
double evalXPathToNumber(AutoPilot *ap);
/*
* Evaluate XPath
*/
int evalXPath(AutoPilot *ap);
/*
* Reset XPath
*/
void resetXPath(AutoPilot *ap);
/*
* Declare prefix/URL binding
*/
void declareXPathNameSpace(AutoPilot *ap, UCSChar *prefix, UCSChar *URL);
/* Clear the namespace prefix URL bindings in the global list */
void clearXPathNameSpaces();
/* Clear the variable name and exprs in the global list */
void clearVariableExprs();
/* Declare the variable name and expression binding*/
void declareVariableExpr(AutoPilot *ap, UCSChar* varName, UCSChar* varExpr);
void selectNameSpace(AutoPilot *ap, UCSChar *name);
int iterateNameSpace(AutoPilot *ap);
void enableCaching(AutoPilot *ap, Boolean state);
VTDNav* getNavFromAP(AutoPilot *ap);
#endif