source: NonGTP/Xerces/xercesc/util/Transcoders/Iconv400/Iconv400TransService.hpp @ 188

Revision 188, 10.7 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-2002 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 * @02A           V5R2M0    200419   jrhansen : support lowercase function
59 * $Id: Iconv400TransService.hpp,v 1.9 2003/12/24 15:24:15 cargilld Exp $
60 */
61
62#ifndef ICONV400TRANSSERVICE_HPP
63#define ICONV400TRANSSERVICE_HPP
64
65#include <xercesc/util/Mutexes.hpp>
66#include <xercesc/util/TransService.hpp>
67#include <qlg.h>
68
69XERCES_CPP_NAMESPACE_BEGIN
70
71struct UConverter;
72
73class XMLUTIL_EXPORT Iconv400TransService : public XMLTransService
74{
75public :
76    // -----------------------------------------------------------------------
77    //  Public, static methods
78    // -----------------------------------------------------------------------
79
80
81    // -----------------------------------------------------------------------
82    //  Constructors and Destructor
83    // -----------------------------------------------------------------------
84    Iconv400TransService();
85    ~Iconv400TransService();
86
87
88    // -----------------------------------------------------------------------
89    //  Implementation of the virtual transcoding service API
90    // -----------------------------------------------------------------------
91    virtual int compareIString
92    (
93        const   XMLCh* const    comp1
94        , const XMLCh* const    comp2
95    );
96
97    virtual int compareNIString
98    (
99        const   XMLCh* const    comp1
100        , const XMLCh* const    comp2
101        , const unsigned int    maxChars
102    );
103
104    virtual const XMLCh* getId() const;
105
106    virtual bool isSpace(const XMLCh toCheck) const;
107
108    virtual XMLLCPTranscoder* makeNewLCPTranscoder();
109
110    virtual bool supportsSrcOfs() const;
111
112    virtual void upperCase(XMLCh* const toUpperCase) const;
113    virtual void lowerCase(XMLCh* const toLowerCase) const;
114
115
116protected :
117    // -----------------------------------------------------------------------
118    //  Protected virtual methods
119    // -----------------------------------------------------------------------
120    virtual XMLTranscoder* makeNewXMLTranscoder
121    (
122        const   XMLCh* const            encodingName
123        ,       XMLTransService::Codes& resValue
124        , const unsigned int            blockSize
125        ,       MemoryManager* const    manager
126    );
127
128
129private :
130    // -----------------------------------------------------------------------
131    //  Unimplemented constructors and operators
132    // -----------------------------------------------------------------------
133    Iconv400TransService(const Iconv400TransService&);
134    Iconv400TransService& operator=(const Iconv400TransService&);
135
136    XMLCh toUnicodeUpper(XMLCh toupper) const;
137    XMLCh toUnicodeLower(XMLCh tolower) const;
138
139    Qlg_CCSID_ReqCtlBlk_T convertCtlblkUpper;
140    Qlg_CCSID_ReqCtlBlk_T convertCtlblkLower;
141
142};
143
144
145
146class XMLUTIL_EXPORT Iconv400Transcoder : public XMLTranscoder
147{
148public :
149    // -----------------------------------------------------------------------
150    //  Constructors and Destructor
151    // -----------------------------------------------------------------------
152    Iconv400Transcoder
153    (
154        const   XMLCh* const      encodingName
155        ,       UConverter* const toAdopt
156        , const unsigned int      blockSize
157        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
158    );
159    ~Iconv400Transcoder();
160
161    // -----------------------------------------------------------------------
162    //  Implementation of the virtual transcoder interface
163    // -----------------------------------------------------------------------
164    virtual unsigned int transcodeFrom
165    (
166        const   XMLByte* const          srcData
167        , const unsigned int            srcCount
168        ,       XMLCh* const            toFill
169        , const unsigned int            maxChars
170        ,       unsigned int&           bytesEaten
171        ,       unsigned char* const    charSizes
172    );
173
174    virtual unsigned int transcodeTo
175    (
176        const   XMLCh* const    srcData
177        , const unsigned int    srcCount
178        ,       XMLByte* const  toFill
179        , const unsigned int    maxBytes
180        ,       unsigned int&   charsEaten
181        , const UnRepOpts       options
182    );
183
184    virtual bool canTranscodeTo
185    (
186        const   unsigned int    toCheck
187    )   const;
188
189
190
191private :
192    // -----------------------------------------------------------------------
193    //  Unimplemented constructors and operators
194    // -----------------------------------------------------------------------
195    Iconv400Transcoder();
196    Iconv400Transcoder(const Iconv400Transcoder&);
197    Iconv400Transcoder& operator=(const Iconv400Transcoder&);
198
199
200    // -----------------------------------------------------------------------
201    //  Private data members
202    //
203    //  fConverter
204    //      This is a pointer to the Iconv400 converter that this transcoder
205    //      uses.
206    //
207    //  fFixed
208    //      This is set to true if the encoding is a fixed size one. This
209    //      can be used to optimize some operations.
210    //
211    //  fSrcOffsets
212    //      This is an array of longs, which are allocated to the size of
213    //      the trancoding block (if any) indicated in the ctor. It is used
214    //      to get the character offsets from Iconv400, which are then translated
215    //      into an array of char sizes for return.
216    // -----------------------------------------------------------------------
217    UConverter*     fConverter;
218    bool            fFixed;
219    long*           fSrcOffsets;
220
221};
222
223
224class XMLUTIL_EXPORT Iconv400LCPTranscoder : public XMLLCPTranscoder
225{
226public :
227    // -----------------------------------------------------------------------
228    //  Constructors and Destructor
229    // -----------------------------------------------------------------------
230    Iconv400LCPTranscoder(UConverter* const toAdopt);
231    ~Iconv400LCPTranscoder();
232
233
234    // -----------------------------------------------------------------------
235    //  Implementation of the virtual transcoder interface
236    // -----------------------------------------------------------------------
237    virtual unsigned int calcRequiredSize(const char* const srcText
238        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
239
240    virtual unsigned int calcRequiredSize(const XMLCh* const srcText
241        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
242
243    virtual char* transcode(const XMLCh* const toTranscode);
244    virtual char* transcode(const XMLCh* const toTranscode,
245                            MemoryManager* const manager);
246
247    virtual XMLCh* transcode(const char* const toTranscode);
248    virtual XMLCh* transcode(const char* const toTranscode,
249                             MemoryManager* const manager);
250
251    virtual bool transcode
252    (
253        const   char* const     toTranscode
254        ,       XMLCh* const    toFill
255        , const unsigned int    maxChars
256        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
257    );
258
259    virtual bool transcode
260    (
261        const   XMLCh* const    toTranscode
262        ,       char* const     toFill
263        , const unsigned int    maxChars
264        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
265    );
266
267
268
269private :
270    // -----------------------------------------------------------------------
271    //  Unimplemented constructors and operators
272    // -----------------------------------------------------------------------
273    Iconv400LCPTranscoder();
274    Iconv400LCPTranscoder(const Iconv400LCPTranscoder&);
275    Iconv400LCPTranscoder& operator=(const Iconv400LCPTranscoder&);
276
277
278    // -----------------------------------------------------------------------
279    //  Private data members
280    //
281    //  fConverter
282    //      This is a pointer to the Iconv converter that this transcoder
283    //      uses.
284    //
285    //  fMutex
286    //      We have to synchronize threaded calls to the converter.
287    // -----------------------------------------------------------------------
288    UConverter*     fConverter;
289    XMLMutex        fMutex;
290};
291
292XERCES_CPP_NAMESPACE_END
293
294#endif
Note: See TracBrowser for help on using the repository browser.