source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/util/Transcoders/Cygwin/CygwinTransService.hpp @ 2674

Revision 2674, 8.5 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19#ifndef CYGWINTRANSSERVICE_HPP
20#define CYGWINTRANSSERVICE_HPP
21
22#include <xercesc/util/TransService.hpp>
23#include <xercesc/util/RefHashTableOf.hpp>
24#include <windows.h>
25
26XERCES_CPP_NAMESPACE_BEGIN
27
28class CPMapEntry;
29
30
31
32//---------------------------------------------------------------------------
33//
34//  class CygwinTransService
35//
36//---------------------------------------------------------------------------
37class XMLUTIL_EXPORT CygwinTransService : public XMLTransService
38{
39public :
40    // -----------------------------------------------------------------------
41    //  Constructors and Destructor
42    // -----------------------------------------------------------------------
43    CygwinTransService();
44    virtual ~CygwinTransService();
45
46
47    // -----------------------------------------------------------------------
48    //  Implementation of the virtual transcoding service API
49    // -----------------------------------------------------------------------
50    virtual int compareIString
51    (
52        const   XMLCh* const    comp1
53        , const XMLCh* const    comp2
54    );
55
56    virtual int compareNIString
57    (
58        const   XMLCh* const    comp1
59        , const XMLCh* const    comp2
60        , const unsigned int    maxChars
61    );
62
63    virtual const XMLCh* getId() const;
64
65    virtual bool isSpace(const XMLCh toCheck) const;
66
67    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
68
69    virtual bool supportsSrcOfs() const;
70
71    virtual void upperCase(XMLCh* const toUpperCase) const;
72    virtual void lowerCase(XMLCh* const toLowerCase) const;
73
74
75protected :
76    // -----------------------------------------------------------------------
77    //  Protected virtual methods, implemented in CygwinTransService.cpp
78    // -----------------------------------------------------------------------
79    virtual XMLTranscoder* makeNewXMLTranscoder
80    (
81        const   XMLCh* const            encodingName
82        ,       XMLTransService::Codes& resValue
83        , const unsigned int            blockSize
84        ,       MemoryManager* const    manager
85    );
86
87private :
88    // -----------------------------------------------------------------------
89    //  Unimplemented constructors and operators
90    // -----------------------------------------------------------------------
91    CygwinTransService(const CygwinTransService&);
92    CygwinTransService& operator=(const CygwinTransService&);
93
94    int auxCompareString
95    (
96        const   XMLCh* const  comp1
97        , const XMLCh* const  comp2
98        , signed long         maxChars
99        , const  bool         ignoreCase
100    );
101
102    static bool isAlias(const HKEY          encodingKey
103                    ,       char* const     aliasBuf = 0
104                    , const unsigned int    nameBufSz = 0);
105
106
107    //      This is a hash table of entries which map encoding names to their
108    //      Windows specific code pages. The code page allows us to create
109    //      transcoders for those encodings. The encoding names come from XML
110    //      files.
111    //
112    //      This map is shared unsynchronized among all threads of the process,
113    //      which is cool since it will be read only once its initialized.
114
115    RefHashTableOf<CPMapEntry>    *fCPMap;
116};
117
118
119
120
121
122
123
124//---------------------------------------------------------------------------
125//
126//  class CygwinTranscoder
127//
128//---------------------------------------------------------------------------
129
130class XMLUTIL_EXPORT CygwinTranscoder : public XMLTranscoder
131{
132public :
133    // -----------------------------------------------------------------------
134    //  Constructors and Destructor
135    // -----------------------------------------------------------------------
136    CygwinTranscoder
137    (
138        const   XMLCh* const    encodingName
139        , const unsigned int    winCP
140        , const unsigned int    ieCP
141        , const unsigned int    blockSize
142        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
143    ~CygwinTranscoder();
144
145
146    // -----------------------------------------------------------------------
147    //  Implementation of the virtual transcoder interface
148    // -----------------------------------------------------------------------
149    virtual unsigned int transcodeFrom
150    (
151        const   XMLByte* const          srcData
152        , const unsigned int            srcCount
153        ,       XMLCh* const            toFill
154        , const unsigned int            maxChars
155        ,       unsigned int&           bytesEaten
156        ,       unsigned char* const    charSizes
157    );
158
159    virtual unsigned int transcodeTo
160    (
161        const   XMLCh* const    srcData
162        , const unsigned int    srcCount
163        ,       XMLByte* const  toFill
164        , const unsigned int    maxBytes
165        ,       unsigned int&   charsEaten
166        , const UnRepOpts       options
167    );
168
169    virtual bool canTranscodeTo
170    (
171        const   unsigned int    toCheck
172    )   const;
173
174
175private :
176    // -----------------------------------------------------------------------
177    //  Unimplemented constructors and operators
178    // -----------------------------------------------------------------------
179    CygwinTranscoder(const CygwinTranscoder&);
180    CygwinTranscoder& operator=(const CygwinTranscoder&);
181
182
183    // -----------------------------------------------------------------------
184    //  Private data members
185    //
186    //  fIECP
187    //      This is the internet explorer code page for this encoding.
188    //
189    //  fWinCP
190    //      This is the windows code page for this encoding.
191    // -----------------------------------------------------------------------
192    unsigned int    fIECP;
193    unsigned int    fWinCP;
194};
195
196
197
198
199
200//---------------------------------------------------------------------------
201//
202//  class CygwinLCPTranscoder
203//
204//---------------------------------------------------------------------------
205class XMLUTIL_EXPORT CygwinLCPTranscoder : public XMLLCPTranscoder
206{
207public :
208    // -----------------------------------------------------------------------
209    //  Constructors and Destructor
210    // -----------------------------------------------------------------------
211    CygwinLCPTranscoder();
212    ~CygwinLCPTranscoder();
213
214
215    // -----------------------------------------------------------------------
216    //  Implementation of the virtual transcoder interface
217    // -----------------------------------------------------------------------
218    virtual unsigned int calcRequiredSize(const char* const srcText
219        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
220
221    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
222        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
223
224    virtual char* transcode(const XMLCh* const toTranscode);
225    virtual char* transcode(const XMLCh* const toTranscode,
226                            MemoryManager* const manager);
227
228    virtual XMLCh* transcode(const char* const toTranscode);
229    virtual XMLCh* transcode(const char* const toTranscode,
230                             MemoryManager* const manager);
231
232    virtual bool transcode
233    (
234        const   char* const     toTranscode
235        ,       XMLCh* const    toFill
236        , const unsigned int    maxChars
237        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
238    );
239
240    virtual bool transcode
241    (
242        const   XMLCh* const    toTranscode
243        ,       char* const     toFill
244        , const unsigned int    maxChars
245        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
246    );
247
248
249private :
250    // -----------------------------------------------------------------------
251    //  Unimplemented constructors and operators
252    // -----------------------------------------------------------------------
253    CygwinLCPTranscoder(const CygwinLCPTranscoder&);
254    CygwinLCPTranscoder& operator=(const CygwinLCPTranscoder&);
255};
256
257XERCES_CPP_NAMESPACE_END
258
259#endif
Note: See TracBrowser for help on using the repository browser.