|
|
|
|
| 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 |
**/ |
|
|
| 115 |
/** |
122 |
/** |
| 116 |
* Virtual destructor, important for subclasses |
123 |
* Virtual destructor, important for subclasses |
| 117 |
**/ |
124 |
**/ |
| 118 |
virtual ~Expr() {}; |
125 |
virtual ~Expr(); |
| 119 |
|
126 |
|
| 120 |
/** |
127 |
/** |
| 121 |
* Evaluates this Expr based on the given context node and processor state |
128 |
* Evaluates this Expr based on the given context node and processor state |
|
|
| 127 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
134 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
| 128 |
|
135 |
|
| 129 |
/** |
136 |
/** |
|
|
137 |
* Determines whether this Expr matches the given node within |
| 138 |
* the given context |
| 139 |
**/ |
| 140 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 141 |
|
| 142 |
/** |
| 143 |
* Returns the default priority of this Expr based on the given Node, |
| 144 |
* context Node, and ContextState. |
| 145 |
**/ |
| 146 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 147 |
|
| 148 |
/** |
| 130 |
* Returns the String representation of this Expr. |
149 |
* Returns the String representation of this Expr. |
| 131 |
* @param dest the String to use when creating the String |
150 |
* @param dest the String to use when creating the String |
| 132 |
* representation. The String representation will be appended to |
151 |
* representation. The String representation will be appended to |
|
|
| 138 |
|
157 |
|
| 139 |
}; //-- Expr |
158 |
}; //-- Expr |
| 140 |
|
159 |
|
| 141 |
|
|
|
| 142 |
/** |
160 |
/** |
| 143 |
* This class represents a FunctionCall as defined by the XPath 1.0 |
161 |
* This class represents a FunctionCall as defined by the XPath 1.0 |
| 144 |
* Recommendation. |
162 |
* Recommendation. |
|
|
| 149 |
|
167 |
|
| 150 |
static const String INVALID_PARAM_COUNT; |
168 |
static const String INVALID_PARAM_COUNT; |
| 151 |
|
169 |
|
| 152 |
|
|
|
| 153 |
virtual ~FunctionCall(); |
170 |
virtual ~FunctionCall(); |
| 154 |
|
171 |
|
| 155 |
/** |
172 |
/** |
| 156 |
* Adds the given parameter to this FunctionCall's parameter list |
173 |
* Virtual methods from Expr |
| 157 |
* @param expr the Expr to add to this FunctionCall's parameter list |
|
|
| 158 |
**/ |
174 |
**/ |
| 159 |
void addParam(Expr* expr); |
175 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
|
|
176 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 177 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 178 |
virtual void toString(String& dest); |
| 160 |
|
179 |
|
| 161 |
/** |
180 |
/** |
| 162 |
* Evaluates this Expr based on the given context node and processor state |
181 |
* Adds the given parameter to this FunctionCall's parameter list |
| 163 |
* @param context the context node for evaluation of this Expr |
182 |
* @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 |
**/ |
183 |
**/ |
| 168 |
virtual ExprResult* evaluate(Node* context, ContextState* cs) = 0; |
184 |
void addParam(Expr* expr); |
| 169 |
|
185 |
|
| 170 |
/** |
186 |
/** |
| 171 |
* Returns the name of this FunctionCall |
187 |
* Returns the name of this FunctionCall |
|
|
| 184 |
* @param name the name of this Function |
200 |
* @param name the name of this Function |
| 185 |
**/ |
201 |
**/ |
| 186 |
void setName(const String& name); |
202 |
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 |
|
203 |
|
| 197 |
|
204 |
|
| 198 |
protected: |
205 |
protected: |
|
|
| 221 |
String name; |
228 |
String name; |
| 222 |
}; //-- FunctionCall |
229 |
}; //-- FunctionCall |
| 223 |
|
230 |
|
| 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 |
|
| 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 |
|
231 |
|
| 263 |
|
|
|
| 264 |
/** |
232 |
/** |
| 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 |
233 |
* Represents an AttributeValueTemplate |
| 316 |
**/ |
234 |
**/ |
| 317 |
class AttributeValueTemplate: public Expr { |
235 |
class AttributeValueTemplate: public Expr { |
|
|
| 328 |
void addExpr(Expr* expr); |
246 |
void addExpr(Expr* expr); |
| 329 |
|
247 |
|
| 330 |
/** |
248 |
/** |
| 331 |
* Evaluates this Expr based on the given context node and processor state |
249 |
* 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 |
**/ |
250 |
**/ |
| 337 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
251 |
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); |
252 |
virtual void toString(String& str); |
| 348 |
|
253 |
|
| 349 |
private: |
254 |
private: |
|
|
| 355 |
* This class represents a NodeTestExpr as defined by the XSL |
260 |
* This class represents a NodeTestExpr as defined by the XSL |
| 356 |
* Working Draft |
261 |
* Working Draft |
| 357 |
**/ |
262 |
**/ |
| 358 |
class NodeExpr : public PatternExpr { |
263 |
class NodeExpr : public Expr { |
| 359 |
|
264 |
|
| 360 |
public: |
265 |
public: |
| 361 |
|
266 |
|
|
|
| 379 |
//------------------/ |
284 |
//------------------/ |
| 380 |
|
285 |
|
| 381 |
/** |
286 |
/** |
| 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 |
287 |
* Returns the type of this NodeExpr |
| 391 |
* @return the type of this NodeExpr |
288 |
* @return the type of this NodeExpr |
| 392 |
**/ |
289 |
**/ |
| 393 |
virtual short getType() = 0; |
290 |
virtual short getType() = 0; |
| 394 |
|
291 |
|
| 395 |
/** |
292 |
/** |
| 396 |
* Determines whether this NodeExpr matches the given node within |
293 |
* Virtual methods from Expr |
| 397 |
* the given context |
|
|
| 398 |
**/ |
294 |
**/ |
| 399 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
295 |
virtual MBool matches(Node* node, Node* context, ContextState* cs) = 0; |
| 400 |
|
296 |
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; |
297 |
virtual void toString(String& dest) = 0; |
| 410 |
|
298 |
|
| 411 |
}; //-- NodeExpr |
299 |
}; //-- NodeExpr |
|
|
| 440 |
**/ |
328 |
**/ |
| 441 |
void setName(const String& name); |
329 |
void setName(const String& name); |
| 442 |
|
330 |
|
| 443 |
//-----------------------------------/ |
|
|
| 444 |
//- Method signatures from NodeExpr -/ |
| 445 |
//-----------------------------------/ |
| 446 |
|
| 447 |
/** |
331 |
/** |
| 448 |
* Returns the default priority of this Pattern based on the given Node, |
332 |
* 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 |
**/ |
333 |
**/ |
| 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 |
**/ |
| 462 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
334 |
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(); |
335 |
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); |
336 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 475 |
|
337 |
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); |
338 |
virtual void toString(String& dest); |
| 485 |
|
339 |
|
| 486 |
private: |
340 |
private: |
|
|
| 521 |
* Destroys this BasicNodeExpr |
375 |
* Destroys this BasicNodeExpr |
| 522 |
**/ |
376 |
**/ |
| 523 |
virtual ~BasicNodeExpr(); |
377 |
virtual ~BasicNodeExpr(); |
| 524 |
|
378 |
|
| 525 |
//-----------------------------------/ |
|
|
| 526 |
//- Method signatures from NodeExpr -/ |
| 527 |
//-----------------------------------/ |
| 528 |
|
| 529 |
/** |
379 |
/** |
| 530 |
* Returns the default priority of this Pattern based on the given Node, |
380 |
* 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 |
**/ |
381 |
**/ |
| 535 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
382 |
void setNodeName(const String& name); |
| 536 |
|
383 |
|
| 537 |
/** |
384 |
/** |
| 538 |
* Evaluates this Expr based on the given context node and processor state |
385 |
* 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 |
**/ |
386 |
**/ |
| 544 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
387 |
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(); |
388 |
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); |
389 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 557 |
|
390 |
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); |
391 |
virtual void toString(String& dest); |
| 567 |
|
392 |
|
| 568 |
private: |
393 |
private: |
| 569 |
NodeExprType type; |
394 |
NodeExprType type; |
|
|
395 |
String nodeName; |
| 396 |
MBool nodeNameSet; |
| 570 |
}; //-- BasicNodeExpr |
397 |
}; //-- BasicNodeExpr |
| 571 |
|
398 |
|
| 572 |
/** |
399 |
/** |
|
|
| 597 |
**/ |
424 |
**/ |
| 598 |
void setName(const String& name); |
425 |
void setName(const String& name); |
| 599 |
|
426 |
|
| 600 |
//-----------------------------------/ |
|
|
| 601 |
//- Method signatures from NodeExpr -/ |
| 602 |
//-----------------------------------/ |
| 603 |
|
| 604 |
/** |
427 |
/** |
| 605 |
* Evaluates this Expr based on the given context node and processor state |
428 |
* 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 |
**/ |
429 |
**/ |
| 611 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
430 |
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(); |
431 |
short getType(); |
| 626 |
|
432 |
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); |
433 |
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); |
434 |
virtual void toString(String& dest); |
| 642 |
|
435 |
|
| 643 |
private: |
436 |
private: |
|
|
| 655 |
}; //-- ElementExpr |
448 |
}; //-- ElementExpr |
| 656 |
|
449 |
|
| 657 |
/** |
450 |
/** |
| 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 |
451 |
* This class represents a TextExpr, which only matches any text node |
| 726 |
**/ |
452 |
**/ |
| 727 |
class TextExpr : public NodeExpr { |
453 |
class TextExpr : public NodeExpr { |
| 728 |
|
454 |
|
| 729 |
public: |
455 |
public: |
| 730 |
|
|
|
| 731 |
//------------------/ |
| 732 |
//- Public Methods -/ |
| 733 |
//------------------/ |
| 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 |
|
456 |
|
|
|
457 |
//------------------/ |
| 458 |
//- Public Methods -/ |
| 459 |
//------------------/ |
| 764 |
|
460 |
|
| 765 |
/** |
461 |
/** |
| 766 |
* Returns the String representation of this NodeExpr. |
462 |
* 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 |
**/ |
463 |
**/ |
|
|
464 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 465 |
virtual short getType(); |
| 466 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 467 |
virtual double getDefaultPriority(Node* node, Node* context, ContextState* cs); |
| 773 |
virtual void toString(String& dest); |
468 |
virtual void toString(String& dest); |
| 774 |
|
469 |
|
| 775 |
}; //-- TextExpr |
470 |
}; //-- TextExpr |
|
|
| 827 |
List predicates; |
522 |
List predicates; |
| 828 |
}; //-- PredicateList |
523 |
}; //-- PredicateList |
| 829 |
|
524 |
|
| 830 |
class LocationStep : public PredicateList, public PatternExpr { |
525 |
class LocationStep : public PredicateList, public Expr { |
| 831 |
|
526 |
|
| 832 |
public: |
527 |
public: |
| 833 |
|
528 |
|
|
|
| 887 |
**/ |
582 |
**/ |
| 888 |
void setNodeExpr(NodeExpr* nodeExpr); |
583 |
void setNodeExpr(NodeExpr* nodeExpr); |
| 889 |
|
584 |
|
| 890 |
//------------------------------------/ |
|
|
| 891 |
//- Virtual methods from PatternExpr -/ |
| 892 |
//------------------------------------/ |
| 893 |
|
| 894 |
/** |
585 |
/** |
| 895 |
* Evaluates this Expr based on the given context node and processor state |
586 |
* 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 |
**/ |
587 |
**/ |
| 901 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
588 |
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); |
589 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 916 |
|
590 |
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); |
591 |
virtual void toString(String& dest); |
| 926 |
|
592 |
|
| 927 |
private: |
593 |
private: |
| 928 |
|
594 |
|
| 929 |
NodeExpr* nodeExpr; |
595 |
NodeExpr* nodeExpr; |
| 930 |
short axisIdentifier; |
596 |
short axisIdentifier; |
| 931 |
|
597 |
|
| 932 |
void fromDescendants(Node* context, ContextState* cs, NodeSet* nodes); |
598 |
void fromDescendants(Node* context, ContextState* cs, NodeSet* nodes); |
| 933 |
void fromDescendantsRev(Node* context, ContextState* cs, NodeSet* nodes); |
599 |
void fromDescendantsRev(Node* context, ContextState* cs, NodeSet* nodes); |
|
|
| 935 |
}; //-- LocationStep |
601 |
}; //-- LocationStep |
| 936 |
|
602 |
|
| 937 |
|
603 |
|
| 938 |
class FilterExpr : public PredicateList, public PatternExpr { |
604 |
class FilterExpr : public PredicateList, public Expr { |
| 939 |
|
605 |
|
| 940 |
public: |
606 |
public: |
| 941 |
|
607 |
|
|
|
| 962 |
**/ |
628 |
**/ |
| 963 |
void setExpr(Expr* expr); |
629 |
void setExpr(Expr* expr); |
| 964 |
|
630 |
|
| 965 |
//------------------------------------/ |
|
|
| 966 |
//- Virtual methods from PatternExpr -/ |
| 967 |
//------------------------------------/ |
| 968 |
|
| 969 |
/** |
631 |
/** |
| 970 |
* Evaluates this Expr based on the given context node and processor state |
632 |
* 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 |
**/ |
633 |
**/ |
| 976 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
634 |
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); |
635 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 991 |
|
636 |
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); |
637 |
virtual void toString(String& dest); |
| 1001 |
|
638 |
|
| 1002 |
private: |
639 |
private: |
| 1003 |
|
640 |
|
| 1004 |
Expr* expr; |
641 |
Expr* expr; |
| 1005 |
|
642 |
|
| 1006 |
}; //-- FilterExpr |
643 |
}; //-- FilterExpr |
| 1007 |
|
644 |
|
|
|
| 1015 |
~NumberExpr(); |
652 |
~NumberExpr(); |
| 1016 |
|
653 |
|
| 1017 |
/** |
654 |
/** |
| 1018 |
* Evaluates this Expr based on the given context node and processor state |
655 |
* 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 |
**/ |
656 |
**/ |
| 1024 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
657 |
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); |
658 |
virtual void toString(String& str); |
| 1035 |
|
659 |
|
| 1036 |
private: |
660 |
private: |
|
|
| 1052 |
~StringExpr(); |
676 |
~StringExpr(); |
| 1053 |
|
677 |
|
| 1054 |
/** |
678 |
/** |
| 1055 |
* Evaluates this Expr based on the given context node and processor state |
679 |
* 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 |
**/ |
680 |
**/ |
| 1061 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
681 |
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); |
682 |
virtual void toString(String& str); |
| 1072 |
|
683 |
|
| 1073 |
private: |
684 |
private: |
|
|
| 1106 |
|
717 |
|
| 1107 |
|
718 |
|
| 1108 |
/** |
719 |
/** |
| 1109 |
* Evaluates this Expr based on the given context node and processor state |
720 |
* 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 |
**/ |
721 |
**/ |
| 1115 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
722 |
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); |
723 |
virtual void toString(String& str); |
| 1126 |
|
724 |
|
| 1127 |
|
725 |
|
|
|
| 1133 |
}; //-- AdditiveExpr |
731 |
}; //-- AdditiveExpr |
| 1134 |
|
732 |
|
| 1135 |
/** |
733 |
/** |
|
|
734 |
* Represents an UnaryExpr. Returns the negative value of it's expr. |
| 735 |
**/ |
| 736 |
class UnaryExpr : public Expr { |
| 737 |
|
| 738 |
public: |
| 739 |
|
| 740 |
UnaryExpr(); |
| 741 |
UnaryExpr(Expr* expr); |
| 742 |
~UnaryExpr(); |
| 743 |
|
| 744 |
/** |
| 745 |
* Sets the expression to negate |
| 746 |
**/ |
| 747 |
void setExpr(Expr* expr); |
| 748 |
|
| 749 |
/** |
| 750 |
* Virtual methods from Expr |
| 751 |
**/ |
| 752 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
| 753 |
virtual void toString(String& str); |
| 754 |
|
| 755 |
private: |
| 756 |
Expr* expr; |
| 757 |
}; //-- UnaryExpr |
| 758 |
|
| 759 |
/** |
| 1136 |
* Represents a BooleanExpr, a binary expression that |
760 |
* Represents a BooleanExpr, a binary expression that |
| 1137 |
* performs a boolean operation between it's lvalue and rvalue:<BR/> |
761 |
* performs a boolean operation between it's lvalue and rvalue:<BR/> |
| 1138 |
**/ |
762 |
**/ |
|
|
| 1148 |
~BooleanExpr(); |
772 |
~BooleanExpr(); |
| 1149 |
|
773 |
|
| 1150 |
/** |
774 |
/** |
| 1151 |
* Sets the left side of this AdditiveExpr |
775 |
* Sets the left side of this BooleanExpr |
| 1152 |
**/ |
776 |
**/ |
| 1153 |
void setLeftExpr(Expr* leftExpr); |
777 |
void setLeftExpr(Expr* leftExpr); |
| 1154 |
|
778 |
|
| 1155 |
/** |
779 |
/** |
| 1156 |
* Sets the right side of this AdditiveExpr |
780 |
* Sets the right side of this BooleanExpr |
| 1157 |
**/ |
781 |
**/ |
| 1158 |
void setRightExpr(Expr* rightExpr); |
782 |
void setRightExpr(Expr* rightExpr); |
| 1159 |
|
783 |
|
| 1160 |
|
784 |
|
| 1161 |
/** |
785 |
/** |
| 1162 |
* Evaluates this Expr based on the given context node and processor state |
786 |
* 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 |
**/ |
787 |
**/ |
| 1168 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
788 |
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); |
789 |
virtual void toString(String& str); |
| 1179 |
|
790 |
|
| 1180 |
|
791 |
|
|
|
| 1215 |
**/ |
826 |
**/ |
| 1216 |
void setRightExpr(Expr* rightExpr); |
827 |
void setRightExpr(Expr* rightExpr); |
| 1217 |
|
828 |
|
| 1218 |
|
|
|
| 1219 |
/** |
829 |
/** |
| 1220 |
* Evaluates this Expr based on the given context node and processor state |
830 |
* 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 |
**/ |
831 |
**/ |
| 1226 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
832 |
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); |
833 |
virtual void toString(String& str); |
| 1237 |
|
834 |
|
| 1238 |
|
|
|
| 1239 |
|
| 1240 |
private: |
835 |
private: |
| 1241 |
short op; |
836 |
short op; |
| 1242 |
Expr* leftExpr; |
837 |
Expr* leftExpr; |
|
|
| 1273 |
~RelationalExpr(); |
868 |
~RelationalExpr(); |
| 1274 |
|
869 |
|
| 1275 |
/** |
870 |
/** |
| 1276 |
* Evaluates this Expr based on the given context node and processor state |
871 |
* 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 |
**/ |
872 |
**/ |
| 1282 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
873 |
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); |
874 |
virtual void toString(String& str); |
| 1293 |
|
875 |
|
| 1294 |
|
|
|
| 1295 |
|
| 1296 |
private: |
876 |
private: |
| 1297 |
short op; |
877 |
short op; |
| 1298 |
Expr* leftExpr; |
878 |
Expr* leftExpr; |
|
|
| 1320 |
void setName(const String& name); |
900 |
void setName(const String& name); |
| 1321 |
|
901 |
|
| 1322 |
/** |
902 |
/** |
| 1323 |
* Evaluates this Expr based on the given context node and processor state |
903 |
* 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 |
**/ |
904 |
**/ |
| 1329 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
905 |
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); |
906 |
virtual void toString(String& str); |
| 1340 |
|
907 |
|
| 1341 |
private: |
908 |
private: |
|
|
| 1346 |
/** |
913 |
/** |
| 1347 |
* Represents a PathExpr |
914 |
* Represents a PathExpr |
| 1348 |
**/ |
915 |
**/ |
| 1349 |
class PathExpr : public PatternExpr { |
916 |
class PathExpr : public Expr { |
| 1350 |
|
917 |
|
| 1351 |
public: |
918 |
public: |
| 1352 |
|
919 |
|
|
|
| 1361 |
PathExpr(); |
928 |
PathExpr(); |
| 1362 |
|
929 |
|
| 1363 |
/** |
930 |
/** |
| 1364 |
* Destructor, will delete all Pattern Expressions |
931 |
* Destructor, will delete all Expressions |
| 1365 |
**/ |
932 |
**/ |
| 1366 |
virtual ~PathExpr(); |
933 |
virtual ~PathExpr(); |
| 1367 |
|
934 |
|
| 1368 |
/** |
935 |
/** |
| 1369 |
* Adds the PatternExpr to this PathExpr |
936 |
* Adds the Expr to this PathExpr |
| 1370 |
* @param expr the Expr to add to this PathExpr |
937 |
* @param expr the Expr to add to this PathExpr |
| 1371 |
* @param index the index at which to add the given Expr |
938 |
* @param index the index at which to add the given Expr |
| 1372 |
**/ |
939 |
**/ |
| 1373 |
void addPatternExpr(int index, PatternExpr* expr, short ancestryOp); |
940 |
void addExpr(int index, Expr* expr, short ancestryOp); |
| 1374 |
|
941 |
|
| 1375 |
/** |
942 |
/** |
| 1376 |
* Adds the PatternExpr to this PathExpr |
943 |
* Adds the Expr to this PathExpr |
| 1377 |
* @param expr the Expr to add to this PathExpr |
944 |
* @param expr the Expr to add to this PathExpr |
| 1378 |
**/ |
945 |
**/ |
| 1379 |
void addPatternExpr(PatternExpr* expr, short ancestryOp); |
946 |
void addExpr(Expr* expr, short ancestryOp); |
| 1380 |
|
947 |
|
| 1381 |
virtual MBool isAbsolute(); |
948 |
virtual MBool isAbsolute(); |
| 1382 |
|
949 |
|
| 1383 |
//------------------------------------/ |
|
|
| 1384 |
//- Virtual methods from PatternExpr -/ |
| 1385 |
//------------------------------------/ |
| 1386 |
|
| 1387 |
/** |
950 |
/** |
| 1388 |
* Evaluates this Expr based on the given context node and processor state |
951 |
* 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 |
**/ |
952 |
**/ |
| 1394 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
953 |
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); |
954 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1409 |
|
955 |
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); |
956 |
virtual void toString(String& dest); |
| 1419 |
|
957 |
|
| 1420 |
private: |
958 |
private: |
| 1421 |
|
959 |
|
| 1422 |
struct PathExprItem { |
960 |
struct PathExprItem { |
| 1423 |
PatternExpr* pExpr; |
961 |
Expr* expr; |
| 1424 |
short ancestryOp; |
962 |
short ancestryOp; |
| 1425 |
}; |
963 |
}; |
| 1426 |
|
964 |
|
|
|
| 1428 |
|
966 |
|
| 1429 |
/** |
967 |
/** |
| 1430 |
* Selects from the descendants of the context node |
968 |
* Selects from the descendants of the context node |
| 1431 |
* all nodes that match the PatternExpr |
969 |
* all nodes that match the Expr |
| 1432 |
* -- this will be moving to a Utility class |
970 |
* -- this will be moving to a Utility class |
| 1433 |
**/ |
971 |
**/ |
| 1434 |
void evalDescendants(PatternExpr* pExpr, |
972 |
void evalDescendants(Expr* expr, |
| 1435 |
Node* context, |
973 |
Node* context, |
| 1436 |
ContextState* cs, |
974 |
ContextState* cs, |
| 1437 |
NodeSet* nodes); |
975 |
NodeSet* resNodes); |
| 1438 |
|
976 |
|
| 1439 |
}; //-- PathExpr |
977 |
}; //-- PathExpr |
| 1440 |
|
978 |
|
|
|
| 1450 |
//------------------/ |
988 |
//------------------/ |
| 1451 |
|
989 |
|
| 1452 |
/** |
990 |
/** |
| 1453 |
* Evaluates this Expr based on the given context node and processor state |
991 |
* 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 |
**/ |
992 |
**/ |
| 1459 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
993 |
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); |
994 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1476 |
|
995 |
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); |
996 |
virtual void toString(String& dest); |
| 1486 |
|
997 |
|
|
|
998 |
virtual MBool isAbsolute(); |
| 999 |
|
| 1487 |
|
1000 |
|
| 1488 |
}; //-- RootExpr |
1001 |
}; //-- RootExpr |
| 1489 |
|
1002 |
|
| 1490 |
/** |
1003 |
/** |
| 1491 |
* Represents a UnionExpr |
1004 |
* Represents a UnionExpr |
| 1492 |
**/ |
1005 |
**/ |
| 1493 |
class UnionExpr : public PatternExpr { |
1006 |
class UnionExpr : public Expr { |
| 1494 |
|
1007 |
|
| 1495 |
public: |
1008 |
public: |
| 1496 |
|
1009 |
|
|
|
| 1508 |
* Adds the PathExpr to this UnionExpr |
1021 |
* Adds the PathExpr to this UnionExpr |
| 1509 |
* @param expr the Expr to add to this UnionExpr |
1022 |
* @param expr the Expr to add to this UnionExpr |
| 1510 |
**/ |
1023 |
**/ |
| 1511 |
void addPathExpr(PathExpr* expr); |
1024 |
void addExpr(Expr* expr); |
| 1512 |
|
1025 |
|
| 1513 |
/** |
1026 |
/** |
| 1514 |
* Adds the PathExpr to this UnionExpr at the specified index |
1027 |
* Adds the PathExpr to this UnionExpr at the specified index |
| 1515 |
* @param expr the Expr to add to this UnionExpr |
1028 |
* @param expr the Expr to add to this UnionExpr |
| 1516 |
**/ |
1029 |
**/ |
| 1517 |
void addPathExpr(int index, PathExpr* expr); |
1030 |
void addExpr(int index, Expr* expr); |
| 1518 |
|
|
|
| 1519 |
//------------------------------------/ |
| 1520 |
//- Virtual methods from PatternExpr -/ |
| 1521 |
//------------------------------------/ |
| 1522 |
|
1031 |
|
| 1523 |
/** |
1032 |
/** |
| 1524 |
* Evaluates this Expr based on the given context node and processor state |
1033 |
* 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 |
**/ |
1034 |
**/ |
| 1530 |
virtual ExprResult* evaluate(Node* context, ContextState* cs); |
1035 |
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); |
1036 |
virtual MBool matches(Node* node, Node* context, ContextState* cs); |
| 1545 |
|
1037 |
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); |
1038 |
virtual void toString(String& dest); |
| 1555 |
|
1039 |
|
| 1556 |
private: |
1040 |
private: |