source: NonGTP/Xerces/xercesc/util/Transcoders/Win32/Win32TransService.hpp @ 188

Revision 188, 12.8 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: Win32TransService.hpp,v $
59 * Revision 1.7  2003/12/24 15:24:15  cargilld
60 * More updates to memory management so that the static memory manager.
61 *
62 * Revision 1.6  2003/05/17 16:32:18  knoaman
63 * Memory manager implementation : transcoder update.
64 *
65 * Revision 1.5  2003/05/15 18:47:07  knoaman
66 * Partial implementation of the configurable memory manager.
67 *
68 * Revision 1.4  2003/03/07 18:15:58  tng
69 * Return a reference instead of void for operator=
70 *
71 * Revision 1.3  2002/11/04 15:14:34  tng
72 * C++ Namespace Support.
73 *
74 * Revision 1.2  2002/04/09 15:44:00  knoaman
75 * Add lower case string support.
76 *
77 * Revision 1.1.1.1  2002/02/01 22:22:37  peiyongz
78 * sane_include
79 *
80 * Revision 1.10  2000/05/09 00:22:45  andyh
81 * Memory Cleanup.  XMLPlatformUtils::Terminate() deletes all lazily
82 * allocated memory; memory leak checking tools will no longer report
83 * that leaks exist.  (DOM GetElementsByTagID temporarily removed
84 * as part of this.)
85 *
86 * Revision 1.9  2000/03/18 00:00:04  roddey
87 * Initial updates for two way transcoding support
88 *
89 * Revision 1.8  2000/03/07 23:45:36  roddey
90 * First cut for additions to Win32 xcode. Based very loosely on a
91 * prototype from Eric Ulevik.
92 *
93 * Revision 1.7  2000/03/02 19:55:36  roddey
94 * This checkin includes many changes done while waiting for the
95 * 1.1.0 code to be finished. I can't list them all here, but a list is
96 * available elsewhere.
97 *
98 * Revision 1.6  2000/02/06 07:48:34  rahulj
99 * Year 2K copyright swat.
100 *
101 * Revision 1.5  2000/01/25 22:49:58  roddey
102 * Moved the supportsSrcOfs() method from the individual transcoder to the
103 * transcoding service, where it should have been to begin with.
104 *
105 * Revision 1.4  2000/01/25 19:19:09  roddey
106 * Simple addition of a getId() method to the xcode and netacess abstractions to
107 * allow each impl to give back an id string.
108 *
109 * Revision 1.3  1999/12/18 00:22:33  roddey
110 * Changes to support the new, completely orthagonal, transcoder architecture.
111 *
112 * Revision 1.2  1999/12/15 19:44:02  roddey
113 * Now implements the new transcoding abstractions, with separate interface
114 * classes for XML transcoders and local code page transcoders.
115 *
116 * Revision 1.1.1.1  1999/11/09 01:06:06  twl
117 * Initial checkin
118 *
119 * Revision 1.2  1999/11/08 20:45:35  rahul
120 * Swat for adding in Product name and CVS comment log variable.
121 *
122 */
123
124#ifndef WIN32TRANSSERVICE_HPP
125#define WIN32TRANSSERVICE_HPP
126
127#include <xercesc/util/TransService.hpp>
128#include <xercesc/util/RefHashTableOf.hpp>
129#include <windows.h>
130
131XERCES_CPP_NAMESPACE_BEGIN
132
133class CPMapEntry;
134
135
136
137//---------------------------------------------------------------------------
138//
139//  class Win32TransService
140//
141//---------------------------------------------------------------------------
142class XMLUTIL_EXPORT Win32TransService : public XMLTransService
143{
144public :
145    // -----------------------------------------------------------------------
146    //  Constructors and Destructor
147    // -----------------------------------------------------------------------
148    Win32TransService();
149    virtual ~Win32TransService();
150
151
152    // -----------------------------------------------------------------------
153    //  Implementation of the virtual transcoding service API
154    // -----------------------------------------------------------------------
155    virtual int compareIString
156    (
157        const   XMLCh* const    comp1
158        , const XMLCh* const    comp2
159    );
160
161    virtual int compareNIString
162    (
163        const   XMLCh* const    comp1
164        , const XMLCh* const    comp2
165        , const unsigned int    maxChars
166    );
167
168    virtual const XMLCh* getId() const;
169
170    virtual bool isSpace(const XMLCh toCheck) const;
171
172    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
173
174    virtual bool supportsSrcOfs() const;
175
176    virtual void upperCase(XMLCh* const toUpperCase) const;
177    virtual void lowerCase(XMLCh* const toLowerCase) const;
178
179
180protected :
181    // -----------------------------------------------------------------------
182    //  Protected virtual methods, implemented in Win32TransService2.cpp
183    // -----------------------------------------------------------------------
184    virtual XMLTranscoder* makeNewXMLTranscoder
185    (
186        const   XMLCh* const            encodingName
187        ,       XMLTransService::Codes& resValue
188        , const unsigned int            blockSize
189        ,       MemoryManager* const    manager
190    );
191
192
193private :
194    // -----------------------------------------------------------------------
195    //  Unimplemented constructors and operators
196    // -----------------------------------------------------------------------
197    Win32TransService(const Win32TransService&);
198    Win32TransService& operator=(const Win32TransService&);
199
200    //      This is a hash table of entries which map encoding names to their
201    //      Windows specific code pages. The code page allows us to create
202    //      transcoders for those encodings. The encoding names come from XML
203    //      files.
204    //
205    //      This map is shared unsynchronized among all threads of the process,
206    //      which is cool since it will be read only once its initialized.
207
208
209
210    static bool isAlias(const   HKEY            encodingKey
211                    ,       char* const     aliasBuf = 0
212                    , const unsigned int    nameBufSz = 0);
213
214
215    RefHashTableOf<CPMapEntry>    *fCPMap;
216};
217
218
219
220
221
222
223
224//---------------------------------------------------------------------------
225//
226//  class Win32Transcoder
227//
228//---------------------------------------------------------------------------
229
230class XMLUTIL_EXPORT Win32Transcoder : public XMLTranscoder
231{
232public :
233    // -----------------------------------------------------------------------
234    //  Constructors and Destructor
235    // -----------------------------------------------------------------------
236    Win32Transcoder
237    (
238        const   XMLCh* const    encodingName
239        , const unsigned int    winCP
240        , const unsigned int    ieCP
241        , const unsigned int    blockSize
242        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
243    ~Win32Transcoder();
244
245
246    // -----------------------------------------------------------------------
247    //  Implementation of the virtual transcoder interface
248    // -----------------------------------------------------------------------
249    virtual unsigned int transcodeFrom
250    (
251        const   XMLByte* const          srcData
252        , const unsigned int            srcCount
253        ,       XMLCh* const            toFill
254        , const unsigned int            maxChars
255        ,       unsigned int&           bytesEaten
256        ,       unsigned char* const    charSizes
257    );
258
259    virtual unsigned int transcodeTo
260    (
261        const   XMLCh* const    srcData
262        , const unsigned int    srcCount
263        ,       XMLByte* const  toFill
264        , const unsigned int    maxBytes
265        ,       unsigned int&   charsEaten
266        , const UnRepOpts       options
267    );
268
269    virtual bool canTranscodeTo
270    (
271        const   unsigned int    toCheck
272    )   const;
273
274
275private :
276    // -----------------------------------------------------------------------
277    //  Unimplemented constructors and operators
278    // -----------------------------------------------------------------------
279    Win32Transcoder(const Win32Transcoder&);
280    Win32Transcoder& operator=(const Win32Transcoder&);
281
282
283    // -----------------------------------------------------------------------
284    //  Private data members
285    //
286    //  fIECP
287    //      This is the internet explorer code page for this encoding.
288    //
289    //  fWinCP
290    //      This is the windows code page for this encoding.
291    // -----------------------------------------------------------------------
292    unsigned int    fIECP;
293    unsigned int    fWinCP;
294};
295
296
297
298
299
300//---------------------------------------------------------------------------
301//
302//  class Win32LCPTranscoder
303//
304//---------------------------------------------------------------------------
305class XMLUTIL_EXPORT Win32LCPTranscoder : public XMLLCPTranscoder
306{
307public :
308    // -----------------------------------------------------------------------
309    //  Constructors and Destructor
310    // -----------------------------------------------------------------------
311    Win32LCPTranscoder();
312    ~Win32LCPTranscoder();
313
314
315    // -----------------------------------------------------------------------
316    //  Implementation of the virtual transcoder interface
317    // -----------------------------------------------------------------------
318    virtual unsigned int calcRequiredSize(const char* const srcText
319        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
320
321    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
322        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
323
324    virtual char* transcode(const XMLCh* const toTranscode);
325    virtual char* transcode(const XMLCh* const toTranscode,
326                            MemoryManager* const manager);
327
328    virtual XMLCh* transcode(const char* const toTranscode);
329    virtual XMLCh* transcode(const char* const toTranscode,
330                             MemoryManager* const manager);
331
332    virtual bool transcode
333    (
334        const   char* const     toTranscode
335        ,       XMLCh* const    toFill
336        , const unsigned int    maxChars
337        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
338    );
339
340    virtual bool transcode
341    (
342        const   XMLCh* const    toTranscode
343        ,       char* const     toFill
344        , const unsigned int    maxChars
345        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
346    );
347
348
349private :
350    // -----------------------------------------------------------------------
351    //  Unimplemented constructors and operators
352    // -----------------------------------------------------------------------
353    Win32LCPTranscoder(const Win32LCPTranscoder&);
354    Win32LCPTranscoder& operator=(const Win32LCPTranscoder&);
355};
356
357XERCES_CPP_NAMESPACE_END
358
359#endif
Note: See TracBrowser for help on using the repository browser.