source: icXML/icXML-devel/src/xercesc/util/Transcoders/Win32/Win32TransService.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 9.1 KB
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 * $Id: Win32TransService.hpp 676954 2008-07-15 16:29:19Z dbertoni $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_WIN32TRANSSERVICE_HPP)
23#define XERCESC_INCLUDE_GUARD_WIN32TRANSSERVICE_HPP
24
25#include <icxercesc/util/TransService.hpp>
26#include <icxercesc/util/RefHashTableOf.hpp>
27#include <windows.h>
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31class CPMapEntry;
32
33
34
35//---------------------------------------------------------------------------
36//
37//  class Win32TransService
38//
39//---------------------------------------------------------------------------
40class XMLUTIL_EXPORT Win32TransService : public XMLTransService
41{
42public :
43    // -----------------------------------------------------------------------
44    //  Constructors and Destructor
45    // -----------------------------------------------------------------------
46    Win32TransService(MemoryManager* manager);
47    virtual ~Win32TransService();
48
49
50    // -----------------------------------------------------------------------
51    //  Implementation of the virtual transcoding service API
52    // -----------------------------------------------------------------------
53    virtual int compareIString
54    (
55        const   XMLCh* const    comp1
56        , const XMLCh* const    comp2
57    );
58
59    virtual int compareNIString
60    (
61        const   XMLCh* const    comp1
62        , const XMLCh* const    comp2
63        , const XMLSize_t       maxChars
64    );
65
66    virtual const XMLCh* getId() const;
67
68    virtual XMLLCPTranscoder* makeNewLCPTranscoder(MemoryManager* manager);
69
70    virtual bool supportsSrcOfs() const;
71
72    virtual void upperCase(XMLCh* const toUpperCase);
73    virtual void lowerCase(XMLCh* const toLowerCase);
74
75
76protected :
77    // -----------------------------------------------------------------------
78    //  Protected virtual methods
79    // -----------------------------------------------------------------------
80    virtual XMLTranscoder* makeNewXMLTranscoder
81    (
82        const   XMLCh* const            encodingName
83        ,       XMLTransService::Codes& resValue
84        , const XMLSize_t               blockSize
85        ,       MemoryManager* const    manager
86    );
87
88
89private :
90    // -----------------------------------------------------------------------
91    //  Unimplemented constructors and operators
92    // -----------------------------------------------------------------------
93    Win32TransService(const Win32TransService&);
94    Win32TransService& operator=(const Win32TransService&);
95
96    //      This is a hash table of entries which map encoding names to their
97    //      Windows specific code pages. The code page allows us to create
98    //      transcoders for those encodings. The encoding names come from XML
99    //      files.
100    //
101    //      This map is shared unsynchronized among all threads of the process,
102    //      which is cool since it will be read only once its initialized.
103
104    RefHashTableOf<CPMapEntry>    *fCPMap;
105    MemoryManager*  fManager;
106};
107
108
109
110
111
112
113
114//---------------------------------------------------------------------------
115//
116//  class Win32Transcoder
117//
118//---------------------------------------------------------------------------
119
120class XMLUTIL_EXPORT Win32Transcoder : public XMLTranscoder
121{
122public :
123    // -----------------------------------------------------------------------
124    //  Constructors and Destructor
125    // -----------------------------------------------------------------------
126    Win32Transcoder
127    (
128        const   XMLCh* const    encodingName
129        , const unsigned int    ieCP
130        , const XMLSize_t       blockSize
131        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager);
132    ~Win32Transcoder();
133
134
135    // -----------------------------------------------------------------------
136    //  Implementation of the virtual transcoder interface
137    // -----------------------------------------------------------------------
138    virtual XMLSize_t transcodeFrom
139    (
140        const   XMLByte* const          srcData
141        , const XMLSize_t               srcCount
142        ,       XMLCh* const            toFill
143        , const XMLSize_t               maxChars
144        ,       XMLSize_t&              bytesEaten
145        ,       unsigned char* const    charSizes
146    );
147
148    virtual XMLSize_t transcodeTo
149    (
150        const   XMLCh* const    srcData
151        , const XMLSize_t       srcCount
152        ,       XMLByte* const  toFill
153        , const XMLSize_t       maxBytes
154        ,       XMLSize_t&      charsEaten
155        , const UnRepOpts       options
156    );
157
158    virtual bool canTranscodeTo
159    (
160        const   unsigned int    toCheck
161    );
162
163
164private :
165    // -----------------------------------------------------------------------
166    //  Unimplemented constructors and operators
167    // -----------------------------------------------------------------------
168    Win32Transcoder(const Win32Transcoder&);
169    Win32Transcoder& operator=(const Win32Transcoder&);
170
171
172    // -----------------------------------------------------------------------
173    //  Private data members
174    //
175    //  fIECP
176    //      This is the code page for this encoding.
177    //
178    //  fUsedDef
179    //      A flag passed into the conversions routines that is set to
180    //      TRUE when a default character was substituted for the actual
181    //      character.
182    //
183    //  fPtrUsedDef
184    //      A pointer to fUsedDef or a null pointer if the code page does not
185    //      support the parameter that returns whether or not a default
186    //      character was substituted.
187    //
188    //  fFromFlags
189    //      These are the flags passed to MultiByteToWideChar.  For some
190    //      code pages, this must be 0.  See the documentation of the function
191    //      for more details.
192    //
193    //  fToFlags
194    //      These are the flags passed to WideCharToMultiByte.  For some
195    //      code pages, this must be 0.  See the documentation of the function
196    //      for more details.
197    //
198    // -----------------------------------------------------------------------
199    UINT    fIECP;
200
201    BOOL    fUsedDef;
202
203    BOOL*   fPtrUsedDef;
204
205    DWORD   fFromFlags;
206
207    DWORD   fToFlags;
208};
209
210
211
212
213
214//---------------------------------------------------------------------------
215//
216//  class Win32LCPTranscoder
217//
218//---------------------------------------------------------------------------
219class XMLUTIL_EXPORT Win32LCPTranscoder : public XMLLCPTranscoder
220{
221public :
222    // -----------------------------------------------------------------------
223    //  Constructors and Destructor
224    // -----------------------------------------------------------------------
225    Win32LCPTranscoder();
226    ~Win32LCPTranscoder();
227
228
229    // -----------------------------------------------------------------------
230    //  Implementation of the virtual transcoder interface
231    // -----------------------------------------------------------------------
232    virtual char* transcode(const XMLCh* const toTranscode,
233                            MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
234
235    virtual XMLCh* transcode(const char* const toTranscode,
236                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
237
238
239    // -----------------------------------------------------------------------
240    //  DEPRECATED old transcode interface
241    // -----------------------------------------------------------------------
242    virtual XMLSize_t calcRequiredSize(const char* const srcText
243        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
244
245    virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
246        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
247
248    virtual bool transcode
249    (
250        const   char* const     toTranscode
251        ,       XMLCh* const    toFill
252        , const XMLSize_t       maxChars
253        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
254    );
255
256    virtual bool transcode
257    (
258        const   XMLCh* const    toTranscode
259        ,       char* const     toFill
260        , const XMLSize_t       maxChars
261        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
262    );
263
264
265private :
266    // -----------------------------------------------------------------------
267    //  Unimplemented constructors and operators
268    // -----------------------------------------------------------------------
269    Win32LCPTranscoder(const Win32LCPTranscoder&);
270    Win32LCPTranscoder& operator=(const Win32LCPTranscoder&);
271
272    MemoryManager*  fManager;
273};
274
275XERCES_CPP_NAMESPACE_END
276
277#endif
Note: See TracBrowser for help on using the repository browser.