Changeset 1373 for trunk/gsdl/src/recpt/querytools.cpp
- Timestamp:
- 2000-08-08T15:46:13+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/querytools.cpp
r1329 r1373 25 25 26 26 #include "querytools.h" 27 27 #include <ctype.h> 28 28 29 29 // request.filterResultOptions and request.fields (if required) should … … 185 185 } 186 186 187 void add_ands(text_t& querystring, int querytype) 188 { 189 190 if(querytype==0) 191 { 192 text_t formattedstring; 193 194 bool spacelast = false; 195 196 text_t::const_iterator here = querystring.begin(); 197 text_t::const_iterator end = querystring.end(); 198 199 200 querystring = formattedstring; 201 202 while(here!=end && isspace((*here))) 203 here++; 204 205 if(here==end) 206 return; 207 208 while(here!=end) 209 { 210 if(isspace((*here))) 211 { 212 while(here!=end && isspace((*here))) 213 here++; 214 if(here!=end) 215 formattedstring.appendcstr(" AND "); 216 } 217 if(!isspace((*here))) 218 { 219 formattedstring.push_back((*here)); 220 } 221 here++; 222 } 223 querystring = formattedstring; 224 } 225 } 226 227 228 229 void add_dates(text_t &querystring, int startdate, int enddate, 230 int startbc, int endbc) 231 { 232 if(startdate) 233 { 234 int querystringis = 0; 235 text_t::const_iterator here = querystring.begin(); 236 text_t::const_iterator end = querystring.end(); 237 while(here!=end) 238 { 239 if(!(isspace((*here)))){ 240 here = end; 241 querystringis = 1; 242 } 243 else 244 here++; 245 } 246 //converting BCE dates 247 if(startbc && startdate > 0) 248 { 249 startdate *= -1; 250 } 251 if(endbc && enddate > 0) 252 { 253 enddate *= -1; 254 } 255 if(enddate != 0 && enddate<startdate) 256 { 257 cout<<"enddate too small"<<endl; 258 return; 259 } 260 if(querystringis) 261 querystring.appendcstr(" AND"); 262 if(!enddate) 263 { 264 querystring.appendcstr(" ["); 265 querystring.appendint(startdate); 266 querystring.appendcstr("]:Date"); 267 } 268 else{ 269 int nextdate = startdate; 270 querystring.appendcstr(" ("); 271 while(nextdate<=enddate) 272 { 273 if(nextdate!=0) 274 { 275 querystring.appendcstr(" ["); 276 querystring.appendint(nextdate); 277 querystring.appendcstr("]:Date"); 278 } 279 nextdate++; 280 } 281 querystring.appendcstr(" )"); 282 } 283 } 284 } 187 285 void get_phrases (const text_t &querystring, text_tarray &phrases) { 188 286
Note:
See TracChangeset
for help on using the changeset viewer.