Ignore:
Timestamp:
1999-02-03T14:13:30+13:00 (25 years ago)
Author:
sjboddie
Message:

Got interface to handle subcollections and language subcollections -
committed changes made to some of the collections

Location:
trunk/gsdl/src/colservr
Files:
2 edited

Legend:

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

    r114 r138  
    1212/*
    1313   $Log$
     14   Revision 1.4  1999/02/03 01:13:27  sjboddie
     15
     16   Got interface to handle subcollections and language subcollections -
     17   committed changes made to some of the collections
     18
    1419   Revision 1.3  1999/01/19 01:38:17  rjmcnab
    1520
     
    7378/////////////////////////
    7479
    75 void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex) {
    76   realindex.clear ();
    77   dirindex.clear();
     80void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart) {
     81  realpart.clear ();
     82  dirpart.clear();
    7883
    7984  text_t::const_iterator here = map.begin();
     
    8287  // get the real index
    8388  while (here != end && *here != '-') {
    84     realindex.push_back(*here);
     89    realpart.push_back(*here);
    8590    here++;
    8691  }
     
    9196  // get the dir index
    9297  while (here != end) {
    93     dirindex.push_back(*here);
    94     here++;
    95   }
    96 }
    97 
    98 bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) {
     98    dirpart.push_back(*here);
     99    here++;
     100  }
     101}
     102
     103void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
     104              const text_t &languagemap, text_t &realindex,
     105              text_t &dirindex) {
     106  text_t real, dir;
     107  realindex.clear();
     108  dirindex.clear();
     109
     110  getrealdir (indexmap, real, dir);
     111  realindex += real;
     112  dirindex += dir;
     113
     114  getrealdir (subcollectionmap, real, dir);
     115  realindex += real;
     116  dirindex += dir;
     117
     118  getrealdir (languagemap, real, dir);
     119  realindex += real;
     120  dirindex += dir;
     121}
     122
     123//bool isdirindex (const text_tarray &indexmap, const text_t &dirindex) {
     124// text_tarray::const_iterator here = indexmap.begin();
     125//  text_tarray::const_iterator end = indexmap.end();
     126//  text_t maprealindex, mapdirindex;
     127
     128//  while (here != end) {
     129//    getrealdirindex (*here, maprealindex, mapdirindex);
     130//    if (mapdirindex == dirindex) return true;
     131//    here++;
     132//  }
     133
     134//  return false;
     135//}
     136
     137void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     138            const text_tarray &languagemap, const text_t &realindex,
     139            text_t &index, text_t &subcollection, text_t &language) {
     140
     141  index.clear();
     142  subcollection.clear();
     143  language.clear();
     144
     145  text_tarray parts;
     146  splitchar (realindex.begin(), realindex.end(), ':', parts);
     147  int numparts = parts.size();
     148
     149  if (numparts >= 2) {
     150    index = parts[0] + ":" + parts[1];
     151
     152    if (numparts == 3) {
     153      if (languagemap.empty())
     154    subcollection = parts[2];
     155      else
     156    language = parts[2];
     157    } else if (numparts == 4) {
     158      subcollection = parts[2];
     159      language = parts[3];
     160    }
     161  }
     162}
     163
     164
     165void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     166               const text_tarray &languagemap, const text_t &dirindex,
     167               text_t &index, text_t &subcollection, text_t &language) {
     168
     169  index.clear();
     170  subcollection.clear();
     171  language.clear();
     172
     173  int indexsize = dirindex.size();
     174  if (indexsize != 3 && indexsize != 5 &&
     175      indexsize != 7) return;
     176 
     177  text_t::const_iterator dibegin = dirindex.begin();
     178  text_t::const_iterator diend = dirindex.end(); 
     179
     180  // first three characters make up index part
     181  index = substr(dibegin, dibegin+3);
     182
     183  if (indexsize == 5) {
     184    if (languagemap.empty())
     185      subcollection = substr(dibegin+3, dibegin+5);
     186    else
     187      language = substr(dibegin+3, dibegin+5);
     188  } else if (indexsize == 7) {
     189    subcollection = substr(dibegin+3, dibegin+5);
     190    language = substr(dibegin+5, diend);
     191  }
     192}
     193 
     194
     195bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     196          const text_tarray &languagemap, const text_t &realindex) {
     197     
     198  text_t index, subcollection, language, realpart, dirpart;
     199  getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,
     200             index, subcollection, language);
     201
     202  // check index part
    99203  text_tarray::const_iterator here = indexmap.begin();
    100204  text_tarray::const_iterator end = indexmap.end();
    101   text_t maprealindex, mapdirindex;
    102 
    103   while (here != end) {
    104     getrealdirindex (*here, maprealindex, mapdirindex);
    105     if (mapdirindex == dirindex) return true;
    106     here++;
    107   }
    108 
    109   return false;
    110 }
    111 
    112 bool isrealindex (const text_tarray &indexmap, const text_t &realindex) {
     205  bool exists = false;
     206  while (here != end) {
     207    getrealdir (*here, realpart, dirpart);
     208    if (realpart == index) {exists = true; break;}
     209    here++;
     210  }
     211  if (!exists) return false;
     212
     213  // check subcollection part if there is one
     214  if (!subcollection.empty()) {
     215    here = subcollectionmap.begin();
     216    end = subcollectionmap.end();
     217    exists = false;
     218    while (here != end) {
     219      getrealdir (*here, realpart, dirpart);
     220      if (realpart == subcollection) {exists = true; break;}
     221    here++;
     222  }
     223  if (!exists) return false;
     224  }
     225
     226  // check language part if there is one
     227  if (!language.empty()) {
     228    here = languagemap.begin();
     229    end = languagemap.end();
     230    exists = false;
     231    while (here != end) {
     232      getrealdir (*here, realpart, dirpart);
     233      if (realpart == language) {exists = true; break;}
     234    here++;
     235  }
     236  if (!exists) return false;
     237  }
     238  return true;
     239}
     240
     241text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     242              const text_tarray &languagemap, const text_t &dirindex) {
     243
     244  text_t index, subcollection, language, realpart, dirpart, realindex;
     245  getdirindexparts (indexmap, subcollectionmap, languagemap, dirindex,
     246            index, subcollection, language);
     247
     248  // get index part
    113249  text_tarray::const_iterator here = indexmap.begin();
    114250  text_tarray::const_iterator end = indexmap.end();
    115   text_t maprealindex, mapdirindex;
    116 
    117   while (here != end) {
    118     getrealdirindex (*here, maprealindex, mapdirindex);
    119     if (maprealindex == realindex) return true;
    120     here++;
    121   }
    122 
    123   return false;
    124 }
    125 
    126 text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex) {
     251  while (here != end) {
     252    getrealdir (*here, realpart, dirpart);
     253    if (dirpart == index) {realindex += realpart; break;}
     254    here++;
     255  }
     256 
     257  if (realindex.empty()) return "";
     258
     259  // get subcollection part
     260  here = subcollectionmap.begin();
     261  end = subcollectionmap.end();
     262  while (here != end) {
     263    getrealdir (*here, realpart, dirpart);
     264    if (dirpart == subcollection) {realindex += ":" + realpart; break;}
     265    here++;
     266  }
     267 
     268  // get language part
     269  here = languagemap.begin();
     270  end = languagemap.end();
     271  while (here != end) {
     272    getrealdir (*here, realpart, dirpart);
     273    if (dirpart == language) {realindex += ":" + realpart; break;}
     274    here++;
     275  }
     276  return realindex;
     277}
     278
     279text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     280              const text_tarray &languagemap, const text_t &realindex) {
     281
     282  text_t index, subcollection, language, realpart, dirpart, dirindex;
     283  getrealindexparts (indexmap, subcollectionmap, languagemap, realindex,
     284             index, subcollection, language);
     285
     286  // get index part
    127287  text_tarray::const_iterator here = indexmap.begin();
    128288  text_tarray::const_iterator end = indexmap.end();
    129   text_t maprealindex, mapdirindex;
    130 
    131   while (here != end) {
    132     getrealdirindex (*here, maprealindex, mapdirindex);
    133     if (mapdirindex == dirindex) return maprealindex;
    134     here++;
    135   }
    136 
    137   return "";
    138 }
    139 
    140 text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex) {
    141   text_tarray::const_iterator here = indexmap.begin();
    142   text_tarray::const_iterator end = indexmap.end();
    143   text_t maprealindex, mapdirindex;
    144 
    145   while (here != end) {
    146     getrealdirindex (*here, maprealindex, mapdirindex);
    147     if (maprealindex == realindex) return mapdirindex;
    148     here++;
    149   }
    150 
    151   return "";
     289  while (here != end) {
     290    getrealdir (*here, realpart, dirpart);
     291    if (realpart == index) {dirindex += dirpart; break;}
     292    here++;
     293  }
     294 
     295  if (dirindex.empty()) return "";
     296
     297  // get subcollection part
     298  here = subcollectionmap.begin();
     299  end = subcollectionmap.end();
     300  while (here != end) {
     301    getrealdir (*here, realpart, dirpart);
     302    if (realpart == subcollection) {dirindex += dirpart; break;}
     303    here++;
     304  }
     305 
     306  // get language part
     307  here = languagemap.begin();
     308  end = languagemap.end();
     309  while (here != end) {
     310    getrealdir (*here, realpart, dirpart);
     311    if (realpart == language) {dirindex += dirpart; break;}
     312    here++;
     313  }
     314  return dirindex;
    152315}
    153316
     
    186349
    187350text_t getdoclevelindex (const text_tarray &indexmap) {
    188   text_tarray::const_iterator here = indexmap.begin();
    189   text_tarray::const_iterator end = indexmap.end();
    190   text_t maprealindex, mapdirindex;
    191  
    192   while (here != end) {
    193     getrealdirindex (*here, maprealindex, mapdirindex);
    194     if (isdoclevelindex (maprealindex)) return maprealindex;
    195     here++;
    196   }
     351  //text_tarray::const_iterator here = indexmap.begin();
     352  //text_tarray::const_iterator end = indexmap.end();
     353  //text_t maprealindex, mapdirindex;
     354 
     355  //  while (here != end) {
     356  //  getrealdirindex (*here, maprealindex, mapdirindex);
     357  //  if (isdoclevelindex (maprealindex)) return maprealindex;
     358  //  here++;
     359  //}
    197360 
    198361  return "";
  • trunk/gsdl/src/colservr/mgsearch.h

    r110 r138  
    2525// appear within the index directory) and real indexes (indexes as they
    2626// appear within the collect.cfg file) and mappings between them.
    27 void getrealdirindex (const text_t &map, text_t &realindex, text_t &dirindex);
     27void getdirindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     28               const text_tarray &languagemap, const text_t &dirindex,
     29               text_t &index, text_t &subcollection, text_t &language);
     30void getrealindexparts (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     31            const text_tarray &languagemap, const text_t &realindex,
     32            text_t &index, text_t &subcollection, text_t &language);
     33void getrealdir (const text_t &map, text_t &realpart, text_t &dirpart);
     34void getrealdirindex (const text_t &indexmap, const text_t &subcollectionmap,
     35              const text_t &languagemap, text_t &realindex,
     36              text_t &dirindex);
    2837bool isdirindex (const text_tarray &indexmap, const text_t &dirindex);
    29 bool isrealindex (const text_tarray &indexmap, const text_t &realindex);
    30 text_t dir2realindex (const text_tarray &indexmap, const text_t &dirindex);
    31 text_t real2dirindex (const text_tarray &indexmap, const text_t &realindex);
     38bool isrealindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     39          const text_tarray &languagemap, const text_t &realindex);
     40text_t dir2realindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     41              const text_tarray &languagemap, const text_t &dirindex);
     42text_t real2dirindex (const text_tarray &indexmap, const text_tarray &subcollectionmap,
     43              const text_tarray &languagemap, const text_t &realindex);
    3244text_t real2macroindex (const text_t &realindex);
    3345bool isdoclevelindex (const text_t &realindex);
Note: See TracChangeset for help on using the changeset viewer.