Changeset 460 for trunk


Ignore:
Timestamp:
1999-08-13T16:20:27+12:00 (25 years ago)
Author:
sjboddie
Message:

added ability to get return all available metadata when 'fields' is empty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/mggdbmsource.cpp

    r350 r460  
    1212/*
    1313   $Log$
     14   Revision 1.13  1999/08/13 04:20:27  sjboddie
     15   added ability to get return all available metadata when 'fields' is empty
     16
    1417   Revision 1.12  1999/07/07 06:17:47  rjmcnab
    1518   broke search_index into index+subcollection+language
     
    109112  // get the filename for the database and make sure it exists
    110113  gdbm_filename = filename_cat(collectdir,"index","text",collection);
     114
     115  // temporary hack for niupepa
     116  if (collection == "niupepa")
     117    gdbm_filename = filename_cat(collectdir,"index.new","text",collection);
     118
    111119#ifdef _LITTLE_ENDIAN
    112120  gdbm_filename += ".ldb";
     
    207215  }
    208216
     217  // if fields array is empty we want to get all available metadata
     218  text_tarray tfields = fields;
     219  if (tfields.empty() && !info_array.empty()) {
     220    infodbclass::iterator t_info = info_array[0].begin();
     221    infodbclass::iterator e_info = info_array[0].end();
     222    while (t_info != e_info) {
     223      if ((*t_info).first != "contains")
     224    tfields.push_back ((*t_info).first);
     225      t_info ++;
     226    }
     227    tfields.push_back ("hasnext");
     228    tfields.push_back ("hasprevious");
     229  }
     230   
    209231  // collect together the metadata
    210232  bool donenextprevtest = false;
     
    212234  MetadataInfo_t this_metadata;
    213235  text_t *pos_metadata;
    214   text_tarray::const_iterator fields_here = fields.begin();
    215   text_tarray::const_iterator fields_end = fields.end();
     236  text_tarray::const_iterator fields_here = tfields.begin();
     237  text_tarray::const_iterator fields_end = tfields.end();
    216238  while (fields_here != fields_end) {
    217239    this_metadata.clear();
     
    266288   
    267289    // fill in metadata
     290    this_metadata.name = *fields_here;
    268291    if ((*fields_here == "hasnext" && hasnext) ||
    269292        (*fields_here == "hasprevious" && hasprevious))
     
    273296   
    274297      }
    275       else if (pos_metadata != NULL && *fields_here != "contains")
     298      else if (pos_metadata != NULL && *fields_here != "contains") {
     299    this_metadata.name = *fields_here;
    276300    this_metadata.values.push_back(*pos_metadata);
    277       else
     301      } else {
     302    this_metadata.name = *fields_here;
    278303    this_metadata.values.push_back("");
    279      
     304      }
    280305
    281306      this_info++;
Note: See TracChangeset for help on using the changeset viewer.