Changeset 4906


Ignore:
Timestamp:
2003-07-12T08:58:10+12:00 (21 years ago)
Author:
sjboddie
Message:

Replaced overloaded get_formatted_string() functions in formattools with
a single function by using a text_tmap in place of the old link, text,
icon, and highlight variables.

Location:
trunk/gsdl/src/recpt
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/browsetools.cpp

    r4867 r4906  
    115115    return;
    116116
     117  text_tmap options; // no options
    117118  textout << outconvert << disp
    118       << get_formatted_string (args["c"],collectproto,
    119                    response.docInfo[0], disp, formatlistptr,
    120                    logout);
     119      << get_formatted_string (args["c"],collectproto, response.docInfo[0], disp,
     120                   formatlistptr, options, logout);
    121121}
    122122
     
    145145 
    146146  //get the format string from formattools.cpp
     147  text_tmap options; // no options
    147148  text_t relateddocs =  get_formatted_string (args["c"],collectproto, response.docInfo[0],
    148                           disp, formatlistptr, logout);
     149                          disp, formatlistptr, options, logout);
    149150  //output the related documents
    150151  textout << outconvert << disp << relateddocs;
  • trunk/gsdl/src/recpt/datelistbrowserclass.cpp

    r3666 r4906  
    123123   
    124124    if (!use_table) textout << outconvert << "<td>\n";
    125    
     125
     126    text_tmap options;
     127    options["link"] = link;
     128    options["icon"] = icon;
     129    options["highlight"] = "0";
    126130    textout << outconvert << disp
    127131            << get_formatted_string (collection, collectproto,
    128132                     *thissection, disp, formatlistptr,
    129                      link, icon, false,
    130                      logout) << "\n";
     133                     options, logout) << "\n";
    131134   
    132135    if (!use_table) textout << outconvert << "</td>";
  • trunk/gsdl/src/recpt/documentaction.cpp

    r4893 r4906  
    899899 
    900900    if (wanttext != 1) {
     901      text_tmap options;
     902      options["text"] = docresponse.doc;
    901903      text_t doctext
    902     = get_formatted_string (collection, collectproto,
    903                 docinfo, disp, formatlistptr, docresponse.doc,
    904                 logout);
     904     = get_formatted_string (collection, collectproto, docinfo, disp,
     905                 formatlistptr, options, logout);
    905906     
    906907      if (highlight) {
  • trunk/gsdl/src/recpt/formattools.cpp

    r4868 r4906  
    3232
    3333// a few function prototypes
     34
    3435static text_t format_string (const text_t& collection, recptproto* collectproto,
    3536                 ResultDocInfo_t &docinfo, displayclass &disp,
    36                  format_t *formatlistptr,
    37                  const text_t &link, const text_t &icon,
    38                  const text_t &text, bool highlight, ostream& logout);
     37                 format_t *formatlistptr, text_tmap &options,
     38                 ostream& logout);
    3939
    4040static bool parse_action (text_t::const_iterator &here, const text_t::const_iterator &end,
    4141              format_t *formatlistptr, text_tset &metadata, bool &getParents);
    4242
    43 text_t format_summary (const text_t& collection, recptproto* collectproto,
    44               ResultDocInfo_t &docinfo, displayclass &disp,
    45               const text_t &text, bool highlight,
    46                ostream& logout);
     43static text_t format_summary (const text_t& collection, recptproto* collectproto,
     44                  ResultDocInfo_t &docinfo, displayclass &disp,
     45                  text_tmap &options, ostream& logout);
    4746
    4847
     
    866865static text_t get_or (const text_t& collection, recptproto* collectproto,
    867866              ResultDocInfo_t &docinfo, displayclass &disp,
    868               format_t *orptr,
    869               const text_t &link, const text_t &icon,
    870               const text_t &text, bool highlight,
     867              format_t *orptr, text_tmap &options,
    871868              ostream& logout) {
    872869
     
    875872
    876873    tmp = format_string (collection,collectproto, docinfo, disp, orptr,
    877              link, icon, text, highlight, logout);
     874             options, logout);
    878875    if (!tmp.empty()) return tmp;
    879876
     
    886883              ResultDocInfo_t &docinfo, displayclass &disp,
    887884              const decision_t &decision,
    888               format_t *ifptr, format_t *elseptr, const text_t &link,
    889               const text_t &icon, const text_t &text, bool highlight,
    890               ostream& logout)
     885              format_t *ifptr, format_t *elseptr,
     886              text_tmap &options, ostream& logout)
    891887{
    892888
     
    897893      if (ifptr != NULL)
    898894    return get_formatted_string (collection,collectproto, docinfo, disp, ifptr,
    899                      link, icon, text, highlight, logout);
     895                     options, logout);
    900896    }
    901897    else {
    902898      if (elseptr != NULL)
    903899    return get_formatted_string (collection,collectproto, docinfo, disp, elseptr,
    904                      link, icon, text, highlight, logout);
     900                     options, logout);
    905901    }
    906902  }
     
    920916      if (ifptr != NULL)
    921917    return get_formatted_string (collection, collectproto, docinfo, disp, ifptr,
    922                      link, icon, text, highlight, logout);
     918                     options, logout);
    923919    } else {
    924920      if (elseptr != NULL)
    925921    return get_formatted_string (collection, collectproto, docinfo, disp, elseptr,
    926                      link, icon, text, highlight, logout);
     922                     options, logout);
    927923    }
    928924  }
     
    947943text_t format_string (const text_t& collection, recptproto* collectproto,
    948944              ResultDocInfo_t &docinfo, displayclass &disp,
    949               format_t *formatlistptr,
    950               const text_t &link, const text_t &icon,
    951               const text_t &text, bool highlight,
     945              format_t *formatlistptr, text_tmap &options,
    952946              ostream& logout) {
    953947
     
    958952    return formatlistptr->text;
    959953  case comLink:
    960     return link;
     954    return options["link"];
    961955  case comEndLink:
    962     if (link.empty()) return "";
     956    if (options["link"].empty()) return "";
    963957    else return "</a>";
    964958  case comHref:
    965     return get_href(link);
     959    return get_href(options["link"]);
    966960  case comIcon:
    967     return icon;
     961    return options["icon"];
    968962  case comNum:
    969963    return docinfo.result_num;
     
    971965    return get_related_docs(collection, collectproto, docinfo, logout);
    972966  case comSummary:
    973     return format_summary(collection,collectproto,docinfo,disp,text,highlight,logout);
     967    return format_summary(collection, collectproto, docinfo, disp, options, logout);
    974968  case comMeta:
    975969
     
    998992        = get_formatted_string(collection, collectproto,
    999993                       response.docInfo[0], disp, expanded_formatlistptr,
    1000                        link, icon, highlight, logout);
     994                       options, logout);
    1001995         
    1002996          return expanded_metavalue;
     
    10131007    }
    10141008  case comDoc:
    1015     return text;
     1009    return options["text"];
    10161010  case comHighlight:
    1017     if (highlight) return "<b>";
     1011    if (options["highlight"] == "1") return "<b>";
    10181012    break;
    10191013  case comEndHighlight:
    1020     if (highlight) return "</b>";
     1014    if (options["highlight"] == "1") return "</b>";
    10211015    break;
    10221016  case comIf:
    10231017    return get_if (collection, collectproto, docinfo, disp,
    10241018           formatlistptr->decision, formatlistptr->ifptr,
    1025            formatlistptr->elseptr, link, icon, text, highlight,
    1026            logout);
     1019           formatlistptr->elseptr, options, logout);
    10271020  case comOr:
    10281021    return get_or (collection,collectproto, docinfo, disp, formatlistptr->orptr,
    1029            link, icon, text, highlight, logout);
     1022           options, logout);
    10301023  }
    10311024  return "";
    1032 }
    1033 
    1034 
    1035 
    1036 
    1037 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    1038                  ResultDocInfo_t& docinfo, displayclass &disp,
    1039                  format_t* formatlistptr,
    1040                  const text_t& link, const text_t& icon,
    1041                  const text_t& text, const bool highlight,
    1042                  ostream& logout) {
    1043 
    1044   text_t ft;
    1045   while (formatlistptr != NULL)
    1046     {
    1047       ft += format_string (collection, collectproto, docinfo, disp, formatlistptr,
    1048                link, icon, text, highlight, logout);
    1049       formatlistptr = formatlistptr->nextptr;
    1050     }
    1051 
    1052   return ft;
    10531025}
    10541026
    10551027text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    10561028                 ResultDocInfo_t &docinfo, displayclass &disp,
    1057                  format_t *formatlistptr,
    1058                  const text_t &link, const text_t &icon,
    1059                  const bool highlight,
     1029                 format_t *formatlistptr, text_tmap &options,
    10601030                 ostream& logout) {
    10611031
    1062   text_t text = "";
    1063 
    1064   return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
    1065                               link, icon, text, highlight, logout);
    1066 }
    1067 
    1068 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    1069                  ResultDocInfo_t &docinfo, displayclass &disp,
    1070                  format_t *formatlistptr,
    1071                  const text_t& text,
    1072                  ostream& logout) {
    1073 
    1074   text_t link = "<a href=\"_httpdocument_&cl=search&d=" + docinfo.OID + "\">";
    1075   text_t icon = "_icontext_";
    1076   bool highlight = false;
    1077 
    1078   return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
    1079                   link, icon, text, highlight, logout);
    1080 }
    1081 
    1082 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    1083                  ResultDocInfo_t &docinfo, displayclass &disp,
    1084                  format_t *formatlistptr,
    1085                  ostream& logout) {
    1086 
    1087   text_t text = "";
    1088 
    1089   return get_formatted_string(collection, collectproto, docinfo, disp, formatlistptr,
    1090                   text, logout);
     1032   text_t ft;
     1033   while (formatlistptr != NULL)
     1034      {
     1035     ft += format_string (collection, collectproto, docinfo, disp, formatlistptr,
     1036                  options, logout);
     1037     formatlistptr = formatlistptr->nextptr;
     1038      }
     1039   
     1040   return ft;
    10911041}
    10921042
     
    10971047
    10981048text_t format_summary (const text_t& collection, recptproto* collectproto,
    1099               ResultDocInfo_t &docinfo, displayclass &disp,
    1100               const text_t &text, bool highlight,
    1101               ostream& logout) {
     1049               ResultDocInfo_t &docinfo, displayclass &disp,
     1050               text_tmap &options, ostream& logout) {
    11021051
    11031052  // GRB: added code here to ensure that the cstr (and other collections)
     
    11111060
    11121061  text_t textToSummarise, query;
    1113   if(text.empty()) { // get document text
    1114       DocumentRequest_t docrequest;
    1115       DocumentResponse_t docresponse;
    1116       comerror_t err;
    1117       docrequest.OID = docinfo.OID;
    1118       collectproto->get_document (collection, docrequest, docresponse, err, logout);
    1119       textToSummarise = docresponse.doc;
     1062  if(options["text"].empty()) { // get document text
     1063     DocumentRequest_t docrequest;
     1064     DocumentResponse_t docresponse;
     1065     comerror_t err;
     1066     docrequest.OID = docinfo.OID;
     1067     collectproto->get_document (collection, docrequest, docresponse, err, logout);
     1068     textToSummarise = docresponse.doc;
    11201069  } else // in practice, this would not happen, because text is only
    11211070         // loaded with the [Text] command
    1122       textToSummarise = text;
     1071     textToSummarise = options["text"];
    11231072  disp.expandstring("_cgiargq_",query);
    11241073  return summarise(textToSummarise,query,80);
  • trunk/gsdl/src/recpt/formattools.h

    r4868 r4906  
    3434
    3535enum command_t {comIf, comOr, comMeta, comText, comLink, comEndLink, comNum, comIcon,
    36         comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary};
     36        comDoc, comHighlight, comEndHighlight, comRel, comHref, comSummary, comTOC, comImage};
    3737enum pcommand_t {pNone, pImmediate, pTop, pAll};
    3838enum dcommand_t {dMeta, dText};
     
    119119
    120120
    121 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    122                  ResultDocInfo_t &docinfo, displayclass &disp,
    123                  format_t *formatlistptr,
    124                  const text_t &link, const text_t &icon,
    125                  const text_t& t, const bool highlight,
    126                  ostream& logout);
    127121
    128122text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    129123                 ResultDocInfo_t &docinfo, displayclass &disp,
    130                  format_t *formatlistptr,
    131                  const text_t &link, const text_t &icon,
    132                  const bool highlight,
     124                 format_t *formatlistptr, text_tmap &options,
    133125                 ostream& logout);
    134 
    135 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    136                  ResultDocInfo_t &docinfo, displayclass &disp,
    137                  format_t *formatlistptr,
    138                  const text_t &text,
    139                  ostream& logout);
    140 
    141 text_t get_formatted_string (const text_t& collection, recptproto* collectproto,
    142                  ResultDocInfo_t &docinfo, displayclass &disp,
    143                  format_t *formatlistptr, ostream& logout);
    144 
    145 
    146126
    147127#endif
  • trunk/gsdl/src/recpt/hlistbrowserclass.cpp

    r3666 r4906  
    135135    }
    136136
     137    text_tmap options;
     138    options["link"] = link;
     139    options["icon"] = icon;
     140    if (highlight) options["highlight"] = "1";
     141    else options["highlight"] = "0";
     142   
    137143    text_t fmt_str=get_formatted_string (collection, collectproto,
    138144                      *tsibling, disp, formatlistptr,
    139                       link, icon, highlight, logout);
     145                      options, logout);
    140146
    141147    /* this is awful. Someone please come up with a better way to prevent
  • trunk/gsdl/src/recpt/vlistbrowserclass.cpp

    r4829 r4906  
    8383  }
    8484
     85  text_tmap options;
     86  options["link"] = link;
     87  options["icon"] = icon;
     88  if (highlight) options["highlight"] = "1";
     89  else options["highlight"] = "0";
    8590  textout << outconvert << disp
    8691      << get_formatted_string (collection, collectproto,
    8792                   section, disp, formatlistptr,
    88                    link, icon, highlight, logout);
     93                   options, logout);
    8994 
    9095  if (use_table  || colnumber > 0) textout << outconvert << "</tr></table>\n";
     
    127132  int item = 0, perline;; // set perline to 1 normally
    128133  text_t fstring;
     134
     135  text_tmap options;
     136  options["link"] = link;
     137  options["icon"] = icon;
     138  options["highlight"] = "0";
     139
    129140  if ( thissection != endsection ) { // only if there are results (else corrupts display)
    130     fstring =
    131       get_formatted_string (collection, collectproto,
    132                 *thissection, disp, formatlistptr, link, icon, false, logout);
     141    fstring = get_formatted_string (collection, collectproto, *thissection,
     142                                    disp, formatlistptr, options, logout);
    133143    // if format string
    134144    // has <td><t (e.g. <td><table>) then
     
    152162      textout << outconvert << "<tr valign=top>\n";
    153163
     164    options["link"] = link;
     165    options["icon"] = icon;
     166    if (highlight) options["highlight"] = "1";
     167    else options["highlight"] = "0";
     168   
    154169    textout << outconvert << disp
    155170        << " " << get_formatted_string (collection, collectproto, *thissection, disp,
    156                         formatlistptr, link, icon, highlight, logout);
     171                        formatlistptr, options, logout);
    157172
    158173    if ((item >= perline && use_table) || colnumber > 0) {
Note: See TracChangeset for help on using the changeset viewer.