Changeset 211


Ignore:
Timestamp:
1999-03-25T15:13:42+12:00 (25 years ago)
Author:
sjboddie
Message:

More library functions for dealing with OIDs. Many of them just
return dummy data at present

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

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/OIDtools.cpp

    r189 r211  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/03/25 03:13:42  sjboddie
     15
     16   More library functions for dealing with OIDs. Many of them just
     17   return dummy data at present
     18
    1419   Revision 1.2  1999/03/05 03:53:53  sjboddie
    1520
     
    2631
    2732// get first four characters of whatever string is passed in
    28 // targetdoc. targetdoc will normally be either a document
    29 // or classification OID so this returns the CLSU, HASH etc.
    30 void get_head (const text_t &targetdoc, text_t &head) {
     33// OID. This returns the CLSU, HASH etc.
     34void get_head (const text_t &OID, text_t &head) {
    3135
    3236  head.clear();
    33   if (targetdoc.size() < 4) return;
    34   head.appendrange (targetdoc.begin(), (targetdoc.begin() + 4));
     37  if (OID.size() < 4) return;
     38  head.appendrange (OID.begin(), (OID.begin() + 4));
    3539}
    3640
    3741
    38 // returns (in top) the top level of targetdoc (i.e. everything
     42// returns (in top) the top level of OID (i.e. everything
    3943// up until the first dot)
    40 void get_top (const text_t &targetdoc, text_t &top) {
     44void get_top (const text_t &OID, text_t &top) {
    4145
    4246  top.clear();
    43   text_t::const_iterator begin = targetdoc.begin();
    44   text_t::const_iterator end = targetdoc.end();
     47  text_t::const_iterator begin = OID.begin();
     48  text_t::const_iterator end = OID.end();
    4549
    4650  top.appendrange (begin, findchar(begin, end, '.'));
     
    4852
    4953
    50 // checks if targetdoc is top level of a document (i.e. contains no dots)
    51 bool is_top (const text_t &targetdoc) {
     54// checks if OID is top level (i.e. contains no dots)
     55bool is_top (const text_t &OID) {
    5256
    53   text_t::const_iterator here = targetdoc.begin();
    54   text_t::const_iterator end = targetdoc.end();
     57  if (OID.empty()) return true;
     58
     59  text_t::const_iterator here = OID.begin();
     60  text_t::const_iterator end = OID.end();
    5561  here = findchar (here, end, '.');
    5662
     
    5864  return false;
    5965}
     66
     67
     68// is_classification checks OID to see if it's a classification
     69// or a document. I'm not sure how to do this - for now I'll just assume
     70// all documents start with HASH and classifications start with something
     71// else.
     72bool is_classification (const text_t &OID) {
     73  text_t head;
     74  get_head (OID, head);
     75  if (head == "HASH") return false;
     76  return true;
     77}
     78
     79
     80// don't know how to do this yet either ...
     81bool contains_text (const text_t &OID) {
     82  return true;
     83}
     84
     85
     86// get_parents_array loads the parents array with all the parents of the
     87// document or classification specified by OID
     88// note that this function doesn't clear the parents array
     89void get_parents_array (const text_t &OID, text_tarray &parents) {
     90
     91  text_t::const_iterator here = OID.begin ();
     92  text_t::const_iterator end = OID.end ();
     93  text_t thisparent;
     94
     95  while (here != end) {
     96    if (*here == '.') parents.push_back(thisparent);
     97    thisparent.push_back(*here);
     98    here ++;
     99  }
     100}
     101
     102
     103// get_children_array loads the children array with all the children of the
     104// document or classification specified by OID
     105void get_children_array (const text_t &OID, text_tarray &children) {
     106
     107  children.erase(children.begin(), children.end());
     108
     109  // just stuff some rubish in for now
     110  children.push_back (OID + ".1");
     111  children.push_back (OID + ".2");
     112  children.push_back (OID + ".3");
     113  children.push_back (OID + ".4");
     114  children.push_back (OID + ".5");
     115  children.push_back (OID + ".6");
     116  children.push_back (OID + ".7");
     117}
     118
     119
     120// get_parent returns the parent of the document or classification
     121// specified by OID
     122text_t get_parent (text_t OID) {
     123
     124  if (OID.empty() || is_top (OID)) return "";
     125
     126  text_t::const_iterator begin = OID.begin();
     127  text_t::const_iterator here = (OID.end() - 1);
     128
     129  while (here >= begin) {
     130    OID.pop_back();
     131    if (*here == '.') break;
     132    here --;
     133  }
     134  return OID;
     135}
     136
     137
     138// get_first_child loads child with the first
     139// child of OID
     140void get_first_child(const text_t &OID, text_t &child) {
     141  // shove something in for now - I think we'll need to
     142  // look up db here
     143  child.clear();
     144  child += OID + ".1";
     145}
  • trunk/gsdl/src/recpt/OIDtools.h

    r189 r211  
    1717
    1818// get first four characters of whatever string is passed in
    19 // targetdoc. targetdoc will normally be either a document
    20 // or classification OID so this returns the CLSU, HASH etc.
    21 void get_head (const text_t &targetdoc, text_t &head);
     19// OID. This returns the CLSU, HASH etc.
     20void get_head (const text_t &OID, text_t &head);
    2221
    23 // returns (in top) the top level of targetdoc (i.e. everything
     22// returns (in top) the top level of OID (i.e. everything
    2423// up until the first dot)
    25 void get_top (const text_t &targetdoc, text_t &top);
     24void get_top (const text_t &OID, text_t &top);
    2625
    27 // checks if targetdoc is top level of a document (i.e. contains no dots)
    28 bool is_top (const text_t &targetdoc);
     26// checks if OID is top level (i.e. contains no dots)
     27bool is_top (const text_t &OID);
    2928
     29// is_classification checks OID to see if it's a classification
     30// or a document. I'm not sure how to do this - for now I'll just assume
     31// all documents start with HASH and classifications start with something
     32// else.
     33bool is_classification (const text_t &OID);
     34
     35// don't know how to do this yet either ...
     36bool contains_text (const text_t &OID);
     37
     38// get_parents_array loads the parents array with all the parents of the
     39// document or classification specified by OID
     40// note that this function doesn't clear the parents array
     41void get_parents_array (const text_t &OID, text_tarray &parents);
     42
     43// get_children loads the children array with all the children of the
     44// document or classification specified by targetdoc
     45void get_children_array (const text_t &OID, text_tarray &children);
     46
     47// get_parent returns the parent of the document or classification
     48// specified by OID
     49text_t get_parent (text_t OID);
     50 
     51// get_first_child loads child with the first
     52// child of OID
     53void get_first_child(const text_t &OID, text_t &child);
    3054
    3155
Note: See TracChangeset for help on using the changeset viewer.