source: icXML/icXML-devel/src/icxercesc/util/Transcoders/Win32/Win32TransService.hpp @ 3152

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

New custom icxercesc files

File size: 9.3 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 <xercesc/util/TransService.hpp>
26#include <xercesc/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 transcodeFrom
149    (
150          const XMLByte* const          srcData
151        , const XMLSize_t               srcCount
152        ,       XMLBuffer &             toFill
153    );
154
155
156    virtual XMLSize_t transcodeTo
157    (
158        const   XMLCh* const    srcData
159        , const XMLSize_t       srcCount
160        ,       XMLByte* const  toFill
161        , const XMLSize_t       maxBytes
162        ,       XMLSize_t&      charsEaten
163        , const UnRepOpts       options
164    );
165
166    virtual bool canTranscodeTo
167    (
168        const   unsigned int    toCheck
169    );
170
171
172private :
173    // -----------------------------------------------------------------------
174    //  Unimplemented constructors and operators
175    // -----------------------------------------------------------------------
176    Win32Transcoder(const Win32Transcoder&);
177    Win32Transcoder& operator=(const Win32Transcoder&);
178
179
180    // -----------------------------------------------------------------------
181    //  Private data members
182    //
183    //  fIECP
184    //      This is the code page for this encoding.
185    //
186    //  fUsedDef
187    //      A flag passed into the conversions routines that is set to
188    //      TRUE when a default character was substituted for the actual
189    //      character.
190    //
191    //  fPtrUsedDef
192    //      A pointer to fUsedDef or a null pointer if the code page does not
193    //      support the parameter that returns whether or not a default
194    //      character was substituted.
195    //
196    //  fFromFlags
197    //      These are the flags passed to MultiByteToWideChar.  For some
198    //      code pages, this must be 0.  See the documentation of the function
199    //      for more details.
200    //
201    //  fToFlags
202    //      These are the flags passed to WideCharToMultiByte.  For some
203    //      code pages, this must be 0.  See the documentation of the function
204    //      for more details.
205    //
206    // -----------------------------------------------------------------------
207    UINT    fIECP;
208
209    BOOL    fUsedDef;
210
211    BOOL*   fPtrUsedDef;
212
213    DWORD   fFromFlags;
214
215    DWORD   fToFlags;
216};
217
218
219
220
221
222//---------------------------------------------------------------------------
223//
224//  class Win32LCPTranscoder
225//
226//---------------------------------------------------------------------------
227class XMLUTIL_EXPORT Win32LCPTranscoder : public XMLLCPTranscoder
228{
229public :
230    // -----------------------------------------------------------------------
231    //  Constructors and Destructor
232    // -----------------------------------------------------------------------
233    Win32LCPTranscoder();
234    ~Win32LCPTranscoder();
235
236
237    // -----------------------------------------------------------------------
238    //  Implementation of the virtual transcoder interface
239    // -----------------------------------------------------------------------
240    virtual char* transcode(const XMLCh* const toTranscode,
241                            MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
242
243    virtual XMLCh* transcode(const char* const toTranscode,
244                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
245
246
247    // -----------------------------------------------------------------------
248    //  DEPRECATED old transcode interface
249    // -----------------------------------------------------------------------
250    virtual XMLSize_t calcRequiredSize(const char* const srcText
251        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
252
253    virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
254        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
255
256    virtual bool transcode
257    (
258        const   char* const     toTranscode
259        ,       XMLCh* const    toFill
260        , const XMLSize_t       maxChars
261        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
262    );
263
264    virtual bool transcode
265    (
266        const   XMLCh* const    toTranscode
267        ,       char* const     toFill
268        , const XMLSize_t       maxChars
269        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
270    );
271
272
273private :
274    // -----------------------------------------------------------------------
275    //  Unimplemented constructors and operators
276    // -----------------------------------------------------------------------
277    Win32LCPTranscoder(const Win32LCPTranscoder&);
278    Win32LCPTranscoder& operator=(const Win32LCPTranscoder&);
279
280    MemoryManager*  fManager;
281};
282
283XERCES_CPP_NAMESPACE_END
284
285#endif
Note: See TracBrowser for help on using the repository browser.