[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 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 | #include "converter.h"
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 |
|
---|
[1870] | 30 | // the converters within converterinfo become the property of this class
|
---|
| 31 | // after add_converter has been called. The converters remain the
|
---|
| 32 | // responsability of the calling code and will not be deleted by this
|
---|
| 33 | // class.
|
---|
[150] | 34 | void convertinfoclass::add_converter (const text_t &name, inconvertclass *inconverter,
|
---|
| 35 | rzwsoutconvertclass *outconverter) {
|
---|
| 36 | // can't add a null converter or an action with no name
|
---|
| 37 | if (inconverter == NULL || outconverter == NULL || name.empty()) {
|
---|
| 38 | return;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | converterinfo info;
|
---|
| 42 | info.name = name;
|
---|
| 43 | info.inconverter = inconverter;
|
---|
| 44 | info.outconverter = outconverter;
|
---|
| 45 | converters[name] = info;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[509] | 48 |
|
---|
| 49 | bool operator==(const converterinfo &x, const converterinfo &y) {
|
---|
| 50 | return ((x.name == y.name) && (x.inconverter == y.inconverter) &&
|
---|
| 51 | (x.outconverter == y.outconverter));
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | bool operator<(const converterinfo &x, const converterinfo &y) {
|
---|
| 55 | return ((x.name < y.name) ||
|
---|
| 56 | ((x.name == y.name) &&
|
---|
| 57 | ((x.inconverter < y.inconverter) ||
|
---|
| 58 | ((x.inconverter == y.inconverter) &&
|
---|
| 59 | ((x.outconverter < y.outconverter))))));
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 |
|
---|
[150] | 63 | // get_inconverter will return NULL if the convert could not be found
|
---|
| 64 | inconvertclass *convertinfoclass::get_inconverter (const text_t &name) {
|
---|
| 65 | iterator here = converters.find (name);
|
---|
| 66 | if (here == converters.end()) return NULL;
|
---|
| 67 |
|
---|
| 68 | return (*here).second.inconverter;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | // get_outconverter will return NULL if the convert could not be found
|
---|
| 72 | rzwsoutconvertclass *convertinfoclass::get_outconverter (const text_t &name) {
|
---|
| 73 | iterator here = converters.find (name);
|
---|
| 74 | if (here == converters.end()) return NULL;
|
---|
| 75 |
|
---|
| 76 | return (*here).second.outconverter;
|
---|
| 77 | }
|
---|