- Timestamp:
- 2017-02-08T20:07:14+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.cpp
r31387 r31390 449 449 // Method that looks for the requested metaname in the doc_info, and if found, sets the value 450 450 // in the argument 'metavalue'. 451 void oaiaction::getMeta(ResultDocInfo_t &doc_info, const text_t &metaname, text_t &metavalue) 452 { 453 text_t current_metaname; 454 451 bool oaiaction::getMeta(ResultDocInfo_t &doc_info, const text_t &metaname, text_t &metavalue) 452 { 455 453 //ofstream logout("oai.log", ios::app); 456 457 MetadataInfo_tmap::iterator current = doc_info.metadata.begin(); 458 MetadataInfo_tmap::iterator end = doc_info.metadata.end(); 459 460 while(current != end){ 461 current_metaname = current->first; 462 lc(current_metaname); // lowercased for string comparison below 463 464 if (current_metaname == metaname && current->second.values.size() >= 1) { // found match with a value 465 metavalue = current->second.values[0]; 466 467 //logout << "Looking for metaname = " << current_metaname << endl; 468 //logout << "\t\t\t Found value = " << metavalue << endl; 469 return; // done 470 } 471 472 ++current; 473 } 474 475 //logout.close(); 454 //logout << "oaiaction::getMeta(): Looking for metaname = " << metaname << endl; 455 456 // use map::find, rather than testing map["array-index"], as the latter will create that index and 457 // insert an empty value into it, when we just want to test for it. 458 // See http://www.cplusplus.com/reference/map/map/operator[]/ 459 // See also http://stackoverflow.com/questions/1939953/how-to-find-if-a-given-key-exists-in-a-c-stdmap 460 461 if(doc_info.metadata.find(metaname) == doc_info.metadata.end()) { 462 //logout << "\t\t\t Could not find meta " << metaname << endl; 463 //logout.close(); 464 return false; 465 } else { // found meta 466 metavalue = doc_info.metadata[metaname].values[0]; 467 //logout << "\t\t\t Found value = " << metavalue << endl; 468 //logout.close(); 469 return true; 470 } 471 476 472 } 477 473
Note:
See TracChangeset
for help on using the changeset viewer.