source: NonGTP/Xerces/xerces/include/xercesc/util/TransENameMap.hpp @ 358

Revision 358, 5.6 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
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
24XERCES_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//
31class ENameMap : public XMemory
32{
33public :
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
64protected :
65    // -----------------------------------------------------------------------
66    //  Hidden constructors
67    // -----------------------------------------------------------------------
68    ENameMap(const XMLCh* const encodingName) :
69          fEncodingName(XMLString::replicate(encodingName, XMLPlatformUtils::fgMemoryManager))
70    {
71    }
72
73
74private :
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
94template <class TType> class ENameMapFor : public ENameMap
95{
96public :
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
111private :
112    // -----------------------------------------------------------------------
113    //  Unimplemented constructors and operators
114    // -----------------------------------------------------------------------
115    ENameMapFor();
116    ENameMapFor(const ENameMapFor<TType>&);
117    ENameMapFor<TType>& operator=(const ENameMapFor<TType>&);
118};
119
120
121template <class TType> class EEndianNameMapFor : public ENameMap
122{
123public :
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
138private :
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
156XERCES_CPP_NAMESPACE_END
157
158#if !defined(XERCES_TMPLSINC)
159#include <xercesc/util/TransENameMap.c>
160#endif
161
162#endif
Note: See TracBrowser for help on using the repository browser.