|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: Uniconv390TransService.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 #ifndef UNICONV390TRANSSERVICE_HPP |
|
39 #define UNICONV390TRANSSERVICE_HPP |
|
40 |
|
41 #include <xercesc/util/Mutexes.hpp> |
|
42 #include <xercesc/util/TransService.hpp> |
|
43 #include <xercesc/util/Transcoders/ICU/ICUTransService.hpp> |
|
44 #include "uniconv.h" |
|
45 |
|
46 XERCES_CPP_NAMESPACE_BEGIN |
|
47 |
|
48 typedef struct uniconvconverter { |
|
49 XMLMutex fMutex; |
|
50 uniconv_t fIconv390DescriptorFrom; |
|
51 uniconv_t fIconv390DescriptorTo; |
|
52 } uniconvconverter_t; |
|
53 |
|
54 typedef struct uniconvcaseconverter { |
|
55 XMLMutex fcaseMutex; |
|
56 uniconv_t ftoupperhand; |
|
57 uniconv_t ftolowerhand; |
|
58 } uniconvcaseconverter_t; |
|
59 |
|
60 class XMLUTIL_EXPORT Uniconv390TransService : public XMLTransService |
|
61 { |
|
62 public : |
|
63 // ----------------------------------------------------------------------- |
|
64 // Constructors and Destructor |
|
65 // ----------------------------------------------------------------------- |
|
66 Uniconv390TransService(); |
|
67 ~Uniconv390TransService(); |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------- |
|
71 // Implementation of the virtual transcoding service API |
|
72 // ----------------------------------------------------------------------- |
|
73 virtual int compareIString |
|
74 ( |
|
75 const XMLCh* const comp1 |
|
76 , const XMLCh* const comp2 |
|
77 ); |
|
78 |
|
79 virtual int compareNIString |
|
80 ( |
|
81 const XMLCh* const comp1 |
|
82 , const XMLCh* const comp2 |
|
83 , const unsigned int maxChars |
|
84 ); |
|
85 |
|
86 virtual const XMLCh* getId() const; |
|
87 |
|
88 virtual bool isSpace(const XMLCh toCheck) const; |
|
89 |
|
90 virtual XMLLCPTranscoder* makeNewLCPTranscoder(); |
|
91 |
|
92 virtual bool supportsSrcOfs() const; |
|
93 |
|
94 virtual void upperCase(XMLCh* const toUpperCase) const; |
|
95 virtual void lowerCase(XMLCh* const toLowerCase) const; |
|
96 |
|
97 protected : |
|
98 // ----------------------------------------------------------------------- |
|
99 // Protected virtual methods |
|
100 // ----------------------------------------------------------------------- |
|
101 virtual XMLTranscoder* makeNewXMLTranscoder |
|
102 ( |
|
103 const XMLCh* const encodingName |
|
104 , XMLTransService::Codes& resValue |
|
105 , const unsigned int blockSize |
|
106 , MemoryManager* const manager |
|
107 ); |
|
108 |
|
109 virtual void initTransService(); |
|
110 |
|
111 private : |
|
112 // ----------------------------------------------------------------------- |
|
113 // Unimplemented constructors and operators |
|
114 // ----------------------------------------------------------------------- |
|
115 Uniconv390TransService(const Uniconv390TransService&); |
|
116 Uniconv390TransService& operator=(const Uniconv390TransService&); |
|
117 ICUTransService * fICUService; |
|
118 XMLLCPTranscoder* fLCPTranscoder; |
|
119 uniconvcaseconverter_t *fCaseConverter; |
|
120 }; |
|
121 |
|
122 |
|
123 |
|
124 class XMLUTIL_EXPORT Uniconv390Transcoder : public XMLTranscoder |
|
125 { |
|
126 public : |
|
127 // ----------------------------------------------------------------------- |
|
128 // Constructors and Destructor |
|
129 // ----------------------------------------------------------------------- |
|
130 Uniconv390Transcoder |
|
131 ( |
|
132 const XMLCh* const encodingName |
|
133 , uniconvconverter_t* const toAdopt |
|
134 , const unsigned int blockSize |
|
135 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
136 ); |
|
137 ~Uniconv390Transcoder(); |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------- |
|
141 // Implementation of the virtual transcoder interface |
|
142 // ----------------------------------------------------------------------- |
|
143 virtual unsigned int transcodeFrom |
|
144 ( |
|
145 const XMLByte* const srcData |
|
146 , const unsigned int srcCount |
|
147 , XMLCh* const toFill |
|
148 , const unsigned int maxChars |
|
149 , unsigned int& bytesEaten |
|
150 , unsigned char* const charSizes |
|
151 ); |
|
152 |
|
153 virtual unsigned int transcodeTo |
|
154 ( |
|
155 const XMLCh* const srcData |
|
156 , const unsigned int srcCount |
|
157 , XMLByte* const toFill |
|
158 , const unsigned int maxBytes |
|
159 , unsigned int& charsEaten |
|
160 , const UnRepOpts options |
|
161 ); |
|
162 |
|
163 virtual bool canTranscodeTo |
|
164 ( |
|
165 const unsigned int toCheck |
|
166 ) const; |
|
167 |
|
168 |
|
169 |
|
170 private : |
|
171 // ----------------------------------------------------------------------- |
|
172 // Unimplemented constructors and operators |
|
173 // ----------------------------------------------------------------------- |
|
174 Uniconv390Transcoder(); |
|
175 Uniconv390Transcoder(const Uniconv390Transcoder&); |
|
176 Uniconv390Transcoder& operator=(const Uniconv390Transcoder&); |
|
177 |
|
178 ICUTranscoder * fICUTranscoder; |
|
179 |
|
180 // ----------------------------------------------------------------------- |
|
181 // Private data members |
|
182 // |
|
183 // fConverter |
|
184 // This is a pointer to the converter structure that this transcoder |
|
185 // uses. |
|
186 // |
|
187 // ----------------------------------------------------------------------- |
|
188 uniconvconverter_t *fConverter; |
|
189 }; |
|
190 |
|
191 |
|
192 class XMLUTIL_EXPORT Uniconv390LCPTranscoder : public XMLLCPTranscoder |
|
193 { |
|
194 public : |
|
195 // ----------------------------------------------------------------------- |
|
196 // Constructors and Destructor |
|
197 // ----------------------------------------------------------------------- |
|
198 Uniconv390LCPTranscoder( uniconvconverter_t* const toAdopt); |
|
199 ~Uniconv390LCPTranscoder(); |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------- |
|
203 // Implementation of the virtual transcoder interface |
|
204 // ----------------------------------------------------------------------- |
|
205 virtual unsigned int calcRequiredSize(const char* const srcText |
|
206 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
|
207 |
|
208 virtual unsigned int calcRequiredSize(const XMLCh* const srcText |
|
209 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
|
210 |
|
211 virtual char* transcode(const XMLCh* const toTranscode); |
|
212 virtual char* transcode(const XMLCh* const toTranscode, |
|
213 MemoryManager* const manager); |
|
214 |
|
215 virtual XMLCh* transcode(const char* const toTranscode); |
|
216 virtual XMLCh* transcode(const char* const toTranscode, |
|
217 MemoryManager* const manager); |
|
218 |
|
219 virtual bool transcode |
|
220 ( |
|
221 const char* const toTranscode |
|
222 , XMLCh* const toFill |
|
223 , const unsigned int maxChars |
|
224 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
225 ); |
|
226 |
|
227 virtual bool transcode |
|
228 ( |
|
229 const XMLCh* const toTranscode |
|
230 , char* const toFill |
|
231 , const unsigned int maxChars |
|
232 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
|
233 ); |
|
234 |
|
235 |
|
236 |
|
237 private : |
|
238 // ----------------------------------------------------------------------- |
|
239 // Unimplemented constructors and operators |
|
240 // ----------------------------------------------------------------------- |
|
241 Uniconv390LCPTranscoder(); |
|
242 Uniconv390LCPTranscoder(const Uniconv390LCPTranscoder&); |
|
243 Uniconv390LCPTranscoder& operator=(const Uniconv390LCPTranscoder&); |
|
244 |
|
245 ICULCPTranscoder * fICULCPTranscoder; |
|
246 |
|
247 // ----------------------------------------------------------------------- |
|
248 // Private data members |
|
249 // |
|
250 // fConverter |
|
251 // This is a pointer to the converter structure that this transcoder |
|
252 // uses. |
|
253 // ----------------------------------------------------------------------- |
|
254 uniconvconverter_t *fConverter; |
|
255 }; |
|
256 |
|
257 XERCES_CPP_NAMESPACE_END |
|
258 |
|
259 #endif |