source: NonGTP/Xerces/xercesc/util/Transcoders/Cygwin/CygwinTransService.hpp @ 188

Revision 188, 10.7 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-2002 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#ifndef CYGWINTRANSSERVICE_HPP
59#define CYGWINTRANSSERVICE_HPP
60
61#include <xercesc/util/TransService.hpp>
62#include <xercesc/util/RefHashTableOf.hpp>
63#include <windows.h>
64
65XERCES_CPP_NAMESPACE_BEGIN
66
67class CPMapEntry;
68
69
70
71//---------------------------------------------------------------------------
72//
73//  class CygwinTransService
74//
75//---------------------------------------------------------------------------
76class XMLUTIL_EXPORT CygwinTransService : public XMLTransService
77{
78public :
79    // -----------------------------------------------------------------------
80    //  Constructors and Destructor
81    // -----------------------------------------------------------------------
82    CygwinTransService();
83    virtual ~CygwinTransService();
84
85
86    // -----------------------------------------------------------------------
87    //  Implementation of the virtual transcoding service API
88    // -----------------------------------------------------------------------
89    virtual int compareIString
90    (
91        const   XMLCh* const    comp1
92        , const XMLCh* const    comp2
93    );
94
95    virtual int compareNIString
96    (
97        const   XMLCh* const    comp1
98        , const XMLCh* const    comp2
99        , const unsigned int    maxChars
100    );
101
102    virtual const XMLCh* getId() const;
103
104    virtual bool isSpace(const XMLCh toCheck) const;
105
106    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
107
108    virtual bool supportsSrcOfs() const;
109
110    virtual void upperCase(XMLCh* const toUpperCase) const;
111    virtual void lowerCase(XMLCh* const toLowerCase) const;
112
113
114protected :
115    // -----------------------------------------------------------------------
116    //  Protected virtual methods, implemented in CygwinTransService.cpp
117    // -----------------------------------------------------------------------
118    virtual XMLTranscoder* makeNewXMLTranscoder
119    (
120        const   XMLCh* const            encodingName
121        ,       XMLTransService::Codes& resValue
122        , const unsigned int            blockSize
123        ,       MemoryManager* const    manager
124    );
125
126    virtual int auxCompareString
127    (
128        const   XMLCh* const  comp1
129        , const XMLCh* const  comp2
130        , signed long         maxChars
131        , const  bool         ignoreCase
132    );
133
134private :
135    // -----------------------------------------------------------------------
136    //  Unimplemented constructors and operators
137    // -----------------------------------------------------------------------
138    CygwinTransService(const CygwinTransService&);
139    CygwinTransService& operator=(const CygwinTransService&);
140
141    //      This is a hash table of entries which map encoding names to their
142    //      Windows specific code pages. The code page allows us to create
143    //      transcoders for those encodings. The encoding names come from XML
144    //      files.
145    //
146    //      This map is shared unsynchronized among all threads of the process,
147    //      which is cool since it will be read only once its initialized.
148
149
150
151    static bool isAlias(const HKEY          encodingKey
152                    ,       char* const     aliasBuf = 0
153                    , const unsigned int    nameBufSz = 0);
154
155
156    RefHashTableOf<CPMapEntry>    *fCPMap;
157};
158
159
160
161
162
163
164
165//---------------------------------------------------------------------------
166//
167//  class CygwinTranscoder
168//
169//---------------------------------------------------------------------------
170
171class XMLUTIL_EXPORT CygwinTranscoder : public XMLTranscoder
172{
173public :
174    // -----------------------------------------------------------------------
175    //  Constructors and Destructor
176    // -----------------------------------------------------------------------
177    CygwinTranscoder
178    (
179        const   XMLCh* const    encodingName
180        , const unsigned int    winCP
181        , const unsigned int    ieCP
182        , const unsigned int    blockSize
183        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
184    ~CygwinTranscoder();
185
186
187    // -----------------------------------------------------------------------
188    //  Implementation of the virtual transcoder interface
189    // -----------------------------------------------------------------------
190    virtual unsigned int transcodeFrom
191    (
192        const   XMLByte* const          srcData
193        , const unsigned int            srcCount
194        ,       XMLCh* const            toFill
195        , const unsigned int            maxChars
196        ,       unsigned int&           bytesEaten
197        ,       unsigned char* const    charSizes
198    );
199
200    virtual unsigned int transcodeTo
201    (
202        const   XMLCh* const    srcData
203        , const unsigned int    srcCount
204        ,       XMLByte* const  toFill
205        , const unsigned int    maxBytes
206        ,       unsigned int&   charsEaten
207        , const UnRepOpts       options
208    );
209
210    virtual bool canTranscodeTo
211    (
212        const   unsigned int    toCheck
213    )   const;
214
215
216private :
217    // -----------------------------------------------------------------------
218    //  Unimplemented constructors and operators
219    // -----------------------------------------------------------------------
220    CygwinTranscoder(const CygwinTranscoder&);
221    CygwinTranscoder& operator=(const CygwinTranscoder&);
222
223
224    // -----------------------------------------------------------------------
225    //  Private data members
226    //
227    //  fIECP
228    //      This is the internet explorer code page for this encoding.
229    //
230    //  fWinCP
231    //      This is the windows code page for this encoding.
232    // -----------------------------------------------------------------------
233    unsigned int    fIECP;
234    unsigned int    fWinCP;
235};
236
237
238
239
240
241//---------------------------------------------------------------------------
242//
243//  class CygwinLCPTranscoder
244//
245//---------------------------------------------------------------------------
246class XMLUTIL_EXPORT CygwinLCPTranscoder : public XMLLCPTranscoder
247{
248public :
249    // -----------------------------------------------------------------------
250    //  Constructors and Destructor
251    // -----------------------------------------------------------------------
252    CygwinLCPTranscoder();
253    ~CygwinLCPTranscoder();
254
255
256    // -----------------------------------------------------------------------
257    //  Implementation of the virtual transcoder interface
258    // -----------------------------------------------------------------------
259    virtual unsigned int calcRequiredSize(const char* const srcText
260        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
261
262    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
263        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
264
265    virtual char* transcode(const XMLCh* const toTranscode);
266    virtual char* transcode(const XMLCh* const toTranscode,
267                            MemoryManager* const manager);
268
269    virtual XMLCh* transcode(const char* const toTranscode);
270    virtual XMLCh* transcode(const char* const toTranscode,
271                             MemoryManager* const manager);
272
273    virtual bool transcode
274    (
275        const   char* const     toTranscode
276        ,       XMLCh* const    toFill
277        , const unsigned int    maxChars
278        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
279    );
280
281    virtual bool transcode
282    (
283        const   XMLCh* const    toTranscode
284        ,       char* const     toFill
285        , const unsigned int    maxChars
286        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
287    );
288
289
290private :
291    // -----------------------------------------------------------------------
292    //  Unimplemented constructors and operators
293    // -----------------------------------------------------------------------
294    CygwinLCPTranscoder(const CygwinLCPTranscoder&);
295    CygwinLCPTranscoder& operator=(const CygwinLCPTranscoder&);
296};
297
298XERCES_CPP_NAMESPACE_END
299
300#endif
Note: See TracBrowser for help on using the repository browser.