1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * OIDtools.h --
|
---|
4 | * Copyright (C) 1999-2008 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 | #ifndef OIDTOOLS_H
|
---|
27 | #define OIDTOOLS_H
|
---|
28 |
|
---|
29 | #include "text_t.h"
|
---|
30 |
|
---|
31 |
|
---|
32 | void get_oid (const text_t &OID, text_t &to, size_t level);
|
---|
33 |
|
---|
34 | // returns (in top) the top level of OID (i.e. everything
|
---|
35 | // up until the first dot)
|
---|
36 | void get_top (const text_t &OID, text_t &top);
|
---|
37 |
|
---|
38 | // checks if OID is top level (i.e. contains no dots)
|
---|
39 | bool is_top (const text_t &OID);
|
---|
40 |
|
---|
41 | // get_parents_array loads the parents array with all the parents of the
|
---|
42 | // document or classification specified by OID (not including OID itself)
|
---|
43 | void get_parents_array (const text_t &OID, text_tarray &parents);
|
---|
44 |
|
---|
45 | // get_parent returns the parent of the document or classification
|
---|
46 | // specified by OID
|
---|
47 | text_t get_parent (const text_t& OID);
|
---|
48 |
|
---|
49 | // takes an OID like ".2.3 and replaces the " with parent
|
---|
50 | void translate_parent (text_t &OID, const text_t &parent);
|
---|
51 |
|
---|
52 | // shrink_parent does the opposite to translate_parent
|
---|
53 | void shrink_parent (text_t &OID);
|
---|
54 |
|
---|
55 | // checks if OID uses ".fc", ".lc", ".pr", ".ns",
|
---|
56 | // or ".ps" syntax (first child, last child, parent,
|
---|
57 | // next sibling, previous sibling)
|
---|
58 | bool needs_translating (const text_t &OID);
|
---|
59 |
|
---|
60 | // strips the ".fc", ".lc", ".pr", ".ns",
|
---|
61 | // or ".ps" suffix from the end of OID
|
---|
62 | void strip_suffix (text_t &OID);
|
---|
63 |
|
---|
64 | // is_child_of returns true if OID2 is a child of OID1
|
---|
65 | bool is_child_of(const text_t &OID1, const text_t &OID2);
|
---|
66 |
|
---|
67 |
|
---|
68 | #endif
|
---|