|
|
|
|
| 24 |
* -- 19990806 |
24 |
* -- 19990806 |
| 25 |
* - changed constant short declarations in many of the classes |
25 |
* - changed constant short declarations in many of the classes |
| 26 |
* with enumerations, commented with //--LF |
26 |
* with enumerations, commented with //--LF |
|
|
27 |
* Jonas Sicking, sicking@bigfoot.com |
| 28 |
* -- removal of Patterns and some restructuring |
| 29 |
* in the class set |
| 27 |
* |
30 |
* |
| 28 |
* $Id: Expr.h,v 1.13 2001/05/12 09:54:15 nisheeth%netscape.com Exp $ |
31 |
* $Id: Expr.h,v 1.13 2001/05/12 09:54:15 nisheeth%netscape.com Exp $ |
| 29 |
*/ |
32 |
*/ |
|
|
| 52 |
//necessary prototypes |
55 |
//necessary prototypes |
| 53 |
class FunctionCall; |
56 |
class FunctionCall; |
| 54 |
|
57 |
|
|
|
58 |
typedef class Expr Pattern; |
| 59 |
typedef class Expr PatternExpr; |
| 60 |
|
| 61 |
|
| 55 |
/** |
62 |
/** |
| 56 |
* The expression context and state class used when evaluating XPath Expressions. |
63 |
* The expression context and state class used when evaluating XPath Expressions. |
| 57 |
**/ |
64 |
**/ |
|
|
| 59 |
|
66 |
|
| 60 |
public: |
67 |
public: |
| 61 |
|
68 |
|
| 62 |
|
|
|
| 63 |
/** |
69 |
/** |
| 64 |
* Returns the value of a given variable binding within the current scope |
70 |
* Returns the value of a given variable binding within the current scope |
| 65 |
* @param the name to which the desired variable value has been bound |
71 |
* @param the name to which the desired variable value has been bound |
|
|
| 82 |
**/ |
88 |
**/ |
| 83 |
virtual Node* getParentNode(Node* node) = 0; |
89 |
virtual Node* getParentNode(Node* node) = 0; |
| 84 |
|
90 |
|
| 85 |
|
|
|
| 86 |
virtual MBool isStripSpaceAllowed(Node* node) = 0; |
91 |
virtual MBool isStripSpaceAllowed(Node* node) = 0; |
| 87 |
|
92 |
|
| 88 |
|
|
|
| 89 |
/** |
93 |
/** |
| 90 |
* Returns a call to the function that has the given name. |
94 |
* Returns a call to the function that has the given name. |
| 91 |
* This method is used for XPath Extension Functions. |
95 |
* This method is used for XPath Extension Functions. |
|
|
| 101 |
**/ |
105 |
**/ |
| 102 |
virtual void sortByDocumentOrder(NodeSet* nodes) = 0; |
106 |
virtual void sortByDocumentOrder(NodeSet* nodes) = 0; |
| 103 |
|
107 |
|
| 104 |
|
|
|
| 105 |
}; //-- ContextState |
108 |
}; //-- ContextState |
| 106 |
|
109 |
|
| 107 |
|
110 |
|
|
|
| 115 |
/** |
118 |
/** |
| 116 |
* Virtual destructor, important for subclasses |
119 |
* Virtual destructor, important for subclasses |
| 117 |
**/ |
120 |
**/ |
| 118 |
virtual ~Expr() {}; |
121 |
virtual ~Expr(); |
| 119 |
|
122 |
|
| 120 |
/** |
123 |
/** |
| 121 |
* Evaluates this Expr based on the given context node and processor state |
124 |
* Evaluates this Expr based on the given context node and processor state |
|
|
| 127 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
130 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
| 128 |
|
131 |
|
| 129 |
/** |
132 |
/** |
|
|
133 |
* Determines whether this Expr matches the given node within |
| 134 |
* the given context |
| 135 |
**/ |
| 136 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 137 |
|
| 138 |
/** |
| 139 |
* Returns the default priority of this Expr based on the given Node, |
| 140 |
* context Node, and ContextState. |
| 141 |
**/ |
| 142 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 143 |
|
| 144 |
/** |
| 130 |
* Returns the String representation of this Expr. |
145 |
* Returns the String representation of this Expr. |
| 131 |
* @param dest the String to use when creating the String |
146 |
* @param dest the String to use when creating the String |
| 132 |
* representation. The String representation will be appended to |
147 |
* representation. The String representation will be appended to |
|
|
| 138 |
|
153 |
|
| 139 |
}; //-- Expr |
154 |
}; //-- Expr |
| 140 |
|
155 |
|
| 141 |
|
|
|
| 142 |
/** |
156 |
/** |
| 143 |
* This class represents a FunctionCall as defined by the XPath 1.0 |
157 |
* This class represents a FunctionCall as defined by the XPath 1.0 |
| 144 |
* Recommendation. |
158 |
* Recommendation. |
|
|
| 149 |
|
163 |
|
| 150 |
static const String INVALID_PARAM_COUNT; |
164 |
static const String INVALID_PARAM_COUNT; |
| 151 |
|
165 |
|
| 152 |
|
|
|
| 153 |
virtual ~FunctionCall(); |
166 |
virtual ~FunctionCall(); |
| 154 |
|
167 |
|
| 155 |
/** |
168 |
/** |
| 156 |
* Adds the given parameter to this FunctionCall's parameter list |
169 |
* Virtual methods from Expr |
| 157 |
* @param expr the Expr to add to this FunctionCall's parameter list |
|
|
| 158 |
**/ |
170 |
**/ |
| 159 |
void addParam(Expr* expr); |
171 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
|
|
172 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 173 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 174 |
virtual void toString(String& dest); |
| 160 |
|
175 |
|
| 161 |
/** |
176 |
/** |
| 162 |
* Evaluates this Expr based on the given context node and processor state |
177 |
* Adds the given parameter to this FunctionCall's parameter list |
| 163 |
* @param context the context node for evaluation of this Expr |
178 |
* @param expr the Expr to add to this FunctionCall's parameter list |
| 164 |
* @param ps the ContextState containing the stack information needed |
|
|
| 165 |
* for evaluation |
| 166 |
* @return the result of the evaluation |
| 167 |
**/ |
179 |
**/ |
| 168 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
180 |
void addParam(Expr* expr); |
| 169 |
|
181 |
|
| 170 |
/** |
182 |
/** |
| 171 |
* Returns the name of this FunctionCall |
183 |
* Returns the name of this FunctionCall |
|
|
| 184 |
* @param name the name of this Function |
196 |
* @param name the name of this Function |
| 185 |
**/ |
197 |
**/ |
| 186 |
void setName(const String& name); |
198 |
void setName(const String& name); |
| 187 |
/** |
|
|
| 188 |
* Returns the String representation of this Pattern. |
| 189 |
* @param dest the String to use when creating the String |
| 190 |
* representation. The String representation will be appended to |
| 191 |
* any data in the destination String, to allow cascading calls to |
| 192 |
* other #toString() methods for Expressions. |
| 193 |
* @return the String representation of this Pattern. |
| 194 |
**/ |
| 195 |
virtual void toString(String& dest); |
| 196 |
|
199 |
|
| 197 |
|
200 |
|
| 198 |
protected: |
201 |
protected: |
|
|
| 203 |
FunctionCall(const String& name); |
206 |
FunctionCall(const String& name); |
| 204 |
FunctionCall(const String& name, List* parameters); |
207 |
FunctionCall(const String& name, List* parameters); |
| 205 |
|
208 |
|
| 206 |
|
|
|
| 207 |
/** |
209 |
/** |
| 208 |
* Evaluates the given Expression and converts it's result to a String. |
210 |
* Evaluates the given Expression and converts it's result to a String. |
| 209 |
* The value is appended to the given destination String |
211 |
* The value is appended to the given destination String |
|
|
| 221 |
String name; |
223 |
String name; |
| 222 |
}; //-- FunctionCall |
224 |
}; //-- FunctionCall |
| 223 |
|
225 |
|
| 224 |
/** |
|
|
| 225 |
* A base Pattern class |
| 226 |
**/ |
| 227 |
class Pattern { |
| 228 |
|
| 229 |
public: |
| 230 |
|
| 231 |
/** |
| 232 |
* Virtual destructor, important for subclasses |
| 233 |
**/ |
| 234 |
virtual ~Pattern() {}; |
| 235 |
|
| 236 |
/** |
| 237 |
* Returns the default priority of this Pattern based on the given Node, |
| 238 |
* context Node, and ContextState. |
| 239 |
* If this pattern does not match the given Node under the current context Node and |
| 240 |
* ContextState then Negative Infinity is returned. |
| 241 |
**/ |
| 242 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs) = 0; |
| 243 |
|
| 244 |
/** |
| 245 |
* Determines whether this Pattern matches the given node within |
| 246 |
* the given context |
| 247 |
**/ |
| 248 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
| 249 |
|
| 250 |
|
226 |
|
| 251 |
/** |
|
|
| 252 |
* Returns the String representation of this Pattern. |
| 253 |
* @param dest the String to use when creating the String |
| 254 |
* representation. The String representation will be appended to |
| 255 |
* any data in the destination String, to allow cascading calls to |
| 256 |
* other #toString() methods for Expressions. |
| 257 |
* @return the String representation of this Pattern. |
| 258 |
**/ |
| 259 |
virtual void toString(String& dest) = 0; |
| 260 |
|
| 261 |
}; //-- Pattern |
| 262 |
|
| 263 |
|
| 264 |
/** |
227 |
/** |
| 265 |
* A Base class for all Expressions and Patterns |
|
|
| 266 |
**/ |
| 267 |
class PatternExpr : |
| 268 |
public Expr, |
| 269 |
public Pattern |
| 270 |
{ |
| 271 |
|
| 272 |
public: |
| 273 |
|
| 274 |
/** |
| 275 |
* Virtual destructor, important for subclasses |
| 276 |
**/ |
| 277 |
virtual ~PatternExpr() {}; |
| 278 |
|
| 279 |
/** |
| 280 |
* Evaluates this Expr based on the given context node and processor state |
| 281 |
* @param context the context node for evaluation of this Expr |
| 282 |
* @param ps the ContextState containing the stack information needed |
| 283 |
* for evaluation |
| 284 |
* @return the result of the evaluation |
| 285 |
**/ |
| 286 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
| 287 |
|
| 288 |
/** |
| 289 |
* Returns the default priority of this Pattern based on the given Node, |
| 290 |
* context Node, and ContextState. |
| 291 |
* If this pattern does not match the given Node under the current context Node and |
| 292 |
* ContextState then Negative Infinity is returned. |
| 293 |
**/ |
| 294 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs) = 0; |
| 295 |
|
| 296 |
/** |
| 297 |
* Determines whether this PatternExpr matches the given node within |
| 298 |
* the given context |
| 299 |
**/ |
| 300 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
| 301 |
|
| 302 |
/** |
| 303 |
* Returns the String representation of this PatternExpr. |
| 304 |
* @param dest the String to use when creating the String |
| 305 |
* representation. The String representation will be appended to |
| 306 |
* any data in the destination String, to allow cascading calls to |
| 307 |
* other #toString() methods for Expressions. |
| 308 |
* @return the String representation of this PatternExpr. |
| 309 |
**/ |
| 310 |
virtual void toString(String& dest) = 0; |
| 311 |
|
| 312 |
}; //-- PatternExpr |
| 313 |
|
| 314 |
/** |
| 315 |
* Represents an AttributeValueTemplate |
228 |
* Represents an AttributeValueTemplate |
| 316 |
**/ |
229 |
**/ |
| 317 |
class AttributeValueTemplate: public Expr { |
230 |
class AttributeValueTemplate: public Expr { |
|
|
| 328 |
void addExpr(Expr* expr); |
241 |
void addExpr(Expr* expr); |
| 329 |
|
242 |
|
| 330 |
/** |
243 |
/** |
| 331 |
* Evaluates this Expr based on the given context node and processor state |
244 |
* Virtual methods from Expr |
| 332 |
* @param context the context node for evaluation of this Expr |
|
|
| 333 |
* @param ps the ContextState containing the stack information needed |
| 334 |
* for evaluation |
| 335 |
* @return the result of the evaluation |
| 336 |
**/ |
245 |
**/ |
| 337 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
246 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 338 |
|
|
|
| 339 |
/** |
| 340 |
* Returns the String representation of this Expr. |
| 341 |
* @param dest the String to use when creating the String |
| 342 |
* representation. The String representation will be appended to |
| 343 |
* any data in the destination String, to allow cascading calls to |
| 344 |
* other #toString() methods for Expressions. |
| 345 |
* @return the String representation of this Expr. |
| 346 |
**/ |
| 347 |
virtual void toString(String& str); |
247 |
virtual void toString(String& str); |
| 348 |
|
248 |
|
| 349 |
private: |
249 |
private: |
|
|
| 355 |
* This class represents a NodeTestExpr as defined by the XSL |
255 |
* This class represents a NodeTestExpr as defined by the XSL |
| 356 |
* Working Draft |
256 |
* Working Draft |
| 357 |
**/ |
257 |
**/ |
| 358 |
class NodeExpr : public PatternExpr { |
258 |
class NodeExpr : public Expr { |
| 359 |
|
259 |
|
| 360 |
public: |
260 |
public: |
| 361 |
|
261 |
|
|
|
| 379 |
//------------------/ |
279 |
//------------------/ |
| 380 |
|
280 |
|
| 381 |
/** |
281 |
/** |
| 382 |
* Returns the default priority of this Pattern based on the given Node, |
|
|
| 383 |
* context Node, and ContextState. |
| 384 |
* If this pattern does not match the given Node under the current context Node and |
| 385 |
* ContextState then Negative Infinity is returned. |
| 386 |
**/ |
| 387 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs) = 0; |
| 388 |
|
| 389 |
/** |
| 390 |
* Returns the type of this NodeExpr |
282 |
* Returns the type of this NodeExpr |
| 391 |
* @return the type of this NodeExpr |
283 |
* @return the type of this NodeExpr |
| 392 |
**/ |
284 |
**/ |
| 393 |
virtual short getType() = 0; |
285 |
virtual short getType() = 0; |
| 394 |
|
286 |
|
| 395 |
/** |
287 |
/** |
| 396 |
* Determines whether this NodeExpr matches the given node within |
288 |
* Virtual methods from Expr |
| 397 |
* the given context |
|
|
| 398 |
**/ |
289 |
**/ |
| 399 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
290 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
| 400 |
|
291 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs) = 0; |
| 401 |
/** |
|
|
| 402 |
* Returns the String representation of this Pattern. |
| 403 |
* @param dest the String to use when creating the String |
| 404 |
* representation. The String representation will be appended to |
| 405 |
* any data in the destination String, to allow cascading calls to |
| 406 |
* other #toString() methods for Expressions. |
| 407 |
* @return the String representation of this Pattern. |
| 408 |
**/ |
| 409 |
virtual void toString(String& dest) = 0; |
292 |
virtual void toString(String& dest) = 0; |
| 410 |
|
293 |
|
| 411 |
}; //-- NodeExpr |
294 |
}; //-- NodeExpr |
|
|
| 440 |
**/ |
323 |
**/ |
| 441 |
void setName(const String& name); |
324 |
void setName(const String& name); |
| 442 |
|
325 |
|
| 443 |
//-----------------------------------/ |
|
|
| 444 |
//- Method signatures from NodeExpr -/ |
| 445 |
//-----------------------------------/ |
| 446 |
|
| 447 |
/** |
326 |
/** |
| 448 |
* Returns the default priority of this Pattern based on the given Node, |
327 |
* Virtual methods from NodeExpr |
| 449 |
* context Node, and ContextState. |
|
|
| 450 |
* If this pattern does not match the given Node under the current context Node and |
| 451 |
* ContextState then Negative Infinity is returned. |
| 452 |
**/ |
| 453 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 454 |
|
| 455 |
/** |
| 456 |
* Evaluates this Expr based on the given context node and processor state |
| 457 |
* @param context the context node for evaluation of this Expr |
| 458 |
* @param ps the ContextState containing the stack information needed |
| 459 |
* for evaluation |
| 460 |
* @return the result of the evaluation |
| 461 |
**/ |
328 |
**/ |
| 462 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
329 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 463 |
|
|
|
| 464 |
/** |
| 465 |
* Returns the type of this NodeExpr |
| 466 |
* @return the type of this NodeExpr |
| 467 |
**/ |
| 468 |
short getType(); |
330 |
short getType(); |
| 469 |
|
|
|
| 470 |
/** |
| 471 |
* Determines whether this NodeExpr matches the given node within |
| 472 |
* the given context |
| 473 |
**/ |
| 474 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
331 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 475 |
|
332 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 476 |
/** |
|
|
| 477 |
* Returns the String representation of this NodeExpr. |
| 478 |
* @param dest the String to use when creating the String |
| 479 |
* representation. The String representation will be appended to |
| 480 |
* any data in the destination String, to allow cascading calls to |
| 481 |
* other #toString() methods for Expressions. |
| 482 |
* @return the String representation of this NodeExpr. |
| 483 |
**/ |
| 484 |
virtual void toString(String& dest); |
333 |
virtual void toString(String& dest); |
| 485 |
|
334 |
|
| 486 |
private: |
335 |
private: |
|
|
| 492 |
MBool isNameWild; |
341 |
MBool isNameWild; |
| 493 |
MBool isNamespaceWild; |
342 |
MBool isNamespaceWild; |
| 494 |
|
343 |
|
| 495 |
|
|
|
| 496 |
}; //-- AttributeExpr |
344 |
}; //-- AttributeExpr |
| 497 |
|
345 |
|
| 498 |
/** |
346 |
/** |
|
|
| 521 |
* Destroys this BasicNodeExpr |
369 |
* Destroys this BasicNodeExpr |
| 522 |
**/ |
370 |
**/ |
| 523 |
virtual ~BasicNodeExpr(); |
371 |
virtual ~BasicNodeExpr(); |
| 524 |
|
372 |
|
| 525 |
//-----------------------------------/ |
|
|
| 526 |
//- Method signatures from NodeExpr -/ |
| 527 |
//-----------------------------------/ |
| 528 |
|
| 529 |
/** |
373 |
/** |
| 530 |
* Returns the default priority of this Pattern based on the given Node, |
374 |
* Sets the name of the node to match. Only availible for pi nodes |
| 531 |
* context Node, and ContextState. |
|
|
| 532 |
* If this pattern does not match the given Node under the current context Node and |
| 533 |
* ContextState then Negative Infinity is returned. |
| 534 |
**/ |
375 |
**/ |
| 535 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
376 |
void setNodeName(const String& name); |
| 536 |
|
377 |
|
| 537 |
/** |
378 |
/** |
| 538 |
* Evaluates this Expr based on the given context node and processor state |
379 |
* Virtual methods from NodeExpr |
| 539 |
* @param context the context node for evaluation of this Expr |
|
|
| 540 |
* @param ps the ContextState containing the stack information needed |
| 541 |
* for evaluation |
| 542 |
* @return the result of the evaluation |
| 543 |
**/ |
380 |
**/ |
| 544 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
381 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 545 |
|
|
|
| 546 |
/** |
| 547 |
* Returns the type of this NodeExpr |
| 548 |
* @return the type of this NodeExpr |
| 549 |
**/ |
| 550 |
short getType(); |
382 |
short getType(); |
| 551 |
|
|
|
| 552 |
/** |
| 553 |
* Determines whether this NodeExpr matches the given node within |
| 554 |
* the given context |
| 555 |
**/ |
| 556 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
383 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 557 |
|
384 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 558 |
/** |
|
|
| 559 |
* Returns the String representation of this NodeExpr. |
| 560 |
* @param dest the String to use when creating the String |
| 561 |
* representation. The String representation will be appended to |
| 562 |
* any data in the destination String, to allow cascading calls to |
| 563 |
* other #toString() methods for Expressions. |
| 564 |
* @return the String representation of this NodeExpr. |
| 565 |
**/ |
| 566 |
virtual void toString(String& dest); |
385 |
virtual void toString(String& dest); |
| 567 |
|
386 |
|
| 568 |
private: |
387 |
private: |
| 569 |
NodeExprType type; |
388 |
NodeExprType type; |
|
|
389 |
String nodeName; |
| 390 |
MBool nodeNameSet; |
| 570 |
}; //-- BasicNodeExpr |
391 |
}; //-- BasicNodeExpr |
| 571 |
|
392 |
|
| 572 |
/** |
393 |
/** |
|
|
| 597 |
**/ |
418 |
**/ |
| 598 |
void setName(const String& name); |
419 |
void setName(const String& name); |
| 599 |
|
420 |
|
| 600 |
//-----------------------------------/ |
|
|
| 601 |
//- Method signatures from NodeExpr -/ |
| 602 |
//-----------------------------------/ |
| 603 |
|
| 604 |
/** |
421 |
/** |
| 605 |
* Evaluates this Expr based on the given context node and processor state |
422 |
* Virtual methods from NodeExpr |
| 606 |
* @param context the context node for evaluation of this Expr |
|
|
| 607 |
* @param ps the ContextState containing the stack information needed |
| 608 |
* for evaluation |
| 609 |
* @return the result of the evaluation |
| 610 |
**/ |
423 |
**/ |
| 611 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
424 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 612 |
|
|
|
| 613 |
/** |
| 614 |
* Returns the default priority of this Pattern based on the given Node, |
| 615 |
* context Node, and ContextState. |
| 616 |
* If this pattern does not match the given Node under the current context Node and |
| 617 |
* ContextState then Negative Infinity is returned. |
| 618 |
**/ |
| 619 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 620 |
|
| 621 |
/** |
| 622 |
* Returns the type of this NodeExpr |
| 623 |
* @return the type of this NodeExpr |
| 624 |
**/ |
| 625 |
short getType(); |
425 |
short getType(); |
| 626 |
|
426 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 627 |
/** |
|
|
| 628 |
* Determines whether this NodeExpr matches the given node within |
| 629 |
* the given context |
| 630 |
**/ |
| 631 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
427 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 632 |
|
|
|
| 633 |
/** |
| 634 |
* Returns the String representation of this NodeExpr. |
| 635 |
* @param dest the String to use when creating the String |
| 636 |
* representation. The String representation will be appended to |
| 637 |
* any data in the destination String, to allow cascading calls to |
| 638 |
* other #toString() methods for Expressions. |
| 639 |
* @return the String representation of this NodeExpr. |
| 640 |
**/ |
| 641 |
virtual void toString(String& dest); |
428 |
virtual void toString(String& dest); |
| 642 |
|
429 |
|
| 643 |
private: |
430 |
private: |
|
|
| 655 |
}; //-- ElementExpr |
442 |
}; //-- ElementExpr |
| 656 |
|
443 |
|
| 657 |
/** |
444 |
/** |
| 658 |
* This class represents a IdentityExpr, which only matches a node |
|
|
| 659 |
* if it is equal to the context node |
| 660 |
**/ |
| 661 |
class IdentityExpr : public Expr { |
| 662 |
|
| 663 |
public: |
| 664 |
|
| 665 |
//------------------/ |
| 666 |
//- Public Methods -/ |
| 667 |
//------------------/ |
| 668 |
|
| 669 |
/** |
| 670 |
* Evaluates this Expr based on the given context node and processor state |
| 671 |
* @param context the context node for evaluation of this Expr |
| 672 |
* @param ps the ContextState containing the stack information needed |
| 673 |
* for evaluation |
| 674 |
* @return the result of the evaluation |
| 675 |
**/ |
| 676 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 677 |
|
| 678 |
/** |
| 679 |
* Returns the String representation of this NodeExpr. |
| 680 |
* @param dest the String to use when creating the String |
| 681 |
* representation. The String representation will be appended to |
| 682 |
* any data in the destination String, to allow cascading calls to |
| 683 |
* other #toString() methods for Expressions. |
| 684 |
* @return the String representation of this NodeExpr. |
| 685 |
**/ |
| 686 |
virtual void toString(String& dest); |
| 687 |
|
| 688 |
}; //-- IdentityExpr |
| 689 |
|
| 690 |
/** |
| 691 |
* This class represents a ParentExpr, which only selects a node |
| 692 |
* if it is equal to the context node's parent |
| 693 |
**/ |
| 694 |
class ParentExpr : public Expr { |
| 695 |
|
| 696 |
public: |
| 697 |
|
| 698 |
//------------------/ |
| 699 |
//- Public Methods -/ |
| 700 |
//------------------/ |
| 701 |
|
| 702 |
/** |
| 703 |
* Evaluates this Expr based on the given context node and processor state |
| 704 |
* @param context the context node for evaluation of this Expr |
| 705 |
* @param ps the ContextState containing the stack information needed |
| 706 |
* for evaluation |
| 707 |
* @return the result of the evaluation |
| 708 |
**/ |
| 709 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 710 |
|
| 711 |
|
| 712 |
/** |
| 713 |
* Returns the String representation of this NodeExpr. |
| 714 |
* @param dest the String to use when creating the String |
| 715 |
* representation. The String representation will be appended to |
| 716 |
* any data in the destination String, to allow cascading calls to |
| 717 |
* other #toString() methods for Expressions. |
| 718 |
* @return the String representation of this NodeExpr. |
| 719 |
**/ |
| 720 |
virtual void toString(String& dest); |
| 721 |
|
| 722 |
}; //-- ParentExpr |
| 723 |
|
| 724 |
/** |
| 725 |
* This class represents a TextExpr, which only matches any text node |
445 |
* This class represents a TextExpr, which only matches any text node |
| 726 |
**/ |
446 |
**/ |
| 727 |
class TextExpr : public NodeExpr { |
447 |
class TextExpr : public NodeExpr { |
|
|
| 729 |
public: |
449 |
public: |
| 730 |
|
450 |
|
| 731 |
//------------------/ |
451 |
//------------------/ |
| 732 |
//- Public Methods -/ |
452 |
//- Public Methods -/ |
| 733 |
//------------------/ |
453 |
//------------------/ |
| 734 |
|
|
|
| 735 |
/** |
| 736 |
* Evaluates this Expr based on the given context node and processor state |
| 737 |
* @param context the context node for evaluation of this Expr |
| 738 |
* @param ps the ContextState containing the stack information needed |
| 739 |
* for evaluation |
| 740 |
* @return the result of the evaluation |
| 741 |
**/ |
| 742 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 743 |
|
| 744 |
/** |
| 745 |
* Returns the default priority of this Pattern based on the given Node, |
| 746 |
* context Node, and ContextState. |
| 747 |
* If this pattern does not match the given Node under the current context Node and |
| 748 |
* ContextState then Negative Infinity is returned. |
| 749 |
**/ |
| 750 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 751 |
|
| 752 |
/** |
| 753 |
* Returns the type of this NodeExpr |
| 754 |
* @return the type of this NodeExpr |
| 755 |
**/ |
| 756 |
virtual short getType(); |
| 757 |
|
| 758 |
/** |
| 759 |
* Determines whether this NodeExpr matches the given node within |
| 760 |
* the given context |
| 761 |
**/ |
| 762 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 763 |
|
| 764 |
|
454 |
|
| 765 |
/** |
455 |
/** |
| 766 |
* Returns the String representation of this NodeExpr. |
456 |
* Virtual methods from NodeExpr |
| 767 |
* @param dest the String to use when creating the String |
|
|
| 768 |
* representation. The String representation will be appended to |
| 769 |
* any data in the destination String, to allow cascading calls to |
| 770 |
* other #toString() methods for Expressions. |
| 771 |
* @return the String representation of this NodeExpr. |
| 772 |
**/ |
457 |
**/ |
|
|
458 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 459 |
virtual short getType(); |
| 460 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 461 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 773 |
virtual void toString(String& dest); |
462 |
virtual void toString(String& dest); |
| 774 |
|
463 |
|
| 775 |
}; //-- TextExpr |
464 |
}; //-- TextExpr |
|
|
| 827 |
List predicates; |
516 |
List predicates; |
| 828 |
}; //-- PredicateList |
517 |
}; //-- PredicateList |
| 829 |
|
518 |
|
| 830 |
class LocationStep : public PredicateList, public PatternExpr { |
519 |
class LocationStep : public PredicateList, public Expr { |
| 831 |
|
520 |
|
| 832 |
public: |
521 |
public: |
| 833 |
|
522 |
|
|
|
| 849 |
SELF_AXIS |
538 |
SELF_AXIS |
| 850 |
}; |
539 |
}; |
| 851 |
|
540 |
|
| 852 |
|
|
|
| 853 |
/** |
541 |
/** |
| 854 |
* Creates a new LocationStep using the default Axis Identifier and no |
542 |
* Creates a new LocationStep using the default Axis Identifier and no |
| 855 |
* NodeExpr (which matches nothing) |
543 |
* NodeExpr (which matches nothing) |
|
|
| 887 |
**/ |
575 |
**/ |
| 888 |
void setNodeExpr(NodeExpr* nodeExpr); |
576 |
void setNodeExpr(NodeExpr* nodeExpr); |
| 889 |
|
577 |
|
| 890 |
//------------------------------------/ |
|
|
| 891 |
//- Virtual methods from PatternExpr -/ |
| 892 |
//------------------------------------/ |
| 893 |
|
| 894 |
/** |
578 |
/** |
| 895 |
* Evaluates this Expr based on the given context node and processor state |
579 |
* Virtual methods from Expr |
| 896 |
* @param context the context node for evaluation of this Expr |
|
|
| 897 |
* @param ps the ContextState containing the stack information needed |
| 898 |
* for evaluation |
| 899 |
* @return the result of the evaluation |
| 900 |
**/ |
580 |
**/ |
| 901 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
581 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 902 |
|
|
|
| 903 |
/** |
| 904 |
* Returns the default priority of this Pattern based on the given Node, |
| 905 |
* context Node, and ContextState. |
| 906 |
* If this pattern does not match the given Node under the current context Node and |
| 907 |
* ContextState then Negative Infinity is returned. |
| 908 |
**/ |
| 909 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 910 |
|
| 911 |
/** |
| 912 |
* Determines whether this PatternExpr matches the given node within |
| 913 |
* the given context |
| 914 |
**/ |
| 915 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
582 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 916 |
|
583 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 917 |
/** |
|
|
| 918 |
* Returns the String representation of this PatternExpr. |
| 919 |
* @param dest the String to use when creating the String |
| 920 |
* representation. The String representation will be appended to |
| 921 |
* any data in the destination String, to allow cascading calls to |
| 922 |
* other #toString() methods for Expressions. |
| 923 |
* @return the String representation of this PatternExpr. |
| 924 |
**/ |
| 925 |
virtual void toString(String& dest); |
584 |
virtual void toString(String& dest); |
| 926 |
|
585 |
|
| 927 |
private: |
586 |
private: |
| 928 |
|
587 |
|
| 929 |
NodeExpr* nodeExpr; |
588 |
NodeExpr* nodeExpr; |
| 930 |
short axisIdentifier; |
589 |
short axisIdentifier; |
| 931 |
|
590 |
|
| 932 |
void fromDescendants(Node* context, ContextState* cs, NodeSet* nodes); |
591 |
void fromDescendants(Node* context, ContextState* cs, NodeSet* nodes); |
| 933 |
void fromDescendantsRev(Node* context, ContextState* cs, NodeSet* nodes); |
592 |
void fromDescendantsRev(Node* context, ContextState* cs, NodeSet* nodes); |
|
|
| 935 |
}; //-- LocationStep |
594 |
}; //-- LocationStep |
| 936 |
|
595 |
|
| 937 |
|
596 |
|
| 938 |
class FilterExpr : public PredicateList, public PatternExpr { |
597 |
class FilterExpr : public PredicateList, public Expr { |
| 939 |
|
598 |
|
| 940 |
public: |
599 |
public: |
| 941 |
|
600 |
|
|
|
| 962 |
**/ |
621 |
**/ |
| 963 |
void setExpr(Expr* expr); |
622 |
void setExpr(Expr* expr); |
| 964 |
|
623 |
|
| 965 |
//------------------------------------/ |
|
|
| 966 |
//- Virtual methods from PatternExpr -/ |
| 967 |
//------------------------------------/ |
| 968 |
|
| 969 |
/** |
624 |
/** |
| 970 |
* Evaluates this Expr based on the given context node and processor state |
625 |
* Virtual methods from Expr |
| 971 |
* @param context the context node for evaluation of this Expr |
|
|
| 972 |
* @param ps the ContextState containing the stack information needed |
| 973 |
* for evaluation |
| 974 |
* @return the result of the evaluation |
| 975 |
**/ |
626 |
**/ |
| 976 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
627 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 977 |
|
|
|
| 978 |
/** |
| 979 |
* Returns the default priority of this Pattern based on the given Node, |
| 980 |
* context Node, and ContextState. |
| 981 |
* If this pattern does not match the given Node under the current context Node and |
| 982 |
* ContextState then Negative Infinity is returned. |
| 983 |
**/ |
| 984 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 985 |
|
| 986 |
/** |
| 987 |
* Determines whether this PatternExpr matches the given node within |
| 988 |
* the given context |
| 989 |
**/ |
| 990 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
628 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 991 |
|
629 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 992 |
/** |
|
|
| 993 |
* Returns the String representation of this PatternExpr. |
| 994 |
* @param dest the String to use when creating the String |
| 995 |
* representation. The String representation will be appended to |
| 996 |
* any data in the destination String, to allow cascading calls to |
| 997 |
* other #toString() methods for Expressions. |
| 998 |
* @return the String representation of this PatternExpr. |
| 999 |
**/ |
| 1000 |
virtual void toString(String& dest); |
630 |
virtual void toString(String& dest); |
| 1001 |
|
631 |
|
| 1002 |
private: |
632 |
private: |
| 1003 |
|
633 |
|
| 1004 |
Expr* expr; |
634 |
Expr* expr; |
| 1005 |
|
635 |
|
| 1006 |
}; //-- FilterExpr |
636 |
}; //-- FilterExpr |
| 1007 |
|
637 |
|
|
|
| 1015 |
~NumberExpr(); |
645 |
~NumberExpr(); |
| 1016 |
|
646 |
|
| 1017 |
/** |
647 |
/** |
| 1018 |
* Evaluates this Expr based on the given context node and processor state |
648 |
* Virtual methods from Expr |
| 1019 |
* @param context the context node for evaluation of this Expr |
|
|
| 1020 |
* @param ps the ContextState containing the stack information needed |
| 1021 |
* for evaluation |
| 1022 |
* @return the result of the evaluation |
| 1023 |
**/ |
649 |
**/ |
| 1024 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
650 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1025 |
|
|
|
| 1026 |
/** |
| 1027 |
* Returns the String representation of this Expr. |
| 1028 |
* @param dest the String to use when creating the String |
| 1029 |
* representation. The String representation will be appended to |
| 1030 |
* any data in the destination String, to allow cascading calls to |
| 1031 |
* other #toString() methods for Expressions. |
| 1032 |
* @return the String representation of this Expr. |
| 1033 |
**/ |
| 1034 |
virtual void toString(String& str); |
651 |
virtual void toString(String& str); |
| 1035 |
|
652 |
|
| 1036 |
private: |
653 |
private: |
|
|
| 1052 |
~StringExpr(); |
669 |
~StringExpr(); |
| 1053 |
|
670 |
|
| 1054 |
/** |
671 |
/** |
| 1055 |
* Evaluates this Expr based on the given context node and processor state |
672 |
* Virtual methods from Expr |
| 1056 |
* @param context the context node for evaluation of this Expr |
|
|
| 1057 |
* @param ps the ContextState containing the stack information needed |
| 1058 |
* for evaluation |
| 1059 |
* @return the result of the evaluation |
| 1060 |
**/ |
673 |
**/ |
| 1061 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
674 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1062 |
|
|
|
| 1063 |
/** |
| 1064 |
* Returns the String representation of this Expr. |
| 1065 |
* @param dest the String to use when creating the String |
| 1066 |
* representation. The String representation will be appended to |
| 1067 |
* any data in the destination String, to allow cascading calls to |
| 1068 |
* other #toString() methods for Expressions. |
| 1069 |
* @return the String representation of this Expr. |
| 1070 |
**/ |
| 1071 |
virtual void toString(String& str); |
675 |
virtual void toString(String& str); |
| 1072 |
|
676 |
|
| 1073 |
private: |
677 |
private: |
|
|
| 1106 |
|
710 |
|
| 1107 |
|
711 |
|
| 1108 |
/** |
712 |
/** |
| 1109 |
* Evaluates this Expr based on the given context node and processor state |
713 |
* Virtual methods from Expr |
| 1110 |
* @param context the context node for evaluation of this Expr |
|
|
| 1111 |
* @param ps the ContextState containing the stack information needed |
| 1112 |
* for evaluation |
| 1113 |
* @return the result of the evaluation |
| 1114 |
**/ |
714 |
**/ |
| 1115 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
715 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1116 |
|
|
|
| 1117 |
/** |
| 1118 |
* Returns the String representation of this Expr. |
| 1119 |
* @param dest the String to use when creating the String |
| 1120 |
* representation. The String representation will be appended to |
| 1121 |
* any data in the destination String, to allow cascading calls to |
| 1122 |
* other #toString() methods for Expressions. |
| 1123 |
* @return the String representation of this Expr. |
| 1124 |
**/ |
| 1125 |
virtual void toString(String& str); |
716 |
virtual void toString(String& str); |
| 1126 |
|
717 |
|
| 1127 |
|
|
|
| 1128 |
|
| 1129 |
private: |
718 |
private: |
| 1130 |
short op; |
719 |
short op; |
| 1131 |
Expr* leftExpr; |
720 |
Expr* leftExpr; |
|
|
| 1133 |
}; //-- AdditiveExpr |
722 |
}; //-- AdditiveExpr |
| 1134 |
|
723 |
|
| 1135 |
/** |
724 |
/** |
|
|
725 |
* Represents an UnaryExpr. Returns the negative value of it's expr. |
| 726 |
**/ |
| 727 |
class UnaryExpr : public Expr { |
| 728 |
|
| 729 |
public: |
| 730 |
|
| 731 |
UnaryExpr(); |
| 732 |
UnaryExpr(Expr* expr); |
| 733 |
~UnaryExpr(); |
| 734 |
|
| 735 |
/** |
| 736 |
* Sets the expression to negate |
| 737 |
**/ |
| 738 |
void setExpr(Expr* expr); |
| 739 |
|
| 740 |
/** |
| 741 |
* Virtual methods from Expr |
| 742 |
**/ |
| 743 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 744 |
virtual void toString(String& str); |
| 745 |
|
| 746 |
private: |
| 747 |
Expr* expr; |
| 748 |
}; //-- UnaryExpr |
| 749 |
|
| 750 |
/** |
| 1136 |
* Represents a BooleanExpr, a binary expression that |
751 |
* Represents a BooleanExpr, a binary expression that |
| 1137 |
* performs a boolean operation between it's lvalue and rvalue:<BR/> |
752 |
* performs a boolean operation between it's lvalue and rvalue:<BR/> |
| 1138 |
**/ |
753 |
**/ |
|
|
| 1148 |
~BooleanExpr(); |
763 |
~BooleanExpr(); |
| 1149 |
|
764 |
|
| 1150 |
/** |
765 |
/** |
| 1151 |
* Sets the left side of this AdditiveExpr |
766 |
* Sets the left side of this BooleanExpr |
| 1152 |
**/ |
767 |
**/ |
| 1153 |
void setLeftExpr(Expr* leftExpr); |
768 |
void setLeftExpr(Expr* leftExpr); |
| 1154 |
|
769 |
|
| 1155 |
/** |
770 |
/** |
| 1156 |
* Sets the right side of this AdditiveExpr |
771 |
* Sets the right side of this BooleanExpr |
| 1157 |
**/ |
772 |
**/ |
| 1158 |
void setRightExpr(Expr* rightExpr); |
773 |
void setRightExpr(Expr* rightExpr); |
| 1159 |
|
774 |
|
| 1160 |
|
775 |
|
| 1161 |
/** |
776 |
/** |
| 1162 |
* Evaluates this Expr based on the given context node and processor state |
777 |
* Virtual methods from Expr |
| 1163 |
* @param context the context node for evaluation of this Expr |
|
|
| 1164 |
* @param ps the ContextState containing the stack information needed |
| 1165 |
* for evaluation |
| 1166 |
* @return the result of the evaluation |
| 1167 |
**/ |
778 |
**/ |
| 1168 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
779 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1169 |
|
|
|
| 1170 |
/** |
| 1171 |
* Returns the String representation of this Expr. |
| 1172 |
* @param dest the String to use when creating the String |
| 1173 |
* representation. The String representation will be appended to |
| 1174 |
* any data in the destination String, to allow cascading calls to |
| 1175 |
* other #toString() methods for Expressions. |
| 1176 |
* @return the String representation of this Expr. |
| 1177 |
**/ |
| 1178 |
virtual void toString(String& str); |
780 |
virtual void toString(String& str); |
| 1179 |
|
781 |
|
| 1180 |
|
|
|
| 1181 |
|
| 1182 |
private: |
782 |
private: |
| 1183 |
short op; |
783 |
short op; |
| 1184 |
Expr* leftExpr; |
784 |
Expr* leftExpr; |
|
|
| 1215 |
**/ |
815 |
**/ |
| 1216 |
void setRightExpr(Expr* rightExpr); |
816 |
void setRightExpr(Expr* rightExpr); |
| 1217 |
|
817 |
|
| 1218 |
|
|
|
| 1219 |
/** |
818 |
/** |
| 1220 |
* Evaluates this Expr based on the given context node and processor state |
819 |
* Virtual methods from Expr |
| 1221 |
* @param context the context node for evaluation of this Expr |
|
|
| 1222 |
* @param ps the ContextState containing the stack information needed |
| 1223 |
* for evaluation |
| 1224 |
* @return the result of the evaluation |
| 1225 |
**/ |
820 |
**/ |
| 1226 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
821 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1227 |
|
|
|
| 1228 |
/** |
| 1229 |
* Returns the String representation of this Expr. |
| 1230 |
* @param dest the String to use when creating the String |
| 1231 |
* representation. The String representation will be appended to |
| 1232 |
* any data in the destination String, to allow cascading calls to |
| 1233 |
* other #toString() methods for Expressions. |
| 1234 |
* @return the String representation of this Expr. |
| 1235 |
**/ |
| 1236 |
virtual void toString(String& str); |
822 |
virtual void toString(String& str); |
| 1237 |
|
823 |
|
| 1238 |
|
|
|
| 1239 |
|
| 1240 |
private: |
824 |
private: |
| 1241 |
short op; |
825 |
short op; |
| 1242 |
Expr* leftExpr; |
826 |
Expr* leftExpr; |
|
|
| 1273 |
~RelationalExpr(); |
857 |
~RelationalExpr(); |
| 1274 |
|
858 |
|
| 1275 |
/** |
859 |
/** |
| 1276 |
* Evaluates this Expr based on the given context node and processor state |
860 |
* Virtual methods from Expr |
| 1277 |
* @param context the context node for evaluation of this Expr |
|
|
| 1278 |
* @param ps the ContextState containing the stack information needed |
| 1279 |
* for evaluation |
| 1280 |
* @return the result of the evaluation |
| 1281 |
**/ |
861 |
**/ |
| 1282 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
862 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1283 |
|
|
|
| 1284 |
/** |
| 1285 |
* Returns the String representation of this Expr. |
| 1286 |
* @param dest the String to use when creating the String |
| 1287 |
* representation. The String representation will be appended to |
| 1288 |
* any data in the destination String, to allow cascading calls to |
| 1289 |
* other #toString() methods for Expressions. |
| 1290 |
* @return the String representation of this Expr. |
| 1291 |
**/ |
| 1292 |
virtual void toString(String& str); |
863 |
virtual void toString(String& str); |
| 1293 |
|
864 |
|
| 1294 |
|
|
|
| 1295 |
|
| 1296 |
private: |
865 |
private: |
| 1297 |
short op; |
866 |
short op; |
| 1298 |
Expr* leftExpr; |
867 |
Expr* leftExpr; |
|
|
| 1320 |
void setName(const String& name); |
889 |
void setName(const String& name); |
| 1321 |
|
890 |
|
| 1322 |
/** |
891 |
/** |
| 1323 |
* Evaluates this Expr based on the given context node and processor state |
892 |
* Virtual methods from Expr |
| 1324 |
* @param context the context node for evaluation of this Expr |
|
|
| 1325 |
* @param ps the ContextState containing the stack information needed |
| 1326 |
* for evaluation |
| 1327 |
* @return the result of the evaluation |
| 1328 |
**/ |
893 |
**/ |
| 1329 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
894 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1330 |
|
|
|
| 1331 |
/** |
| 1332 |
* Returns the String representation of this Expr. |
| 1333 |
* @param dest the String to use when creating the String |
| 1334 |
* representation. The String representation will be appended to |
| 1335 |
* any data in the destination String, to allow cascading calls to |
| 1336 |
* other #toString() methods for Expressions. |
| 1337 |
* @return the String representation of this Expr. |
| 1338 |
**/ |
| 1339 |
virtual void toString(String& str); |
895 |
virtual void toString(String& str); |
| 1340 |
|
896 |
|
| 1341 |
private: |
897 |
private: |
|
|
| 1346 |
/** |
902 |
/** |
| 1347 |
* Represents a PathExpr |
903 |
* Represents a PathExpr |
| 1348 |
**/ |
904 |
**/ |
| 1349 |
class PathExpr : public PatternExpr { |
905 |
class PathExpr : public Expr { |
| 1350 |
|
906 |
|
| 1351 |
public: |
907 |
public: |
| 1352 |
|
908 |
|
|
|
| 1361 |
PathExpr(); |
917 |
PathExpr(); |
| 1362 |
|
918 |
|
| 1363 |
/** |
919 |
/** |
| 1364 |
* Destructor, will delete all Pattern Expressions |
920 |
* Destructor, will delete all Expressions |
| 1365 |
**/ |
921 |
**/ |
| 1366 |
virtual ~PathExpr(); |
922 |
virtual ~PathExpr(); |
| 1367 |
|
923 |
|
| 1368 |
/** |
924 |
/** |
| 1369 |
* Adds the PatternExpr to this PathExpr |
925 |
* Adds the Expr to this PathExpr |
| 1370 |
* @param expr the Expr to add to this PathExpr |
926 |
* @param expr the Expr to add to this PathExpr |
| 1371 |
* @param index the index at which to add the given Expr |
927 |
* @param index the index at which to add the given Expr |
| 1372 |
**/ |
928 |
**/ |
| 1373 |
void addPatternExpr(int index, PatternExpr* expr, short ancestryOp); |
929 |
void addExpr(int index, Expr* expr, short ancestryOp); |
| 1374 |
|
930 |
|
| 1375 |
/** |
931 |
/** |
| 1376 |
* Adds the PatternExpr to this PathExpr |
932 |
* Adds the Expr to this PathExpr |
| 1377 |
* @param expr the Expr to add to this PathExpr |
933 |
* @param expr the Expr to add to this PathExpr |
| 1378 |
**/ |
934 |
**/ |
| 1379 |
void addPatternExpr(PatternExpr* expr, short ancestryOp); |
935 |
void addExpr(Expr* expr, short ancestryOp); |
| 1380 |
|
936 |
|
| 1381 |
virtual MBool isAbsolute(); |
937 |
virtual MBool isAbsolute(); |
| 1382 |
|
938 |
|
| 1383 |
//------------------------------------/ |
|
|
| 1384 |
//- Virtual methods from PatternExpr -/ |
| 1385 |
//------------------------------------/ |
| 1386 |
|
| 1387 |
/** |
939 |
/** |
| 1388 |
* Evaluates this Expr based on the given context node and processor state |
940 |
* Virtual methods from Expr |
| 1389 |
* @param context the context node for evaluation of this Expr |
|
|
| 1390 |
* @param ps the ContextState containing the stack information needed |
| 1391 |
* for evaluation |
| 1392 |
* @return the result of the evaluation |
| 1393 |
**/ |
941 |
**/ |
| 1394 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
942 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1395 |
|
|
|
| 1396 |
/** |
| 1397 |
* Returns the default priority of this Pattern based on the given Node, |
| 1398 |
* context Node, and ContextState. |
| 1399 |
* If this pattern does not match the given Node under the current context Node and |
| 1400 |
* ContextState then Negative Infinity is returned. |
| 1401 |
**/ |
| 1402 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1403 |
|
| 1404 |
/** |
| 1405 |
* Determines whether this PatternExpr matches the given node within |
| 1406 |
* the given context |
| 1407 |
**/ |
| 1408 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
943 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1409 |
|
944 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1410 |
/** |
|
|
| 1411 |
* Returns the String representation of this PatternExpr. |
| 1412 |
* @param dest the String to use when creating the String |
| 1413 |
* representation. The String representation will be appended to |
| 1414 |
* any data in the destination String, to allow cascading calls to |
| 1415 |
* other #toString() methods for Expressions. |
| 1416 |
* @return the String representation of this PatternExpr. |
| 1417 |
**/ |
| 1418 |
virtual void toString(String& dest); |
945 |
virtual void toString(String& dest); |
| 1419 |
|
946 |
|
| 1420 |
private: |
947 |
private: |
| 1421 |
|
948 |
|
| 1422 |
struct PathExprItem { |
949 |
struct PathExprItem { |
| 1423 |
PatternExpr* pExpr; |
950 |
Expr* expr; |
| 1424 |
short ancestryOp; |
951 |
short ancestryOp; |
| 1425 |
}; |
952 |
}; |
| 1426 |
|
953 |
|
|
|
| 1428 |
|
955 |
|
| 1429 |
/** |
956 |
/** |
| 1430 |
* Selects from the descendants of the context node |
957 |
* Selects from the descendants of the context node |
| 1431 |
* all nodes that match the PatternExpr |
958 |
* all nodes that match the Expr |
| 1432 |
* -- this will be moving to a Utility class |
959 |
* -- this will be moving to a Utility class |
| 1433 |
**/ |
960 |
**/ |
| 1434 |
void evalDescendants(PatternExpr* pExpr, |
961 |
void evalDescendants(Expr* expr, |
| 1435 |
Node* context, |
962 |
Node* context, |
| 1436 |
ContextState* cs, |
963 |
ContextState* cs, |
| 1437 |
NodeSet* nodes); |
964 |
NodeSet* resNodes); |
| 1438 |
|
965 |
|
| 1439 |
}; //-- PathExpr |
966 |
}; //-- PathExpr |
| 1440 |
|
967 |
|
|
|
| 1450 |
//------------------/ |
977 |
//------------------/ |
| 1451 |
|
978 |
|
| 1452 |
/** |
979 |
/** |
| 1453 |
* Evaluates this Expr based on the given context node and processor state |
980 |
* Virtual methods from Expr |
| 1454 |
* @param context the context node for evaluation of this Expr |
|
|
| 1455 |
* @param ps the ContextState containing the stack information needed |
| 1456 |
* for evaluation |
| 1457 |
* @return the result of the evaluation |
| 1458 |
**/ |
981 |
**/ |
| 1459 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
982 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1460 |
|
|
|
| 1461 |
virtual MBool isAbsolute(); |
| 1462 |
|
| 1463 |
/** |
| 1464 |
* Returns the default priority of this Pattern based on the given Node, |
| 1465 |
* context Node, and ContextState. |
| 1466 |
* If this pattern does not match the given Node under the current context Node and |
| 1467 |
* ContextState then Negative Infinity is returned. |
| 1468 |
**/ |
| 1469 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1470 |
|
| 1471 |
/** |
| 1472 |
* Determines whether this NodeExpr matches the given node within |
| 1473 |
* the given context |
| 1474 |
**/ |
| 1475 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
983 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1476 |
|
984 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1477 |
/** |
|
|
| 1478 |
* Returns the String representation of this PatternExpr. |
| 1479 |
* @param dest the String to use when creating the String |
| 1480 |
* representation. The String representation will be appended to |
| 1481 |
* any data in the destination String, to allow cascading calls to |
| 1482 |
* other #toString() methods for Expressions. |
| 1483 |
* @return the String representation of this PatternExpr. |
| 1484 |
**/ |
| 1485 |
virtual void toString(String& dest); |
985 |
virtual void toString(String& dest); |
| 1486 |
|
986 |
|
|
|
987 |
virtual MBool isAbsolute(); |
| 988 |
|
| 1487 |
|
989 |
|
| 1488 |
}; //-- RootExpr |
990 |
}; //-- RootExpr |
| 1489 |
|
991 |
|
| 1490 |
/** |
992 |
/** |
| 1491 |
* Represents a UnionExpr |
993 |
* Represents a UnionExpr |
| 1492 |
**/ |
994 |
**/ |
| 1493 |
class UnionExpr : public PatternExpr { |
995 |
class UnionExpr : public Expr { |
| 1494 |
|
996 |
|
| 1495 |
public: |
997 |
public: |
| 1496 |
|
998 |
|
|
|
| 1508 |
* Adds the PathExpr to this UnionExpr |
1010 |
* Adds the PathExpr to this UnionExpr |
| 1509 |
* @param expr the Expr to add to this UnionExpr |
1011 |
* @param expr the Expr to add to this UnionExpr |
| 1510 |
**/ |
1012 |
**/ |
| 1511 |
void addPathExpr(PathExpr* expr); |
1013 |
void addExpr(Expr* expr); |
| 1512 |
|
1014 |
|
| 1513 |
/** |
1015 |
/** |
| 1514 |
* Adds the PathExpr to this UnionExpr at the specified index |
1016 |
* Adds the PathExpr to this UnionExpr at the specified index |
| 1515 |
* @param expr the Expr to add to this UnionExpr |
1017 |
* @param expr the Expr to add to this UnionExpr |
| 1516 |
**/ |
1018 |
**/ |
| 1517 |
void addPathExpr(int index, PathExpr* expr); |
1019 |
void addExpr(int index, Expr* expr); |
| 1518 |
|
|
|
| 1519 |
//------------------------------------/ |
| 1520 |
//- Virtual methods from PatternExpr -/ |
| 1521 |
//------------------------------------/ |
| 1522 |
|
1020 |
|
| 1523 |
/** |
1021 |
/** |
| 1524 |
* Evaluates this Expr based on the given context node and processor state |
1022 |
* Virtual methods from Expr |
| 1525 |
* @param context the context node for evaluation of this Expr |
|
|
| 1526 |
* @param ps the ContextState containing the stack information needed |
| 1527 |
* for evaluation |
| 1528 |
* @return the result of the evaluation |
| 1529 |
**/ |
1023 |
**/ |
| 1530 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
1024 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 1531 |
|
|
|
| 1532 |
/** |
| 1533 |
* Returns the default priority of this Pattern based on the given Node, |
| 1534 |
* context Node, and ContextState. |
| 1535 |
* If this pattern does not match the given Node under the current context Node and |
| 1536 |
* ContextState then Negative Infinity is returned. |
| 1537 |
**/ |
| 1538 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1539 |
|
| 1540 |
/** |
| 1541 |
* Determines whether this PatternExpr matches the given node within |
| 1542 |
* the given context |
| 1543 |
**/ |
| 1544 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
1025 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1545 |
|
1026 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 1546 |
/** |
|
|
| 1547 |
* Returns the String representation of this PatternExpr. |
| 1548 |
* @param dest the String to use when creating the String |
| 1549 |
* representation. The String representation will be appended to |
| 1550 |
* any data in the destination String, to allow cascading calls to |
| 1551 |
* other #toString() methods for Expressions. |
| 1552 |
* @return the String representation of this PatternExpr. |
| 1553 |
**/ |
| 1554 |
virtual void toString(String& dest); |
1027 |
virtual void toString(String& dest); |
| 1555 |
|
1028 |
|
| 1556 |
private: |
1029 |
private: |