Changeset 7380


Ignore:
Timestamp:
2004-05-24T15:33:18+12:00 (20 years ago)
Author:
mdewsnip
Message:

(Human Info) Made some parameters const, and added an extended addqueryelem function.

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

Legend:

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

    r6584 r7380  
    391391}
    392392
    393 text_t addstemcase(text_t &terms, text_t &stem, text_t &fold) {
     393text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold) {
    394394 
    395395  text_t outtext;
     
    446446
    447447
    448 
    449 void addqueryelem(text_t &querystring, text_t &tag,
    450                   text_t &query, text_t combine) {
     448void addqueryelem(text_t &querystring, const text_t &tag,
     449          const text_t &query, const text_t combine) {
    451450  if (!querystring.empty()) { // have to put and/or
    452451    querystring += " "+combine + " ";
     
    463462
    464463
    465 void format_field_info(text_t & querystring, text_t &tag) {
     464void addqueryelem_ex(text_t &querystring, const text_t &tag,
     465             const text_t &terms, const text_t &stem, const text_t &fold,
     466             const text_t& combine, const text_t& word_combine) {
     467  if (!querystring.empty()) { // have to put and/or
     468    querystring += " " + combine + " ";
     469  }
     470  text_t outtext; outtext.reserve(512);
     471  text_t word; word.reserve(100);
     472  //unsigned short c;                                                           
     473  text_t::const_iterator here = terms.begin();
     474  text_t::const_iterator end = terms.end();
     475  bool inquote = false, firstword = true;
     476
     477  text_t word2; word2.reserve(256);
     478   
     479  while (here !=end) {
     480    if (is_unicode_space(*here)) {
     481      if (word2 == "AND") { word2.clear(); word2.push_back(7527); word2.appendcarr("AND", 3); word2.push_back(7527); }
     482      else if (word2 == "OR") { word2.clear(); word2.push_back(7527); word2.appendcarr("OR", 2); word2.push_back(7527); }
     483      else if (word2 == "NOT") { word2.clear(); word2.push_back(7527); word2.appendcarr("NOT", 3); word2.push_back(7527); }
     484      else if (word2 == "NEAR") { word2.clear(); word2.push_back(7527); word2.appendcarr("NEAR", 4); word2.push_back(7527); }
     485      else if (word2 == "WITHIN") { word2.clear(); word2.push_back(7527); word2.appendcarr("WITHIN", 6); word2.push_back(7527); }
     486      if (inquote) {
     487    word2.push_back(*here);
     488      }
     489      word.append(word2); word2.clear();
     490           
     491      if (!inquote && !word.empty() ) {
     492                // found word boundary   
     493               
     494    if (stem == "1" || fold =="1") {
     495      word += "#";
     496      if (stem == "1") word += "s";
     497      //else word += "u";
     498                   
     499      if (fold == "1") word += "i";
     500      //else word += "c";
     501    }
     502    if (firstword) {
     503      firstword = false;
     504    } else {
     505      outtext += " " + word_combine + " ";
     506    }
     507    outtext += "[" + word + "]:"+tag;
     508    word.clear();
     509      }
     510      ++here;
     511    } else if (*here == '\"') {
     512      word2.push_back(*here);
     513      inquote = !inquote;
     514      ++here;
     515    } else {
     516      // not word boundary
     517      word2.push_back(*here);
     518      ++here;   
     519    }
     520  }
     521   
     522  // get last word
     523  if (!word2.empty()) {
     524    if (word2 == "AND") { word2.clear(); word2.push_back(7527); word2.appendcarr("AND", 3); word2.push_back(7527); }
     525    else if (word2 == "OR") { word2.clear(); word2.push_back(7527); word2.appendcarr("OR", 2); word2.push_back(7527); }
     526    else if (word2 == "NOT") { word2.clear(); word2.push_back(7527); word2.appendcarr("NOT", 3); word2.push_back(7527); }
     527    else if (word2 == "NEAR") { word2.clear(); word2.push_back(7527); word2.appendcarr("NEAR", 4); word2.push_back(7527); }
     528    else if (word2 == "WITHIN") { word2.clear(); word2.push_back(7527); word2.appendcarr("WITHIN", 6); word2.push_back(7527); }
     529    word.append(word2); word2.clear();
     530       
     531    if (stem == "1"|| fold == "1") {
     532      word += "#";
     533      if (stem == "1") word += "s";
     534      //else word += "u";
     535           
     536      if (fold == "1") word += "i";
     537      //else word += "c";
     538    }
     539    if (!outtext.empty()) outtext += " " + word_combine + " ";
     540    outtext += "[" + word + "]:"+tag;
     541  }
     542  querystring += "(" + outtext + ")";
     543}
     544
     545
     546void format_field_info(text_t & querystring, const text_t &tag) {
    466547
    467548  if (tag == "ZZ" || tag == "") {
  • trunk/gsdl/src/recpt/querytools.h

    r6584 r7380  
    5656void parse_adv_query_form(text_t &formattedstring, cgiargsclass &args);
    5757
    58 void addqueryelem(text_t &querystring, text_t &tag,
    59           text_t &query, text_t combine);
    60 text_t addstemcase(text_t &terms, text_t &stem, text_t &fold);
     58void addqueryelem(text_t &querystring, const text_t &tag,
     59          const text_t &query, const text_t& combine);
     60void addqueryelem_ex(text_t &querystring, const text_t &tag,
     61             const text_t &terms, const text_t &stem, const text_t &fold,
     62             const text_t& combine, const text_t& word_combine);
     63text_t addstemcase(const text_t &terms, const text_t &stem, const text_t &fold);
    6164text_t formatelem(text_t &text);
    62 void format_field_info(text_t &querystring, text_t &tag);
     65void format_field_info(text_t &querystring, const text_t &tag);
     66
    6367#endif
    64 
    65 
    66 
    67 
Note: See TracChangeset for help on using the changeset viewer.