Changeset 410 for trunk/gsdl/src/recpt/formattools.cpp
- Timestamp:
- 1999-07-21T17:00:00+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/formattools.cpp
r407 r410 12 12 /* 13 13 $Log$ 14 Revision 1.5 1999/07/21 05:00:00 sjboddie 15 added some date formatting 16 14 17 Revision 1.4 1999/07/20 03:02:15 sjboddie 15 18 added an [icon] option, added ability to call get_formatted_string … … 34 37 35 38 36 37 38 39 39 // a few function prototypes 40 40 static text_t format_string (const ResultDocInfo_t &docinfo, format_t *formatlistptr, … … 45 45 text_tmap &metamap, int &metacount); 46 46 47 48 49 47 void metadata_t::clear() { 48 metaname.clear(); 50 49 metaindex = 0; 51 50 parentcommand = pNone; … … 58 57 meta.clear(); 59 58 }; 60 61 59 62 60 void format_t::clear() { … … 71 69 }; 72 70 73 74 71 // returns a date of form _textmonthnn_ 31, 1999 72 // input is date of type 19991231 73 // at least the year must be present in date 74 static text_t format_date (const text_t &date) { 75 76 if (date.size() < 4) return ""; 77 78 text_t::const_iterator datebegin = date.begin(); 79 80 text_t year = substr (datebegin, datebegin+4); 81 82 if (date.size() < 6) return year; 83 84 text_t month = "_textmonth" + substr (datebegin+4, datebegin+6) + "_"; 85 int imonth = month.getint(); 86 if (imonth < 0 || imonth > 12) return year; 87 88 if (date.size() < 8) return month + ", " + year; 89 90 text_t day = substr (datebegin+6, datebegin+8); 91 if (day[0] == '0') day = substr (day.begin()+1, day.end()); 92 int iday = day.getint(); 93 if (iday < 0 || iday > 31) return month + ", " + year; 94 95 return month + " " + day + ", " + year; 96 } 75 97 76 98 static void get_parent_options (text_t &instring, metadata_t &metaoption) { … … 145 167 else { 146 168 formatlistptr->command = comMeta; 169 formatlistptr->meta.metaname = meta; 147 170 if (meta.size() > 7 && (substr (meta.begin(), meta.begin()+6) == "parent")) { 148 171 getParents = true; … … 153 176 text_tmap::const_iterator it; 154 177 if ((it = metamap.find(meta)) != metamap.end()) { 155 (formatlistptr->meta).metaindex = (*it).second.getint();178 formatlistptr->meta.metaindex = (*it).second.getint(); 156 179 } else { 157 180 metamap[meta] = count; 158 181 metadata.push_back (meta); 159 (formatlistptr->meta).metaindex = count;182 formatlistptr->meta.metaindex = count; 160 183 count ++; 161 184 } … … 347 370 348 371 372 // note: all the format_date stuff is assuming that all Date metadata is going to 373 // be of the form yyyymmdd, this is of course, crap ;) 349 374 350 375 static text_t get_meta (const ResultDocInfo_t &docinfo, const metadata_t &meta) { … … 356 381 switch (meta.parentcommand) { 357 382 case pNone: 383 if (meta.metaname == "Date") 384 return format_date (docinfo.metadata[mindex].values.back()); 358 385 return docinfo.metadata[mindex].values.back(); 359 386 360 387 case pImmediate: 361 if (valuesize > 1) 388 if (valuesize > 1) { 389 if (meta.metaname == "Date") 390 return format_date (docinfo.metadata[mindex].values[metasize-2]); 362 391 return docinfo.metadata[mindex].values[metasize-2]; 392 } 363 393 break; 364 394 365 395 case pTop: 366 if (valuesize > 1) 396 if (valuesize > 1) { 397 if (meta.metaname == "Date") 398 return format_date (docinfo.metadata[mindex].values[0]); 367 399 return docinfo.metadata[mindex].values[0]; 400 } 368 401 break; 369 402 370 403 case pIndex: 371 if (valuesize > meta.parentindex) 404 if (valuesize > meta.parentindex) { 405 if (meta.metaname == "Date") 406 return format_date (docinfo.metadata[mindex].values[meta.parentindex]); 372 407 return docinfo.metadata[mindex].values[meta.parentindex]; 408 } 373 409 break; 374 410 … … 383 419 while (here != end) { 384 420 if (!first) tmp += meta.parentoptions; 385 tmp += *here; 421 if (meta.metaname == "Date") tmp += format_date (*here); 422 else tmp += *here; 386 423 first = false; 387 424 here ++;
Note:
See TracChangeset
for help on using the changeset viewer.