source: NonGTP/Xerces/xerces/include/xercesc/util/Transcoders/Win32/Win32TransService.hpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 1999-2000,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 * $Log: Win32TransService.hpp,v $
19 * Revision 1.8  2004/09/08 13:56:47  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.7  2003/12/24 15:24:15  cargilld
23 * More updates to memory management so that the static memory manager.
24 *
25 * Revision 1.6  2003/05/17 16:32:18  knoaman
26 * Memory manager implementation : transcoder update.
27 *
28 * Revision 1.5  2003/05/15 18:47:07  knoaman
29 * Partial implementation of the configurable memory manager.
30 *
31 * Revision 1.4  2003/03/07 18:15:58  tng
32 * Return a reference instead of void for operator=
33 *
34 * Revision 1.3  2002/11/04 15:14:34  tng
35 * C++ Namespace Support.
36 *
37 * Revision 1.2  2002/04/09 15:44:00  knoaman
38 * Add lower case string support.
39 *
40 * Revision 1.1.1.1  2002/02/01 22:22:37  peiyongz
41 * sane_include
42 *
43 * Revision 1.10  2000/05/09 00:22:45  andyh
44 * Memory Cleanup.  XMLPlatformUtils::Terminate() deletes all lazily
45 * allocated memory; memory leak checking tools will no longer report
46 * that leaks exist.  (DOM GetElementsByTagID temporarily removed
47 * as part of this.)
48 *
49 * Revision 1.9  2000/03/18 00:00:04  roddey
50 * Initial updates for two way transcoding support
51 *
52 * Revision 1.8  2000/03/07 23:45:36  roddey
53 * First cut for additions to Win32 xcode. Based very loosely on a
54 * prototype from Eric Ulevik.
55 *
56 * Revision 1.7  2000/03/02 19:55:36  roddey
57 * This checkin includes many changes done while waiting for the
58 * 1.1.0 code to be finished. I can't list them all here, but a list is
59 * available elsewhere.
60 *
61 * Revision 1.6  2000/02/06 07:48:34  rahulj
62 * Year 2K copyright swat.
63 *
64 * Revision 1.5  2000/01/25 22:49:58  roddey
65 * Moved the supportsSrcOfs() method from the individual transcoder to the
66 * transcoding service, where it should have been to begin with.
67 *
68 * Revision 1.4  2000/01/25 19:19:09  roddey
69 * Simple addition of a getId() method to the xcode and netacess abstractions to
70 * allow each impl to give back an id string.
71 *
72 * Revision 1.3  1999/12/18 00:22:33  roddey
73 * Changes to support the new, completely orthagonal, transcoder architecture.
74 *
75 * Revision 1.2  1999/12/15 19:44:02  roddey
76 * Now implements the new transcoding abstractions, with separate interface
77 * classes for XML transcoders and local code page transcoders.
78 *
79 * Revision 1.1.1.1  1999/11/09 01:06:06  twl
80 * Initial checkin
81 *
82 * Revision 1.2  1999/11/08 20:45:35  rahul
83 * Swat for adding in Product name and CVS comment log variable.
84 *
85 */
86
87#ifndef WIN32TRANSSERVICE_HPP
88#define WIN32TRANSSERVICE_HPP
89
90#include <xercesc/util/TransService.hpp>
91#include <xercesc/util/RefHashTableOf.hpp>
92#include <windows.h>
93
94XERCES_CPP_NAMESPACE_BEGIN
95
96class CPMapEntry;
97
98
99
100//---------------------------------------------------------------------------
101//
102//  class Win32TransService
103//
104//---------------------------------------------------------------------------
105class XMLUTIL_EXPORT Win32TransService : public XMLTransService
106{
107public :
108    // -----------------------------------------------------------------------
109    //  Constructors and Destructor
110    // -----------------------------------------------------------------------
111    Win32TransService();
112    virtual ~Win32TransService();
113
114
115    // -----------------------------------------------------------------------
116    //  Implementation of the virtual transcoding service API
117    // -----------------------------------------------------------------------
118    virtual int compareIString
119    (
120        const   XMLCh* const    comp1
121        , const XMLCh* const    comp2
122    );
123
124    virtual int compareNIString
125    (
126        const   XMLCh* const    comp1
127        , const XMLCh* const    comp2
128        , const unsigned int    maxChars
129    );
130
131    virtual const XMLCh* getId() const;
132
133    virtual bool isSpace(const XMLCh toCheck) const;
134
135    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
136
137    virtual bool supportsSrcOfs() const;
138
139    virtual void upperCase(XMLCh* const toUpperCase) const;
140    virtual void lowerCase(XMLCh* const toLowerCase) const;
141
142
143protected :
144    // -----------------------------------------------------------------------
145    //  Protected virtual methods, implemented in Win32TransService2.cpp
146    // -----------------------------------------------------------------------
147    virtual XMLTranscoder* makeNewXMLTranscoder
148    (
149        const   XMLCh* const            encodingName
150        ,       XMLTransService::Codes& resValue
151        , const unsigned int            blockSize
152        ,       MemoryManager* const    manager
153    );
154
155
156private :
157    // -----------------------------------------------------------------------
158    //  Unimplemented constructors and operators
159    // -----------------------------------------------------------------------
160    Win32TransService(const Win32TransService&);
161    Win32TransService& operator=(const Win32TransService&);
162
163    //      This is a hash table of entries which map encoding names to their
164    //      Windows specific code pages. The code page allows us to create
165    //      transcoders for those encodings. The encoding names come from XML
166    //      files.
167    //
168    //      This map is shared unsynchronized among all threads of the process,
169    //      which is cool since it will be read only once its initialized.
170
171
172
173    static bool isAlias(const   HKEY            encodingKey
174                    ,       char* const     aliasBuf = 0
175                    , const unsigned int    nameBufSz = 0);
176
177
178    RefHashTableOf<CPMapEntry>    *fCPMap;
179};
180
181
182
183
184
185
186
187//---------------------------------------------------------------------------
188//
189//  class Win32Transcoder
190//
191//---------------------------------------------------------------------------
192
193class XMLUTIL_EXPORT Win32Transcoder : public XMLTranscoder
194{
195public :
196    // -----------------------------------------------------------------------
197    //  Constructors and Destructor
198    // -----------------------------------------------------------------------
199    Win32Transcoder
200    (
201        const   XMLCh* const    encodingName
202        , const unsigned int    winCP
203        , const unsigned int    ieCP
204        , const unsigned int    blockSize
205        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
206    ~Win32Transcoder();
207
208
209    // -----------------------------------------------------------------------
210    //  Implementation of the virtual transcoder interface
211    // -----------------------------------------------------------------------
212    virtual unsigned int transcodeFrom
213    (
214        const   XMLByte* const          srcData
215        , const unsigned int            srcCount
216        ,       XMLCh* const            toFill
217        , const unsigned int            maxChars
218        ,       unsigned int&           bytesEaten
219        ,       unsigned char* const    charSizes
220    );
221
222    virtual unsigned int transcodeTo
223    (
224        const   XMLCh* const    srcData
225        , const unsigned int    srcCount
226        ,       XMLByte* const  toFill
227        , const unsigned int    maxBytes
228        ,       unsigned int&   charsEaten
229        , const UnRepOpts       options
230    );
231
232    virtual bool canTranscodeTo
233    (
234        const   unsigned int    toCheck
235    )   const;
236
237
238private :
239    // -----------------------------------------------------------------------
240    //  Unimplemented constructors and operators
241    // -----------------------------------------------------------------------
242    Win32Transcoder(const Win32Transcoder&);
243    Win32Transcoder& operator=(const Win32Transcoder&);
244
245
246    // -----------------------------------------------------------------------
247    //  Private data members
248    //
249    //  fIECP
250    //      This is the internet explorer code page for this encoding.
251    //
252    //  fWinCP
253    //      This is the windows code page for this encoding.
254    // -----------------------------------------------------------------------
255    unsigned int    fIECP;
256    unsigned int    fWinCP;
257};
258
259
260
261
262
263//---------------------------------------------------------------------------
264//
265//  class Win32LCPTranscoder
266//
267//---------------------------------------------------------------------------
268class XMLUTIL_EXPORT Win32LCPTranscoder : public XMLLCPTranscoder
269{
270public :
271    // -----------------------------------------------------------------------
272    //  Constructors and Destructor
273    // -----------------------------------------------------------------------
274    Win32LCPTranscoder();
275    ~Win32LCPTranscoder();
276
277
278    // -----------------------------------------------------------------------
279    //  Implementation of the virtual transcoder interface
280    // -----------------------------------------------------------------------
281    virtual unsigned int calcRequiredSize(const char* const srcText
282        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
283
284    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
285        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
286
287    virtual char* transcode(const XMLCh* const toTranscode);
288    virtual char* transcode(const XMLCh* const toTranscode,
289                            MemoryManager* const manager);
290
291    virtual XMLCh* transcode(const char* const toTranscode);
292    virtual XMLCh* transcode(const char* const toTranscode,
293                             MemoryManager* const manager);
294
295    virtual bool transcode
296    (
297        const   char* const     toTranscode
298        ,       XMLCh* const    toFill
299        , const unsigned int    maxChars
300        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
301    );
302
303    virtual bool transcode
304    (
305        const   XMLCh* const    toTranscode
306        ,       char* const     toFill
307        , const unsigned int    maxChars
308        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
309    );
310
311
312private :
313    // -----------------------------------------------------------------------
314    //  Unimplemented constructors and operators
315    // -----------------------------------------------------------------------
316    Win32LCPTranscoder(const Win32LCPTranscoder&);
317    Win32LCPTranscoder& operator=(const Win32LCPTranscoder&);
318};
319
320XERCES_CPP_NAMESPACE_END
321
322#endif
Note: See TracBrowser for help on using the repository browser.