source: trunk/gsdl/src/recpt/converter.cpp@ 919

Last change on this file since 919 was 533, checked in by sjboddie, 25 years ago

added GPL notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/**********************************************************************
2 *
3 * converter.cpp --
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 * $Id: converter.cpp 533 1999-09-07 04:57:01Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.4 1999/09/07 04:56:54 sjboddie
31 added GPL notice
32
33 Revision 1.3 1999/09/02 00:25:27 rjmcnab
34 changes to get compiling on AIX
35
36 Revision 1.2 1999/02/21 22:33:54 rjmcnab
37 Lots of stuff :-)
38
39 Revision 1.1 1999/02/05 10:42:45 rjmcnab
40
41 Continued working on receptionist
42
43 */
44
45
46#include "converter.h"
47
48
49
50// the converters within converterinfo become the property of
51// of this class after add_converter has been called. The converters
52// remain the responsability of the calling code and will not be
53// deleted by this class.
54void convertinfoclass::add_converter (const text_t &name, inconvertclass *inconverter,
55 rzwsoutconvertclass *outconverter) {
56 // can't add a null converter or an action with no name
57 if (inconverter == NULL || outconverter == NULL || name.empty()) {
58 return;
59 }
60
61 converterinfo info;
62 info.name = name;
63 info.inconverter = inconverter;
64 info.outconverter = outconverter;
65 converters[name] = info;
66}
67
68
69bool operator==(const converterinfo &x, const converterinfo &y) {
70 return ((x.name == y.name) && (x.inconverter == y.inconverter) &&
71 (x.outconverter == y.outconverter));
72}
73
74bool operator<(const converterinfo &x, const converterinfo &y) {
75 return ((x.name < y.name) ||
76 ((x.name == y.name) &&
77 ((x.inconverter < y.inconverter) ||
78 ((x.inconverter == y.inconverter) &&
79 ((x.outconverter < y.outconverter))))));
80}
81
82
83// get_inconverter will return NULL if the convert could not be found
84inconvertclass *convertinfoclass::get_inconverter (const text_t &name) {
85 iterator here = converters.find (name);
86 if (here == converters.end()) return NULL;
87
88 return (*here).second.inconverter;
89}
90
91// get_outconverter will return NULL if the convert could not be found
92rzwsoutconvertclass *convertinfoclass::get_outconverter (const text_t &name) {
93 iterator here = converters.find (name);
94 if (here == converters.end()) return NULL;
95
96 return (*here).second.outconverter;
97}
98
Note: See TracBrowser for help on using the repository browser.