1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * converter.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 | * $Id: converter.h 533 1999-09-07 04:57:01Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 |
|
---|
29 | #ifndef CONVERTER_H
|
---|
30 | #define CONVERTER_H
|
---|
31 |
|
---|
32 |
|
---|
33 | #include "gsdlconf.h"
|
---|
34 | #include "text_t.h"
|
---|
35 | #include "gsdlunicode.h"
|
---|
36 |
|
---|
37 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
38 | # include <ospace\std\map>
|
---|
39 | #elif defined(GSDL_USE_STL_H)
|
---|
40 | # include <map.h>
|
---|
41 | #else
|
---|
42 | # include <map>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 |
|
---|
46 | // inconverter and outconverter ARE NOT destroyed by this class
|
---|
47 | // they should be destroyed by the code which created them after
|
---|
48 | // no more pointers to the class exist.
|
---|
49 | //
|
---|
50 | // The above condition enables the class to be copied without
|
---|
51 | // copying the converters which might contain a lot of data (and
|
---|
52 | // be of an unknown derived type).
|
---|
53 | class converterinfo {
|
---|
54 | public:
|
---|
55 | text_t name;
|
---|
56 | inconvertclass *inconverter;
|
---|
57 | rzwsoutconvertclass *outconverter;
|
---|
58 |
|
---|
59 | converterinfo() {inconverter=NULL; outconverter=NULL;}
|
---|
60 | };
|
---|
61 |
|
---|
62 | bool operator==(const converterinfo &x, const converterinfo &y);
|
---|
63 | bool operator<(const converterinfo &x, const converterinfo &y);
|
---|
64 |
|
---|
65 |
|
---|
66 | typedef map<text_t, converterinfo, lttext_t> convertmap;
|
---|
67 |
|
---|
68 | // convertinfoclass is used to store a number of converters
|
---|
69 | // indexing them by their name
|
---|
70 | class convertinfoclass {
|
---|
71 | protected:
|
---|
72 | convertmap converters;
|
---|
73 |
|
---|
74 | public:
|
---|
75 | // type support for convertmap
|
---|
76 | typedef convertmap::iterator iterator;
|
---|
77 | typedef convertmap::const_iterator const_iterator;
|
---|
78 | typedef convertmap::reference reference;
|
---|
79 | typedef convertmap::const_reference const_reference;
|
---|
80 | typedef convertmap::size_type size_type;
|
---|
81 | typedef convertmap::difference_type difference_type;
|
---|
82 | typedef convertmap::const_reverse_iterator const_reverse_iterator;
|
---|
83 | typedef convertmap::reverse_iterator reverse_iterator;
|
---|
84 |
|
---|
85 | // constructors
|
---|
86 | convertinfoclass () {}
|
---|
87 |
|
---|
88 | // basic container support
|
---|
89 | iterator begin () {return converters.begin();}
|
---|
90 | const_iterator begin () const {return converters.begin();}
|
---|
91 | iterator end () {return converters.end();}
|
---|
92 | const_iterator end () const {return converters.end();}
|
---|
93 |
|
---|
94 | void erase(iterator pos) {converters.erase(pos);}
|
---|
95 | void erase(iterator first, iterator last) {converters.erase(first, last);}
|
---|
96 | convertinfoclass &operator=(const convertinfoclass &x)
|
---|
97 | {converters=x.converters;return *this;}
|
---|
98 |
|
---|
99 | bool empty () const {return converters.empty();}
|
---|
100 | size_type size() const {return converters.size();}
|
---|
101 |
|
---|
102 |
|
---|
103 | // added functionality
|
---|
104 | void clear () {converters.erase(converters.begin(),converters.end());}
|
---|
105 |
|
---|
106 | // the converters within converterinfo become the property of
|
---|
107 | // of this class after add_converter has been called. The converters
|
---|
108 | // remain the responsability of the calling code and will not be
|
---|
109 | // deleted by this class.
|
---|
110 | void add_converter (const text_t &name, inconvertclass *inconverter,
|
---|
111 | rzwsoutconvertclass *outconverter);
|
---|
112 |
|
---|
113 | // get_inconverter will return NULL if the convert could not be found
|
---|
114 | inconvertclass *get_inconverter (const text_t &name);
|
---|
115 |
|
---|
116 | // get_outconverter will return NULL if the convert could not be found
|
---|
117 | rzwsoutconvertclass *get_outconverter (const text_t &name);
|
---|
118 | };
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 | #endif
|
---|