1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * converter.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: converter.h 164 1999-02-21 22:33:54Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef CONVERTER_H
|
---|
14 | #define CONVERTER_H
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "gsdlconf.h"
|
---|
18 | #include "text_t.h"
|
---|
19 | #include "gsdlunicode.h"
|
---|
20 |
|
---|
21 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
22 | # include <ospace\std\map>
|
---|
23 | #elif defined(GSDL_USE_STL_H)
|
---|
24 | # include <map.h>
|
---|
25 | #else
|
---|
26 | # include <map>
|
---|
27 | #endif
|
---|
28 |
|
---|
29 |
|
---|
30 | // inconverter and outconverter ARE NOT destroyed by this class
|
---|
31 | // they should be destroyed by the code which created them after
|
---|
32 | // no more pointers to the class exist.
|
---|
33 | //
|
---|
34 | // The above condition enables the class to be copied without
|
---|
35 | // copying the converters which might contain a lot of data (and
|
---|
36 | // be of an unknown derived type).
|
---|
37 | class converterinfo {
|
---|
38 | public:
|
---|
39 | text_t name;
|
---|
40 | inconvertclass *inconverter;
|
---|
41 | rzwsoutconvertclass *outconverter;
|
---|
42 |
|
---|
43 | converterinfo() {inconverter=NULL; outconverter=NULL;}
|
---|
44 | };
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | typedef map<text_t, converterinfo, lttext_t> convertmap;
|
---|
49 |
|
---|
50 | // convertinfoclass is used to store a number of converters
|
---|
51 | // indexing them by their name
|
---|
52 | class convertinfoclass {
|
---|
53 | protected:
|
---|
54 | convertmap converters;
|
---|
55 |
|
---|
56 | public:
|
---|
57 | // type support for convertmap
|
---|
58 | typedef convertmap::iterator iterator;
|
---|
59 | typedef convertmap::const_iterator const_iterator;
|
---|
60 | typedef convertmap::reference reference;
|
---|
61 | typedef convertmap::const_reference const_reference;
|
---|
62 | typedef convertmap::size_type size_type;
|
---|
63 | typedef convertmap::difference_type difference_type;
|
---|
64 | typedef convertmap::const_reverse_iterator const_reverse_iterator;
|
---|
65 | typedef convertmap::reverse_iterator reverse_iterator;
|
---|
66 |
|
---|
67 | // constructors
|
---|
68 | convertinfoclass () {}
|
---|
69 |
|
---|
70 | // basic container support
|
---|
71 | iterator begin () {return converters.begin();}
|
---|
72 | const_iterator begin () const {return converters.begin();}
|
---|
73 | iterator end () {return converters.end();}
|
---|
74 | const_iterator end () const {return converters.end();}
|
---|
75 |
|
---|
76 | void erase(iterator pos) {converters.erase(pos);}
|
---|
77 | void erase(iterator first, iterator last) {converters.erase(first, last);}
|
---|
78 | convertinfoclass &operator=(const convertinfoclass &x)
|
---|
79 | {converters=x.converters;return *this;}
|
---|
80 |
|
---|
81 | bool empty () const {return converters.empty();}
|
---|
82 | size_type size() const {return converters.size();}
|
---|
83 |
|
---|
84 |
|
---|
85 | // added functionality
|
---|
86 | void clear () {converters.erase(converters.begin(),converters.end());}
|
---|
87 |
|
---|
88 | // the converters within converterinfo become the property of
|
---|
89 | // of this class after add_converter has been called. The converters
|
---|
90 | // remain the responsability of the calling code and will not be
|
---|
91 | // deleted by this class.
|
---|
92 | void add_converter (const text_t &name, inconvertclass *inconverter,
|
---|
93 | rzwsoutconvertclass *outconverter);
|
---|
94 |
|
---|
95 | // get_inconverter will return NULL if the convert could not be found
|
---|
96 | inconvertclass *get_inconverter (const text_t &name);
|
---|
97 |
|
---|
98 | // get_outconverter will return NULL if the convert could not be found
|
---|
99 | rzwsoutconvertclass *get_outconverter (const text_t &name);
|
---|
100 | };
|
---|
101 |
|
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|
105 | #endif
|
---|