Changeset 211
- Timestamp:
- 1999-03-25T15:13:42+12:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/OIDtools.cpp
r189 r211 12 12 /* 13 13 $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 14 19 Revision 1.2 1999/03/05 03:53:53 sjboddie 15 20 … … 26 31 27 32 // 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. 34 void get_head (const text_t &OID, text_t &head) { 31 35 32 36 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)); 35 39 } 36 40 37 41 38 // returns (in top) the top level of targetdoc(i.e. everything42 // returns (in top) the top level of OID (i.e. everything 39 43 // up until the first dot) 40 void get_top (const text_t & targetdoc, text_t &top) {44 void get_top (const text_t &OID, text_t &top) { 41 45 42 46 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(); 45 49 46 50 top.appendrange (begin, findchar(begin, end, '.')); … … 48 52 49 53 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) 55 bool is_top (const text_t &OID) { 52 56 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(); 55 61 here = findchar (here, end, '.'); 56 62 … … 58 64 return false; 59 65 } 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. 72 bool 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 ... 81 bool 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 89 void 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 105 void 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 122 text_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 140 void 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 17 17 18 18 // 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. 20 void get_head (const text_t &OID, text_t &head); 22 21 23 // returns (in top) the top level of targetdoc(i.e. everything22 // returns (in top) the top level of OID (i.e. everything 24 23 // up until the first dot) 25 void get_top (const text_t & targetdoc, text_t &top);24 void get_top (const text_t &OID, text_t &top); 26 25 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) 27 bool is_top (const text_t &OID); 29 28 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. 33 bool is_classification (const text_t &OID); 34 35 // don't know how to do this yet either ... 36 bool 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 41 void 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 45 void 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 49 text_t get_parent (text_t OID); 50 51 // get_first_child loads child with the first 52 // child of OID 53 void get_first_child(const text_t &OID, text_t &child); 30 54 31 55
Note:
See TracChangeset
for help on using the changeset viewer.