source: NonGTP/Xerces/xercesc/util/Transcoders/ICU/ICUTransService.hpp @ 188

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