[150] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * converter.cpp --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[533] | 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.
|
---|
[150] | 9 | *
|
---|
[533] | 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 | *
|
---|
[150] | 24 | * $Id: converter.cpp 533 1999-09-07 04:57:01Z sjboddie $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | /*
|
---|
| 29 | $Log$
|
---|
[533] | 30 | Revision 1.4 1999/09/07 04:56:54 sjboddie
|
---|
| 31 | added GPL notice
|
---|
| 32 |
|
---|
[509] | 33 | Revision 1.3 1999/09/02 00:25:27 rjmcnab
|
---|
| 34 | changes to get compiling on AIX
|
---|
| 35 |
|
---|
[164] | 36 | Revision 1.2 1999/02/21 22:33:54 rjmcnab
|
---|
| 37 | Lots of stuff :-)
|
---|
| 38 |
|
---|
[150] | 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
|
---|
[164] | 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.
|
---|
[150] | 54 | void 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 |
|
---|
[509] | 68 |
|
---|
| 69 | bool operator==(const converterinfo &x, const converterinfo &y) {
|
---|
| 70 | return ((x.name == y.name) && (x.inconverter == y.inconverter) &&
|
---|
| 71 | (x.outconverter == y.outconverter));
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | bool 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 |
|
---|
[150] | 83 | // get_inconverter will return NULL if the convert could not be found
|
---|
| 84 | inconvertclass *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
|
---|
| 92 | rzwsoutconvertclass *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 |
|
---|