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 | #ifndef XMLUTF16TRANSCODER_HPP |
---|
19 | #define XMLUTF16TRANSCODER_HPP |
---|
20 | |
---|
21 | #include <xercesc/util/XercesDefs.hpp> |
---|
22 | #include <xercesc/util/TransService.hpp> |
---|
23 | |
---|
24 | XERCES_CPP_NAMESPACE_BEGIN |
---|
25 | |
---|
26 | |
---|
27 | // |
---|
28 | // This class provides an implementation of the XMLTranscoder interface |
---|
29 | // for a simple UTF16 transcoder. The parser does some encodings |
---|
30 | // intrinsically without depending upon external transcoding services. |
---|
31 | // To make everything more orthagonal, we implement these internal |
---|
32 | // transcoders using the same transcoder abstraction as the pluggable |
---|
33 | // transcoding services do. |
---|
34 | // |
---|
35 | class XMLUTIL_EXPORT XMLUTF16Transcoder : public XMLTranscoder |
---|
36 | { |
---|
37 | public : |
---|
38 | // ----------------------------------------------------------------------- |
---|
39 | // Public constructors and destructor |
---|
40 | // ----------------------------------------------------------------------- |
---|
41 | XMLUTF16Transcoder |
---|
42 | ( |
---|
43 | const XMLCh* const encodingName |
---|
44 | , const unsigned int blockSize |
---|
45 | , const bool swapped |
---|
46 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
47 | ); |
---|
48 | |
---|
49 | virtual ~XMLUTF16Transcoder(); |
---|
50 | |
---|
51 | |
---|
52 | // ----------------------------------------------------------------------- |
---|
53 | // Implementation of the XMLTranscoder interface |
---|
54 | // ----------------------------------------------------------------------- |
---|
55 | virtual unsigned int transcodeFrom |
---|
56 | ( |
---|
57 | const XMLByte* const srcData |
---|
58 | , const unsigned int srcCount |
---|
59 | , XMLCh* const toFill |
---|
60 | , const unsigned int maxChars |
---|
61 | , unsigned int& bytesEaten |
---|
62 | , unsigned char* const charSizes |
---|
63 | ); |
---|
64 | |
---|
65 | virtual unsigned int transcodeTo |
---|
66 | ( |
---|
67 | const XMLCh* const srcData |
---|
68 | , const unsigned int srcCount |
---|
69 | , XMLByte* const toFill |
---|
70 | , const unsigned int maxBytes |
---|
71 | , unsigned int& charsEaten |
---|
72 | , const UnRepOpts options |
---|
73 | ); |
---|
74 | |
---|
75 | virtual bool canTranscodeTo |
---|
76 | ( |
---|
77 | const unsigned int toCheck |
---|
78 | ) const; |
---|
79 | |
---|
80 | |
---|
81 | private : |
---|
82 | // ----------------------------------------------------------------------- |
---|
83 | // Unimplemented constructors and operators |
---|
84 | // ----------------------------------------------------------------------- |
---|
85 | XMLUTF16Transcoder(const XMLUTF16Transcoder&); |
---|
86 | XMLUTF16Transcoder& operator=(const XMLUTF16Transcoder&); |
---|
87 | |
---|
88 | |
---|
89 | // ----------------------------------------------------------------------- |
---|
90 | // Private data members |
---|
91 | // |
---|
92 | // fSwapped |
---|
93 | // Indicates whether the encoding is of the opposite endianness from |
---|
94 | // the local host. |
---|
95 | // ----------------------------------------------------------------------- |
---|
96 | bool fSwapped; |
---|
97 | }; |
---|
98 | |
---|
99 | XERCES_CPP_NAMESPACE_END |
---|
100 | |
---|
101 | #endif |
---|