Changeset 397 for trunk/gsdl/src/recpt/querytools.cpp
- Timestamp:
- 1999-07-16T12:19:02+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/querytools.cpp
r349 r397 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/07/16 00:19:02 sjboddie 15 some changes to the way quoted queries are handled 16 14 17 Revision 1.2 1999/07/07 06:12:21 rjmcnab 15 18 Added ability to combine two independant queries. … … 29 32 // request.filterResultOptions and request.fields (if required) 30 33 // should be set by the calling function. 31 // If the query string uses quotes (phrase-searching) the quoted32 // part of the string is returned in quotedstring (as something33 // of a side-effect ;-/34 34 35 35 bool do_query (FilterRequest_t &request, cgiargsclass &args, 36 recptproto *collectproto, text_t "edstring,37 FilterResponse_t &response,ostream &logout) {36 recptproto *collectproto, FilterResponse_t &response, 37 ostream &logout) { 38 38 39 39 request.filterName = "QueryFilter"; … … 42 42 OptionValue_t option; 43 43 text_t formattedstring = args["q"]; 44 45 // format the query string ready to do the query (and remember46 // the quoted part for later)47 format_querystring (formattedstring, quotedstring);48 44 49 45 option.name = "Term"; … … 87 83 request.filterOptions.push_back (option); 88 84 89 text_t quotedstring2;90 85 text_t formattedstring2 = args["q2"]; 91 format_querystring (formattedstring2 , quotedstring2);86 format_querystring (formattedstring2); 92 87 93 88 option.name = "Term"; … … 149 144 } 150 145 151 void format_querystring (text_t &querystring , text_t "edstring) {146 void format_querystring (text_t &querystring) { 152 147 text_t formattedstring; 153 quotedstring.clear();154 148 155 149 text_t::const_iterator here = querystring.begin(); 156 150 text_t::const_iterator end = querystring.end(); 157 int foundquote = 0;158 151 159 152 // space is used to insert spaces between Chinese … … 169 162 formattedstring.push_back(' '); 170 163 } else { 171 if (*here == '"') { 172 if (foundquote) {foundquote = 0; quotedstring.push_back(*here);} 173 else foundquote = 1; 164 if ((*here >= 0x4e00 && *here <= 0x9fa5) || 165 (*here >= 0xf900 && *here <= 0xfa2d)) { 166 // Chinese character 167 if (space) formattedstring.push_back (0x200b); 168 formattedstring.push_back (*here); 169 formattedstring.push_back (0x200b); 170 space = true; 174 171 } else { 175 if ((*here >= 0x4e00 && *here <= 0x9fa5) || 176 (*here >= 0xf900 && *here <= 0xfa2d)) { 177 // Chinese character 178 if (space) formattedstring.push_back (0x200b); 179 formattedstring.push_back (*here); 180 formattedstring.push_back (0x200b); 181 space = true; 182 } else { 183 // non-Chinese character 184 formattedstring.push_back (*here); 185 space = false; 186 } 172 // non-Chinese character 173 formattedstring.push_back (*here); 174 space = false; 187 175 } 188 if (foundquote) quotedstring.push_back(*here);189 176 } 190 177 here ++; 191 178 } 192 querystring = formattedstring + quotedstring;179 querystring = formattedstring; 193 180 } 194 181
Note:
See TracChangeset
for help on using the changeset viewer.