source: NonGTP/Xerces/xerces/include/xercesc/util/Transcoders/ICU/ICUTransService.hpp @ 358

Revision 358, 10.5 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: ICUTransService.hpp,v $
19 * Revision 1.10  2004/09/08 13:56:44  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.9  2003/12/24 15:24:15  cargilld
23 * More updates to memory management so that the static memory manager.
24 *
25 * Revision 1.8  2003/05/17 16:32:17  knoaman
26 * Memory manager implementation : transcoder update.
27 *
28 * Revision 1.7  2003/05/15 18:47:03  knoaman
29 * Partial implementation of the configurable memory manager.
30 *
31 * Revision 1.6  2003/03/07 18:15:57  tng
32 * Return a reference instead of void for operator=
33 *
34 * Revision 1.5  2002/11/22 14:56:47  tng
35 * 390: Uniconv390 support.  Patch by Chris Larsson and Stephen Dulin.
36 *
37 * Revision 1.4  2002/11/11 14:08:01  tng
38 * Fix: UConverter should be declared outside xerces-c++ namespace
39 *
40 * Revision 1.3  2002/11/04 15:14:33  tng
41 * C++ Namespace Support.
42 *
43 * Revision 1.2  2002/04/09 15:44:00  knoaman
44 * Add lower case string support.
45 *
46 * Revision 1.1.1.1  2002/02/01 22:22:36  peiyongz
47 * sane_include
48 *
49 * Revision 1.10  2000/03/18 00:00:03  roddey
50 * Initial updates for two way transcoding support
51 *
52 * Revision 1.9  2000/03/02 19:55:34  roddey
53 * This checkin includes many changes done while waiting for the
54 * 1.1.0 code to be finished. I can't list them all here, but a list is
55 * available elsewhere.
56 *
57 * Revision 1.8  2000/02/06 07:48:32  rahulj
58 * Year 2K copyright swat.
59 *
60 * Revision 1.7  2000/01/25 22:49:56  roddey
61 * Moved the supportsSrcOfs() method from the individual transcoder to the
62 * transcoding service, where it should have been to begin with.
63 *
64 * Revision 1.6  2000/01/25 19:19:08  roddey
65 * Simple addition of a getId() method to the xcode and netacess abstractions to
66 * allow each impl to give back an id string.
67 *
68 * Revision 1.5  2000/01/19 23:21:11  abagchi
69 * Made this file compatible with ICU 1.4
70 *
71 * Revision 1.4  2000/01/19 00:58:07  roddey
72 * Update to support new ICU 1.4 release.
73 *
74 * Revision 1.3  1999/12/18 00:22:32  roddey
75 * Changes to support the new, completely orthagonal, transcoder architecture.
76 *
77 * Revision 1.2  1999/12/15 19:43:45  roddey
78 * Now implements the new transcoding abstractions, with separate interface
79 * classes for XML transcoders and local code page transcoders.
80 *
81 * Revision 1.1.1.1  1999/11/09 01:06:08  twl
82 * Initial checkin
83 *
84 * Revision 1.3  1999/11/08 20:45:34  rahul
85 * Swat for adding in Product name and CVS comment log variable.
86 *
87 */
88
89#ifndef ICUTRANSSERVICE_HPP
90#define ICUTRANSSERVICE_HPP
91
92#include <xercesc/util/Mutexes.hpp>
93#include <xercesc/util/TransService.hpp>
94
95struct UConverter;
96
97XERCES_CPP_NAMESPACE_BEGIN
98
99class XMLUTIL_EXPORT ICUTransService : public XMLTransService
100{
101public :
102    friend class Uniconv390TransService;
103    // -----------------------------------------------------------------------
104    //  Constructors and Destructor
105    // -----------------------------------------------------------------------
106    ICUTransService();
107    ~ICUTransService();
108
109
110    // -----------------------------------------------------------------------
111    //  Implementation of the virtual transcoding service API
112    // -----------------------------------------------------------------------
113    virtual int compareIString
114    (
115        const   XMLCh* const    comp1
116        , const XMLCh* const    comp2
117    );
118
119    virtual int compareNIString
120    (
121        const   XMLCh* const    comp1
122        , const XMLCh* const    comp2
123        , const unsigned int    maxChars
124    );
125
126    virtual const XMLCh* getId() const;
127
128    virtual bool isSpace(const XMLCh toCheck) const;
129
130    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
131
132    virtual bool supportsSrcOfs() const;
133
134    virtual void upperCase(XMLCh* const toUpperCase) const;
135    virtual void lowerCase(XMLCh* const toLowerCase) const;
136
137
138protected :
139    // -----------------------------------------------------------------------
140    //  Protected virtual methods
141    // -----------------------------------------------------------------------
142    virtual XMLTranscoder* makeNewXMLTranscoder
143    (
144        const   XMLCh* const            encodingName
145        ,       XMLTransService::Codes& resValue
146        , const unsigned int            blockSize
147        ,       MemoryManager* const    manager
148    );
149
150
151private :
152    // -----------------------------------------------------------------------
153    //  Unimplemented constructors and operators
154    // -----------------------------------------------------------------------
155    ICUTransService(const ICUTransService&);
156    ICUTransService& operator=(const ICUTransService&);
157};
158
159
160
161class XMLUTIL_EXPORT ICUTranscoder : public XMLTranscoder
162{
163public :
164    // -----------------------------------------------------------------------
165    //  Constructors and Destructor
166    // -----------------------------------------------------------------------
167    ICUTranscoder
168    (
169        const   XMLCh* const        encodingName
170        ,       UConverter* const   toAdopt
171        , const unsigned int        blockSize
172        , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
173    );
174    ~ICUTranscoder();
175
176
177    // -----------------------------------------------------------------------
178    //  Implementation of the virtual transcoder interface
179    // -----------------------------------------------------------------------
180    virtual unsigned int transcodeFrom
181    (
182        const   XMLByte* const          srcData
183        , const unsigned int            srcCount
184        ,       XMLCh* const            toFill
185        , const unsigned int            maxChars
186        ,       unsigned int&           bytesEaten
187        ,       unsigned char* const    charSizes
188    );
189
190    virtual unsigned int transcodeTo
191    (
192        const   XMLCh* const    srcData
193        , const unsigned int    srcCount
194        ,       XMLByte* const  toFill
195        , const unsigned int    maxBytes
196        ,       unsigned int&   charsEaten
197        , const UnRepOpts       options
198    );
199
200    virtual bool canTranscodeTo
201    (
202        const   unsigned int    toCheck
203    )   const;
204
205
206
207private :
208    // -----------------------------------------------------------------------
209    //  Unimplemented constructors and operators
210    // -----------------------------------------------------------------------
211    ICUTranscoder();
212    ICUTranscoder(const ICUTranscoder&);
213    ICUTranscoder& operator=(const ICUTranscoder&);
214
215
216    // -----------------------------------------------------------------------
217    //  Private data members
218    //
219    //  fConverter
220    //      This is a pointer to the ICU converter that this transcoder
221    //      uses.
222    //
223    //  fFixed
224    //      This is set to true if the encoding is a fixed size one. This
225    //      can be used to optimize some operations.
226    //
227    //  fSrcOffsets
228    //      This is an array of longs, which are allocated to the size of
229    //      the trancoding block (if any) indicated in the ctor. It is used
230    //      to get the character offsets from ICU, which are then translated
231    //      into an array of char sizes for return.
232    // -----------------------------------------------------------------------
233    UConverter*     fConverter;
234    bool            fFixed;
235    XMLUInt32*      fSrcOffsets;
236};
237
238
239class XMLUTIL_EXPORT ICULCPTranscoder : public XMLLCPTranscoder
240{
241public :
242    // -----------------------------------------------------------------------
243    //  Constructors and Destructor
244    // -----------------------------------------------------------------------
245    ICULCPTranscoder(UConverter* const toAdopt);
246    ~ICULCPTranscoder();
247
248
249    // -----------------------------------------------------------------------
250    //  Implementation of the virtual transcoder interface
251    // -----------------------------------------------------------------------
252    virtual unsigned int calcRequiredSize(const char* const srcText
253        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
254
255    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
256        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
257
258    virtual char* transcode(const XMLCh* const toTranscode);
259    virtual char* transcode(const XMLCh* const toTranscode,
260                            MemoryManager* const manager);
261
262    virtual XMLCh* transcode(const char* const toTranscode);
263    virtual XMLCh* transcode(const char* const toTranscode,
264                             MemoryManager* const manager);
265
266    virtual bool transcode
267    (
268        const   char* const     toTranscode
269        ,       XMLCh* const    toFill
270        , const unsigned int    maxChars
271        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
272    );
273
274    virtual bool transcode
275    (
276        const   XMLCh* const    toTranscode
277        ,       char* const     toFill
278        , const unsigned int    maxChars
279        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
280    );
281
282
283
284private :
285    // -----------------------------------------------------------------------
286    //  Unimplemented constructors and operators
287    // -----------------------------------------------------------------------
288    ICULCPTranscoder();
289    ICULCPTranscoder(const ICULCPTranscoder&);
290    ICULCPTranscoder& operator=(const ICULCPTranscoder&);
291
292
293    // -----------------------------------------------------------------------
294    //  Private data members
295    //
296    //  fConverter
297    //      This is a pointer to the ICU converter that this transcoder
298    //      uses.
299    //
300    //  fMutex
301    //      We have to synchronize threaded calls to the converter.
302    // -----------------------------------------------------------------------
303    UConverter*     fConverter;
304    XMLMutex        fMutex;
305};
306
307XERCES_CPP_NAMESPACE_END
308
309#endif
Note: See TracBrowser for help on using the repository browser.