1 | /*
|
---|
2 | * Copyright 1999-2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 |
|
---|
18 | #if !defined(TRANSENAMEMAP_HPP)
|
---|
19 | #define TRANSENAMEMAP_HPP
|
---|
20 |
|
---|
21 | #include <xercesc/util/TransService.hpp>
|
---|
22 | #include <xercesc/util/XMLString.hpp>
|
---|
23 |
|
---|
24 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
25 |
|
---|
26 | //
|
---|
27 | // This class is really private to the TransService class. However, some
|
---|
28 | // compilers are too dumb to allow us to hide this class there in the Cpp
|
---|
29 | // file that uses it.
|
---|
30 | //
|
---|
31 | class ENameMap : public XMemory
|
---|
32 | {
|
---|
33 | public :
|
---|
34 | // -----------------------------------------------------------------------
|
---|
35 | // Destructor
|
---|
36 | // -----------------------------------------------------------------------
|
---|
37 | virtual ~ENameMap()
|
---|
38 | {
|
---|
39 | //delete [] fEncodingName;
|
---|
40 | XMLPlatformUtils::fgMemoryManager->deallocate(fEncodingName);
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | // -----------------------------------------------------------------------
|
---|
46 | // Virtual factory method
|
---|
47 | // -----------------------------------------------------------------------
|
---|
48 | virtual XMLTranscoder* makeNew
|
---|
49 | (
|
---|
50 | const unsigned int blockSize
|
---|
51 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
52 | ) const = 0;
|
---|
53 |
|
---|
54 |
|
---|
55 | // -----------------------------------------------------------------------
|
---|
56 | // Getter methods
|
---|
57 | // -----------------------------------------------------------------------
|
---|
58 | const XMLCh* getKey() const
|
---|
59 | {
|
---|
60 | return fEncodingName;
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | protected :
|
---|
65 | // -----------------------------------------------------------------------
|
---|
66 | // Hidden constructors
|
---|
67 | // -----------------------------------------------------------------------
|
---|
68 | ENameMap(const XMLCh* const encodingName) :
|
---|
69 | fEncodingName(XMLString::replicate(encodingName, XMLPlatformUtils::fgMemoryManager))
|
---|
70 | {
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | private :
|
---|
75 | // -----------------------------------------------------------------------
|
---|
76 | // Unimplemented constructors and operators
|
---|
77 | // -----------------------------------------------------------------------
|
---|
78 | ENameMap();
|
---|
79 | ENameMap(const ENameMap&);
|
---|
80 | ENameMap& operator=(const ENameMap&);
|
---|
81 |
|
---|
82 |
|
---|
83 | // -----------------------------------------------------------------------
|
---|
84 | // Private data members
|
---|
85 | //
|
---|
86 | // fEncodingName
|
---|
87 | // This is the encoding name for the transcoder that is controlled
|
---|
88 | // by this map instance.
|
---|
89 | // -----------------------------------------------------------------------
|
---|
90 | XMLCh* fEncodingName;
|
---|
91 | };
|
---|
92 |
|
---|
93 |
|
---|
94 | template <class TType> class ENameMapFor : public ENameMap
|
---|
95 | {
|
---|
96 | public :
|
---|
97 | // -----------------------------------------------------------------------
|
---|
98 | // Constructors and Destructor
|
---|
99 | // -----------------------------------------------------------------------
|
---|
100 | ENameMapFor(const XMLCh* const encodingName);
|
---|
101 | ~ENameMapFor();
|
---|
102 |
|
---|
103 |
|
---|
104 | // -----------------------------------------------------------------------
|
---|
105 | // Implementation of virtual factory method
|
---|
106 | // -----------------------------------------------------------------------
|
---|
107 | virtual XMLTranscoder* makeNew(const unsigned int blockSize,
|
---|
108 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const;
|
---|
109 |
|
---|
110 |
|
---|
111 | private :
|
---|
112 | // -----------------------------------------------------------------------
|
---|
113 | // Unimplemented constructors and operators
|
---|
114 | // -----------------------------------------------------------------------
|
---|
115 | ENameMapFor();
|
---|
116 | ENameMapFor(const ENameMapFor<TType>&);
|
---|
117 | ENameMapFor<TType>& operator=(const ENameMapFor<TType>&);
|
---|
118 | };
|
---|
119 |
|
---|
120 |
|
---|
121 | template <class TType> class EEndianNameMapFor : public ENameMap
|
---|
122 | {
|
---|
123 | public :
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | // Constructors and Destructor
|
---|
126 | // -----------------------------------------------------------------------
|
---|
127 | EEndianNameMapFor(const XMLCh* const encodingName, const bool swapped);
|
---|
128 | ~EEndianNameMapFor();
|
---|
129 |
|
---|
130 |
|
---|
131 | // -----------------------------------------------------------------------
|
---|
132 | // Implementation of virtual factory method
|
---|
133 | // -----------------------------------------------------------------------
|
---|
134 | virtual XMLTranscoder* makeNew(const unsigned int blockSize,
|
---|
135 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) const;
|
---|
136 |
|
---|
137 |
|
---|
138 | private :
|
---|
139 | // -----------------------------------------------------------------------
|
---|
140 | // Unimplemented constructors and operators
|
---|
141 | // -----------------------------------------------------------------------
|
---|
142 | EEndianNameMapFor(const EEndianNameMapFor<TType>&);
|
---|
143 | EEndianNameMapFor<TType>& operator=(const EEndianNameMapFor<TType>&);
|
---|
144 |
|
---|
145 |
|
---|
146 | // -----------------------------------------------------------------------
|
---|
147 | // Private data members
|
---|
148 | //
|
---|
149 | // fSwapped
|
---|
150 | // Indicates whether the endianess of the encoding is opposite of
|
---|
151 | // that of the local host.
|
---|
152 | // -----------------------------------------------------------------------
|
---|
153 | bool fSwapped;
|
---|
154 | };
|
---|
155 |
|
---|
156 | XERCES_CPP_NAMESPACE_END
|
---|
157 |
|
---|
158 | #if !defined(XERCES_TMPLSINC)
|
---|
159 | #include <xercesc/util/TransENameMap.c>
|
---|
160 | #endif
|
---|
161 |
|
---|
162 | #endif
|
---|