source: icXML/icXML-devel/src/xercesc/util/Transcoders/ICU/ICUTransService.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: 8.2 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: ICUTransService.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_ICUTRANSSERVICE_HPP)
23#define XERCESC_INCLUDE_GUARD_ICUTRANSSERVICE_HPP
24
25#include <xercesc/util/Mutexes.hpp>
26#include <icxercesc/util/TransService.hpp>
27
28struct UConverter;
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32class XMLUTIL_EXPORT ICUTransService : public XMLTransService
33{
34public :
35    friend class Uniconv390TransService;
36    // -----------------------------------------------------------------------
37    //  Constructors and Destructor
38    // -----------------------------------------------------------------------
39    ICUTransService(MemoryManager* manager);
40    ~ICUTransService();
41
42
43    // -----------------------------------------------------------------------
44    //  Implementation of the virtual transcoding service API
45    // -----------------------------------------------------------------------
46    virtual int compareIString
47    (
48        const   XMLCh* const    comp1
49        , const XMLCh* const    comp2
50    );
51
52    virtual int compareNIString
53    (
54        const   XMLCh* const    comp1
55        , const XMLCh* const    comp2
56        , const XMLSize_t       maxChars
57    );
58
59    virtual const XMLCh* getId() const;
60
61    virtual XMLLCPTranscoder* makeNewLCPTranscoder(MemoryManager* manager);
62
63    virtual bool supportsSrcOfs() const;
64
65    virtual void upperCase(XMLCh* const toUpperCase);
66    virtual void lowerCase(XMLCh* const toLowerCase);
67
68
69protected :
70    // -----------------------------------------------------------------------
71    //  Protected virtual methods
72    // -----------------------------------------------------------------------
73    virtual XMLTranscoder* makeNewXMLTranscoder
74    (
75        const   XMLCh* const            encodingName
76        ,       XMLTransService::Codes& resValue
77        , const XMLSize_t               blockSize
78        ,       MemoryManager* const    manager
79    );
80
81
82private :
83    // -----------------------------------------------------------------------
84    //  Unimplemented constructors and operators
85    // -----------------------------------------------------------------------
86    ICUTransService(const ICUTransService&);
87    ICUTransService& operator=(const ICUTransService&);
88};
89
90
91
92class XMLUTIL_EXPORT ICUTranscoder : public XMLTranscoder
93{
94public :
95    // -----------------------------------------------------------------------
96    //  Constructors and Destructor
97    // -----------------------------------------------------------------------
98    ICUTranscoder
99    (
100        const   XMLCh* const        encodingName
101        ,       UConverter* const   toAdopt
102        , const XMLSize_t           blockSize
103        , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
104    );
105    ~ICUTranscoder();
106
107
108    // -----------------------------------------------------------------------
109    //  Implementation of the virtual transcoder interface
110    // -----------------------------------------------------------------------
111    virtual XMLSize_t transcodeFrom
112    (
113        const   XMLByte* const          srcData
114        , const XMLSize_t               srcCount
115        ,       XMLCh* const            toFill
116        , const XMLSize_t               maxChars
117        ,       XMLSize_t&              bytesEaten
118        ,       unsigned char* const    charSizes
119    );
120
121    virtual XMLSize_t transcodeTo
122    (
123        const   XMLCh* const    srcData
124        , const XMLSize_t       srcCount
125        ,       XMLByte* const  toFill
126        , const XMLSize_t       maxBytes
127        ,       XMLSize_t&      charsEaten
128        , const UnRepOpts       options
129    );
130
131    virtual bool canTranscodeTo
132    (
133        const   unsigned int    toCheck
134    );
135
136
137
138private :
139    // -----------------------------------------------------------------------
140    //  Unimplemented constructors and operators
141    // -----------------------------------------------------------------------
142    ICUTranscoder();
143    ICUTranscoder(const ICUTranscoder&);
144    ICUTranscoder& operator=(const ICUTranscoder&);
145
146
147    // -----------------------------------------------------------------------
148    //  Private data members
149    //
150    //  fConverter
151    //      This is a pointer to the ICU converter that this transcoder
152    //      uses.
153    //
154    //  fFixed
155    //      This is set to true if the encoding is a fixed size one. This
156    //      can be used to optimize some operations.
157    //
158    //  fSrcOffsets
159    //      This is an array of longs, which are allocated to the size of
160    //      the transcoding block (if any) indicated in the ctor. It is used
161    //      to get the character offsets from ICU, which are then translated
162    //      into an array of char sizes for return.
163    // -----------------------------------------------------------------------
164    UConverter*     fConverter;
165    bool            fFixed;
166    XMLUInt32*      fSrcOffsets;
167};
168
169
170class XMLUTIL_EXPORT ICULCPTranscoder : public XMLLCPTranscoder
171{
172public :
173    // -----------------------------------------------------------------------
174    //  Constructors and Destructor
175    // -----------------------------------------------------------------------
176    ICULCPTranscoder(UConverter* const toAdopt);
177    ~ICULCPTranscoder();
178
179
180    // -----------------------------------------------------------------------
181    //  Implementation of the virtual transcoder interface
182    // -----------------------------------------------------------------------
183    virtual char* transcode(const XMLCh* const toTranscode,
184                            MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
185
186    virtual XMLCh* transcode(const char* const toTranscode,
187                             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
188
189
190    // -----------------------------------------------------------------------
191    //  DEPRECATED old transcode interface
192    // -----------------------------------------------------------------------
193    virtual XMLSize_t calcRequiredSize(const char* const srcText
194        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
195
196    virtual XMLSize_t calcRequiredSize(const XMLCh* const srcText
197        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
198
199    virtual bool transcode
200    (
201        const   char* const     toTranscode
202        ,       XMLCh* const    toFill
203        , const XMLSize_t       maxChars
204        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
205    );
206
207    virtual bool transcode
208    (
209        const   XMLCh* const    toTranscode
210        ,       char* const     toFill
211        , const XMLSize_t       maxChars
212        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
213    );
214
215
216
217private :
218    // -----------------------------------------------------------------------
219    //  Unimplemented constructors and operators
220    // -----------------------------------------------------------------------
221    ICULCPTranscoder();
222    ICULCPTranscoder(const ICULCPTranscoder&);
223    ICULCPTranscoder& operator=(const ICULCPTranscoder&);
224
225
226    // -----------------------------------------------------------------------
227    //  Private data members
228    //
229    //  fConverter
230    //      This is a pointer to the ICU converter that this transcoder
231    //      uses.
232    //
233    //  fMutex
234    //      We have to synchronize threaded calls to the converter.
235    // -----------------------------------------------------------------------
236    UConverter*     fConverter;
237    XMLMutex        fMutex;
238};
239
240XERCES_CPP_NAMESPACE_END
241
242#endif
Note: See TracBrowser for help on using the repository browser.