source: trunk/gsdl/src/recpt/OIDtools.h@ 11259

Last change on this file since 11259 was 11259, checked in by mdewsnip, 18 years ago

Various little bug fixes and improvements (many to get things working with Visual Studio 2005), by Emanuel Dejanu.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/**********************************************************************
2 *
3 * OIDtools.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26
27#ifndef OIDTOOLS_H
28#define OIDTOOLS_H
29
30#include "text_t.h"
31#include "recptproto.h"
32
33void get_oid (const text_t &OID, text_t &to, size_t level);
34
35// returns (in top) the top level of OID (i.e. everything
36// up until the first dot)
37void get_top (const text_t &OID, text_t &top);
38
39// checks if OID is top level (i.e. contains no dots)
40bool is_top (const text_t &OID);
41
42// get_parents_array loads the parents array with all the parents of the
43// document or classification specified by OID (not including OID itself)
44void get_parents_array (const text_t &OID, text_tarray &parents);
45
46// get_info does a protocol call and returns (in response) the info
47// associated with OID. Metadata should be loaded with whatever
48// metadata fields are to be requested
49bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
50 const text_tset &metadata, bool getParents,
51 recptproto *collectproto, FilterResponse_t &response,
52 ostream &logout);
53bool get_info (const text_t &OID, const text_t &collection, const text_t &lang,
54 const text_tset &metadata, const OptionValue_tarray &options,
55 bool getParents,
56 recptproto *collectproto, FilterResponse_t &response,
57 ostream &logout);
58bool get_info (const text_tarray &OIDs, const text_t &collection, const text_t &lang,
59 const text_tset &metadata, bool getParents,
60 recptproto *collectproto, FilterResponse_t &response,
61 ostream &logout);
62
63// has_children returns true if OID has children
64bool has_children (const text_t &OID, const text_t &collection, const text_t &lang,
65 recptproto *collectproto, ostream &logout);
66bool has_text(const text_t &OID, const text_t &collection, const text_t &lang,
67 recptproto *collectproto, ostream &logout);
68
69inline bool has_text(MetadataInfo_tmap& metadata)
70{
71 if (metadata["hastxt"].values.size() > 0) {
72 return metadata["hastxt"].values[0].getint() != 0;
73 }
74 return false;
75}
76
77inline bool has_children(MetadataInfo_tmap& metadata)
78{
79 if (metadata["haschildren"].values.size() > 0) {
80 return metadata["haschildren"].values[0].getint() != 0;
81 }
82 return false;
83}
84
85// get_children does a protocol call and returns (in response) the OIDs and
86// metadata of all the children of OID. The metadata set should be loaded
87// with whatever metadata fields are to be requested.
88bool get_children (const text_t &OID, const text_t &collection, const text_t &lang,
89 const text_tset &metadata, bool getParents,
90 recptproto *collectproto, FilterResponse_t &response,
91 ostream &logout);
92
93// get_parent returns the parent of the document or classification
94// specified by OID
95text_t get_parent (const text_t& OID);
96
97// takes an OID like ".2.3 and replaces the " with parent
98void translate_parent (text_t &OID, const text_t &parent);
99
100// shrink_parent does the opposite to translate_parent
101void shrink_parent (text_t &OID);
102
103// checks if OID uses ".fc", ".lc", ".pr", ".ns",
104// or ".ps" syntax (first child, last child, parent,
105// next sibling, previous sibling)
106bool needs_translating (const text_t &OID);
107
108// strips the ".fc", ".lc", ".pr", ".ns",
109// or ".ps" suffix from the end of OID
110void strip_suffix (text_t &OID);
111
112// get_contents returns OIDs and metadata of all contents
113// below (and including) OID.
114void get_contents (const text_t &topOID, const bool &is_classify,
115 text_tset &metadata, const text_t &collection, const text_t &lang,
116 recptproto *collectproto, FilterResponse_t &response,
117 ostream &logout);
118
119// is_child_of returns true if OID2 is a child of OID1
120bool is_child_of(const text_t &OID1, const text_t &OID2);
121
122
123#endif
Note: See TracBrowser for help on using the repository browser.