Changeset 1610 for trunk/gsdl/src/recpt/formattools.cpp
- Timestamp:
- 2000-10-25T12:25:01+13:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/formattools.cpp
r1561 r1610 32 32 // a few function prototypes 33 33 static text_t format_string (const text_t& collection, recptproto* collectproto, 34 ResultDocInfo_t &docinfo, format_t *formatlistptr, 34 ResultDocInfo_t &docinfo, displayclass &disp, 35 format_t *formatlistptr, 35 36 const text_t &link, const text_t &icon, 36 37 const text_t &text, bool highlight, ostream& logout); … … 49 50 command = dMeta; 50 51 meta.clear(); 52 text.clear(); 51 53 } 52 54 … … 385 387 text.clear(); 386 388 387 } else { 388 // the {If}{decide,do,else} statement 389 } 390 391 // Parse an {If}{decide,do,else} statement 392 else { 393 394 // Read the decision component. 389 395 if (commacount == 0) { 390 // If decision only supports metadata at present391 392 // remove the surrounding square brackets 396 // Decsion can be a metadata element, or a piece of text. 397 // Originally Stefan's code, updated 25/10/2000 by Gordon. 398 393 399 text_t::const_iterator beginbracket = text.begin(); 394 400 text_t::const_iterator endbracket = (text.end() - 1); 401 402 // Decision is based on a metadata element 395 403 if ((*beginbracket == '[') && (*endbracket == ']')) { 404 // Ignore the surrounding square brackets 396 405 text_t meta = substr (beginbracket+1, endbracket); 397 406 parse_meta (meta, formatlistptr->decision.meta, metadata, getParents); … … 399 408 text.clear(); 400 409 } 401 402 } else { 410 411 // Decision is a piece of text (probably a macro like _cgiargmode_). 412 else { 413 formatlistptr->decision.command = dText; 414 formatlistptr->decision.text = text; 415 commacount ++; 416 text.clear(); 417 } 418 } 419 420 // Read the "then" and "else" components of the {If} statement. 421 else { 403 422 format_t** nextlistptr = NULL; 404 423 if (commacount == 1) { 405 424 nextlistptr = &formatlistptr->ifptr; 406 425 } else if (commacount == 2 ) { 407 426 nextlistptr = &formatlistptr->elseptr; … … 548 567 549 568 static text_t get_or (const text_t& collection, recptproto* collectproto, 550 ResultDocInfo_t &docinfo, format_t *orptr, 569 ResultDocInfo_t &docinfo, displayclass &disp, 570 format_t *orptr, 551 571 const text_t &link, const text_t &icon, 552 572 const text_t &text, bool highlight, … … 556 576 while (orptr != NULL) { 557 577 558 tmp = format_string (collection,collectproto, docinfo, orptr,559 link, icon,text,highlight, logout);578 tmp = format_string (collection,collectproto, docinfo, disp, orptr, 579 link, icon, text, highlight, logout); 560 580 if (!tmp.empty()) return tmp; 561 581 … … 566 586 567 587 static text_t get_if (const text_t& collection, recptproto* collectproto, 568 ResultDocInfo_t &docinfo, const decision_t &decision, 588 ResultDocInfo_t &docinfo, displayclass &disp, 589 const decision_t &decision, 569 590 format_t *ifptr, format_t *elseptr, const text_t &link, 570 591 const text_t &icon, const text_t &text, bool highlight, … … 572 593 { 573 594 574 // not much of a choice yet ... 595 // If the decision component is a metadata element, then evaluate it 596 // to see whether we output the "then" or the "else" clause 575 597 if (decision.command == dMeta) { 576 598 if (get_meta (docinfo, decision.meta) != "") { 577 599 if (ifptr != NULL) 578 return get_formatted_string (collection,collectproto, docinfo, ifptr,579 link, icon,text,highlight, logout);600 return get_formatted_string (collection,collectproto, docinfo, disp, ifptr, 601 link, icon, text, highlight, logout); 580 602 } 581 603 else { 582 604 if (elseptr != NULL) 583 return get_formatted_string (collection,collectproto, docinfo,elseptr, 584 link,icon,text,highlight, logout); 585 } 586 } 605 return get_formatted_string (collection,collectproto, docinfo, disp, elseptr, 606 link, icon, text, highlight, logout); 607 } 608 } 609 610 // If the decision component is text, then evaluate it (it is probably a 611 // macro like _cgiargmode_) to decide what to output. 612 else if (decision.command == dText) { 613 614 text_t outstring; 615 disp.expandstring (decision.text, outstring); 616 617 // This is a tad tricky. When we expand a string like _cgiargmode_, that is 618 // a cgi argument macro that has not been set, it evaluates to itself. 619 // Therefore, were have to say that a piece of text evalautes true if 620 // it is non-empty and if it is a cgi argument evaulating to itself. 621 if ((outstring != "") && !((outstring == decision.text) && (outstring[0] == '_'))) { 622 if (ifptr != NULL) 623 return get_formatted_string (collection, collectproto, docinfo, disp, ifptr, 624 link, icon, text, highlight, logout); 625 } else { 626 if (elseptr != NULL) 627 return get_formatted_string (collection, collectproto, docinfo, disp, elseptr, 628 link, icon, text, highlight, logout); 629 } 630 } 631 587 632 return ""; 588 633 } … … 601 646 602 647 text_t format_string (const text_t& collection, recptproto* collectproto, 603 ResultDocInfo_t &docinfo, format_t *formatlistptr, 648 ResultDocInfo_t &docinfo, displayclass &disp, 649 format_t *formatlistptr, 604 650 const text_t &link, const text_t &icon, 605 651 const text_t &text, bool highlight, … … 644 690 { 645 691 text_t expanded_metavalue 646 = get_formatted_string(collection, collectproto,647 response.docInfo[0], expanded_formatlistptr,692 = get_formatted_string(collection, collectproto, 693 response.docInfo[0], disp, expanded_formatlistptr, 648 694 link,icon,highlight, 649 695 logout); … … 670 716 break; 671 717 case comIf: 672 return get_if (collection, collectproto, 673 docinfo,formatlistptr->decision, formatlistptr->ifptr,718 return get_if (collection, collectproto, docinfo, disp, 719 formatlistptr->decision, formatlistptr->ifptr, 674 720 formatlistptr->elseptr, link, icon, text, highlight, 675 721 logout); 676 722 case comOr: 677 return get_or (collection,collectproto, docinfo, formatlistptr->orptr,678 link, icon,text,highlight, logout);723 return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr, 724 link, icon, text, highlight, logout); 679 725 } 680 726 return ""; … … 685 731 686 732 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 687 ResultDocInfo_t& docinfo, format_t* formatlistptr, 733 ResultDocInfo_t& docinfo, displayclass &disp, 734 format_t* formatlistptr, 688 735 const text_t& link, const text_t& icon, 689 736 const text_t& text, const bool highlight, … … 693 740 while (formatlistptr != NULL) 694 741 { 695 ft += format_string (collection, collectproto, docinfo, formatlistptr,742 ft += format_string (collection, collectproto, docinfo, disp, formatlistptr, 696 743 link, icon, text, highlight, logout); 697 744 formatlistptr = formatlistptr->nextptr; … … 702 749 703 750 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 704 ResultDocInfo_t &docinfo, format_t *formatlistptr, 751 ResultDocInfo_t &docinfo, displayclass &disp, 752 format_t *formatlistptr, 705 753 const text_t &link, const text_t &icon, 706 754 const bool highlight, … … 709 757 text_t text = ""; 710 758 711 return get_formatted_string(collection, collectproto, docinfo, formatlistptr,759 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 712 760 link, icon, text, highlight, logout); 713 761 } 714 762 715 763 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 716 ResultDocInfo_t &docinfo, format_t *formatlistptr, 764 ResultDocInfo_t &docinfo, displayclass &disp, 765 format_t *formatlistptr, 717 766 const text_t& text, 718 767 ostream& logout) { … … 722 771 bool highlight = false; 723 772 724 return get_formatted_string(collection, collectproto, docinfo, formatlistptr,773 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 725 774 link, icon, text, highlight, logout); 726 775 } 727 776 728 777 text_t get_formatted_string (const text_t& collection, recptproto* collectproto, 729 ResultDocInfo_t &docinfo, format_t *formatlistptr, 778 ResultDocInfo_t &docinfo, displayclass &disp, 779 format_t *formatlistptr, 730 780 ostream& logout) { 731 781 732 782 text_t text = ""; 733 783 734 return get_formatted_string(collection, collectproto, docinfo, formatlistptr,784 return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr, 735 785 text, logout); 736 786 } 737 787 788 789 790 791 792 793
Note:
See TracChangeset
for help on using the changeset viewer.