Xalan-C++ API Reference 1.12.0
XalanTranscodingServices.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680)
19#define XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
28#include <cassert>
29
30
31
34
35
36
37namespace XALAN_CPP_NAMESPACE {
38
39
40
41class XalanOutputTranscoder;
42
43
44
46{
47public:
48
49 /**
50 * Perform static initialization. See class PlatformSupportInit.
51 */
52 static void
53 initialize(MemoryManager& theManager);
54
55 /**
56 * Perform static shut down. See class PlatformSupportInit.
57 */
58 static void
60
61 typedef unsigned char XalanXMLByte;
63
64 static size_type
66 {
67 assert(theBytes != 0);
68
69 size_type i = 0;
70
71 while(theBytes[i] != 0)
72 {
73 ++i;
74 }
75
76 return i;
77 }
78
79 enum eCode
80 {
84 SupportFilesNotFound
85 };
86
87
88 /**
89 * Create a transcoder instance for the specified encoding.
90 *
91 * @param theEncodingName The name of the desired output encoding.
92 * @param theResult The error code.
93 * @param theTarget The target array for storing the transcoded data.
94 * @param theBlockSize The block size the transcoder should use.
95 * @return The new transcoder, or 0 if there was an error.
96 */
99 MemoryManager& theManager,
103
106 MemoryManager& theManager,
110
111 /**
112 * Destroy a transcoder instance.
113 *
114 * @theTranscoder The transcoder to destroy.
115 */
116 static void
118
119 /**
120 * Determine if the encoding name supplied is equivalent to UTF-8.
121 *
122 * @param theEncodingName The name of the output encoding.
123 * @return true or false
124 */
125 static bool
127
128 /**
129 * Determine if the encoding name supplied is equivalent to UTF-8.
130 *
131 * @param theEncodingName The name of the output encoding.
132 * @return true or false
133 */
134 static bool
136
137 /**
138 * Determine if the encoding name supplied is equivalent to UTF-16.
139 *
140 * @param theEncodingName The name of the output encoding.
141 * @return true or false
142 */
143 static bool
145
146 /**
147 * Determine if the encoding name supplied is equivalent to UTF-16.
148 *
149 * @param theEncodingName The name of the output encoding.
150 * @return true or false
151 */
152 static bool
154
155 /**
156 * Determine if the encoding name supplied is equivalent to UTF-32.
157 *
158 * @param theEncodingName The name of the output encoding.
159 * @return true or false
160 */
161 static bool
163
164 /**
165 * Determine if the encoding name supplied is equivalent to UTF-32.
166 *
167 * @param theEncodingName The name of the output encoding.
168 * @return true or false
169 */
170 static bool
172
173 /**
174 * Get an array that contains any leading bytes that should be
175 * written to an XML stream for the specified encoding. For example,
176 * if the encoding is UTF-16, the vector will contain the appropriate
177 * byte order mark for the current platform. If there is no
178 * prolog for the encoding, or the encoding is unknown, an empty
179 * array is returned.
180 *
181 * @param theEncodingName The name of the desired output encoding.
182 * @return An array containing the appropriate bytes.
183 */
184 static const XalanXMLByte*
186
187 /**
188 * Get the maximum character value for the encoding.
189 *
190 * @param theEncoding The encoding name.
191 * @return The maximum character value the encoding supports.
192 */
193 static XalanDOMChar
195
196 /**
197 * Get the maximum character value for the local code page.
198 * This is now deprecated, since it's impossibly broken.
199 *
200 * @deprecated
201 *
202 * @return The maximum character value the local code page supports.
203 */
204 static XalanDOMChar
206
207 /**
208 * Determine if the output stage can safely skip transcoding
209 * by truncating.
210 *
211 * @param theEncoding The encoding name.
212 * @return true if truncation is possible, false if not.
213 */
214 static bool
216
217 static const XalanDOMChar s_utf8String[];
218
219 static const XalanDOMChar s_utf16String[];
220
221 static const XalanDOMChar s_utf16LEString[];
222
223 static const XalanDOMChar s_utf16BEString[];
224
225 static const XalanDOMChar s_utf32String[];
226
227 static const XalanDOMChar s_asciiString[];
228
229 static const XalanDOMChar s_usASCIIString[];
230
231 static const XalanDOMChar s_windows1250String[];
232
233 static const XalanDOMChar s_iso88591String[];
234
235 static const XalanDOMChar s_shiftJISString[];
236
237
239 {
240 public:
241
246 const Locator* theLocator = 0);
247
249
250 virtual
252
253 eCode
254 getCode() const
255 {
256 return m_code;
257 }
258
259 const XalanDOMString&
261 {
262 return m_encoding;
263 }
264
265 virtual const XalanDOMChar*
266 getType() const
267 {
268 return s_type;
269 }
270
271 private:
272
273 static const XalanDOMChar s_type[];
274
275 const eCode m_code;
276
277 mutable XalanDOMString m_encoding;
278 };
279
281 {
282 public:
283
288 const Locator* theLocator = 0);
289
291
292 virtual
294
297 {
298 return m_badCharacter;
299 }
300
301 const XalanDOMString&
303 {
304 return m_encoding;
305 }
306
307 virtual const XalanDOMChar*
308 getType() const
309 {
310 return s_type;
311 }
312
313 private:
314
315 static const XalanDOMChar s_type[];
316
317
318 const XalanUnicodeChar m_badCharacter;
319
320 mutable XalanDOMString m_encoding;
321 };
322
323private:
324
325 static const XalanXMLByte s_dummyByteOrderMark[];
326 static const XalanXMLByte s_UTF8ByteOrderMark[];
327 static const XalanDOMChar s_UTF16ByteOrderMark[];
328};
329
330
331
333{
334public:
335
339
340 explicit
342
343 virtual
345
346 MemoryManager&
348 {
349 return m_memoryManager;
350 }
351
352 /**
353 * Transcode data from UTF-16 to the transcoder's encoding. If successfull,
354 * theResult will be set to OK. If not, it will be set to one of the other
355 * codes.
356 *
357 * @param theSourceData The source data to transcode
358 * @param theSourceCount The length of the source data.
359 * @param theTarget The target array for storing the transcoded data.
360 * @param theTargetSize The number of characters that can be stored in the target.
361 * @param theSourceCharsTranscoded The count of the source characters that were transcoded.
362 * @param theTargetBytesUsed The number of characters stored in the target array
363 * @return The result code.
364 */
365 virtual eCode
373
374 /**
375 * Transcode data from the transcoder's encoding to UTF-16. If successfull,
376 * theResult will be set to OK. If not, it will be set to one of the other
377 * codes.
378 *
379 * @param theSourceData The source data to transcode
380 * @param theSourceCount The length of the source data.
381 * @param theTarget The target array for storing the transcoded data.
382 * @param theTargetSize The number of characters that can be stored in the target.
383 * @param theSourceCharsTranscoded The count of the source characters that were transcoded.
384 * @param theTargetBytesUsed The number of characters stored in the target array
385 * @param theCharSizes For each character in theTarget, the number of characters consumed from theSourceData.
386 * @return The result code.
387 */
388 virtual eCode
396 unsigned char* theCharSizes) = 0;
397
398 virtual bool
400
401private:
402
403 MemoryManager& m_memoryManager;
404
405 // Not implemented...
407
408 bool
410
412 operator=(const XalanOutputTranscoder& theRHS);
413};
414
415
416
417}
418
419
420
421#endif // XALANTRANSCODINGSERVICES_HEADER_GUARD_1357924680
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
XalanTranscodingServices::size_type size_type
virtual eCode transcode(const XalanDOMChar *theSourceData, size_type theSourceCount, XalanXMLByte *theTarget, size_type theTargetSize, size_type &theSourceCharsTranscoded, size_type &theTargetBytesUsed)=0
Transcode data from UTF-16 to the transcoder's encoding.
virtual eCode transcode(const XalanXMLByte *theSourceData, size_type theSourceCount, XalanDOMChar *theTarget, size_type theTargetSize, size_type &theSourceCharsTranscoded, size_type &theTargetBytesUsed, unsigned char *theCharSizes)=0
Transcode data from the transcoder's encoding to UTF-16.
XalanTranscodingServices::eCode eCode
XalanTranscodingServices::XalanXMLByte XalanXMLByte
virtual bool canTranscodeTo(XalanUnicodeChar theChar) const =0
XalanOutputTranscoder(MemoryManager &theManager)
MakeTranscoderException(eCode theCode, const XalanDOMChar *theEncoding, XalanDOMString &theBuffer, const Locator *theLocator=0)
MakeTranscoderException(const MakeTranscoderException &)
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
virtual const XalanDOMChar * getType() const
Retrieve type of exception.
UnrepresentableCharacterException(const UnrepresentableCharacterException &theSource)
UnrepresentableCharacterException(XalanUnicodeChar theCharacter, const XalanDOMString &theEncoding, XalanDOMString &theBuffer, const Locator *theLocator=0)
static bool encodingIsUTF8(const XalanDOMChar *theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-8.
static bool encodingIsUTF8(const XalanDOMString &theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-8.
static void initialize(MemoryManager &theManager)
Perform static initialization.
static XalanDOMChar getMaximumCharacterValue()
Get the maximum character value for the local code page.
static XalanOutputTranscoder * makeNewTranscoder(MemoryManager &theManager, const XalanDOMChar *theEncodingName, eCode &theResult, size_type theBlockSize)
static bool encodingIsUTF32(const XalanDOMChar *theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-32.
static size_type length(const XalanXMLByte *theBytes)
static void terminate()
Perform static shut down.
static bool encodingIsUTF16(const XalanDOMChar *theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-16.
static bool encodingIsUTF32(const XalanDOMString &theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-32.
static void destroyTranscoder(XalanOutputTranscoder *theTranscoder)
Destroy a transcoder instance.
static XalanOutputTranscoder * makeNewTranscoder(MemoryManager &theManager, const XalanDOMString &theEncodingName, eCode &theResult, size_type theBlockSize)
Create a transcoder instance for the specified encoding.
static bool encodingIsUTF16(const XalanDOMString &theEncodingName)
Determine if the encoding name supplied is equivalent to UTF-16.
static bool getBytesEqualChars(const XalanDOMString &theEncoding)
Determine if the output stage can safely skip transcoding by truncating.
static const XalanXMLByte * getStreamProlog(const XalanDOMString &theEncodingName)
Get an array that contains any leading bytes that should be written to an XML stream for the specifie...
static XalanDOMChar getMaximumCharacterValue(const XalanDOMString &theEncoding)
Get the maximum character value for the encoding.
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)