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: XML256TableTranscoder390.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef XML256TABLETRANSCODER390_HPP |
---|
23 | #define XML256TABLETRANSCODER390_HPP |
---|
24 | |
---|
25 | #include <xercesc/util/TransService.hpp> |
---|
26 | |
---|
27 | XERCES_CPP_NAMESPACE_BEGIN |
---|
28 | |
---|
29 | // |
---|
30 | // This class implements the functionality of a common type of transcoder |
---|
31 | // for an 8 bit, single byte encoding based on a set of 'to' and 'from' |
---|
32 | // translation tables. Actual derived classes are trivial and just have to |
---|
33 | // provide us with pointers to their tables and we do all the work. |
---|
34 | // |
---|
35 | class XMLUTIL_EXPORT XML256TableTranscoder390 : public XMLTranscoder |
---|
36 | { |
---|
37 | public : |
---|
38 | // ----------------------------------------------------------------------- |
---|
39 | // Public constructors and destructor |
---|
40 | // ----------------------------------------------------------------------- |
---|
41 | virtual ~XML256TableTranscoder390(); |
---|
42 | |
---|
43 | |
---|
44 | // ----------------------------------------------------------------------- |
---|
45 | // The virtual transcoding interface |
---|
46 | // ----------------------------------------------------------------------- |
---|
47 | virtual unsigned int transcodeFrom |
---|
48 | ( |
---|
49 | const XMLByte* const srcData |
---|
50 | , const unsigned int srcCount |
---|
51 | , XMLCh* const toFill |
---|
52 | , const unsigned int maxChars |
---|
53 | , unsigned int& bytesEaten |
---|
54 | , unsigned char* const charSizes |
---|
55 | ); |
---|
56 | |
---|
57 | virtual unsigned int transcodeTo |
---|
58 | ( |
---|
59 | const XMLCh* const srcData |
---|
60 | , const unsigned int srcCount |
---|
61 | , XMLByte* const toFill |
---|
62 | , const unsigned int maxBytes |
---|
63 | , unsigned int& charsEaten |
---|
64 | , const UnRepOpts options |
---|
65 | ); |
---|
66 | |
---|
67 | virtual bool canTranscodeTo |
---|
68 | ( |
---|
69 | const unsigned int toCheck |
---|
70 | ) const; |
---|
71 | |
---|
72 | |
---|
73 | protected : |
---|
74 | // ----------------------------------------------------------------------- |
---|
75 | // Hidden constructors |
---|
76 | // ----------------------------------------------------------------------- |
---|
77 | XML256TableTranscoder390 |
---|
78 | ( |
---|
79 | const XMLCh* const encodingName |
---|
80 | , const unsigned int blockSize |
---|
81 | , const XMLCh* const fromTable |
---|
82 | , const XMLTransService::TransRec* const toTable |
---|
83 | , const unsigned int toTableSize |
---|
84 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
85 | ); |
---|
86 | |
---|
87 | |
---|
88 | // ----------------------------------------------------------------------- |
---|
89 | // Protected helper methods |
---|
90 | // ----------------------------------------------------------------------- |
---|
91 | XMLByte xlatOneTo |
---|
92 | ( |
---|
93 | const XMLCh toXlat |
---|
94 | ) const; |
---|
95 | |
---|
96 | |
---|
97 | private : |
---|
98 | // ----------------------------------------------------------------------- |
---|
99 | // Unimplemented constructors and operators |
---|
100 | // ----------------------------------------------------------------------- |
---|
101 | XML256TableTranscoder390(); |
---|
102 | XML256TableTranscoder390(const XML256TableTranscoder390&); |
---|
103 | XML256TableTranscoder390& operator=(const XML256TableTranscoder390&); |
---|
104 | |
---|
105 | |
---|
106 | // ----------------------------------------------------------------------- |
---|
107 | // Private data members |
---|
108 | // |
---|
109 | // fFromTable |
---|
110 | // This is the 'from' table that we were given during construction. |
---|
111 | // It is a 256 entry table of XMLCh chars. Each entry is the |
---|
112 | // Unicode code point for the external encoding point of that value. |
---|
113 | // So fFromTable[N] is the Unicode translation of code point N of |
---|
114 | // the source encoding. |
---|
115 | // |
---|
116 | // We don't own this table, we just refer to it. It is assumed that |
---|
117 | // the table is static, for performance reasons. |
---|
118 | // |
---|
119 | // fToSize |
---|
120 | // The 'to' table is variable sized. This indicates how many records |
---|
121 | // are in it. |
---|
122 | // |
---|
123 | // fToTable |
---|
124 | // This is a variable sized table of TransRec structures. It must |
---|
125 | // be sorted by the intCh field, i.e. the XMLCh field. It is searched |
---|
126 | // binarily to find the record for a particular Unicode char. Then |
---|
127 | // that record's extch field is the translation record. |
---|
128 | // |
---|
129 | // We don't own this table, we just refer to it. It is assumed that |
---|
130 | // the table is static, for performance reasons. |
---|
131 | // |
---|
132 | // NOTE: There may be dups of the extCh field, since there might be |
---|
133 | // multiple Unicode code points which map to the same external code |
---|
134 | // point. Normally this won't happen, since the parser assumes that |
---|
135 | // internalization is normalized, but we have to be prepared to do |
---|
136 | // the right thing if some client code gives us non-normalized data |
---|
137 | // itself. |
---|
138 | // ----------------------------------------------------------------------- |
---|
139 | const XMLCh* fFromTable; |
---|
140 | unsigned int fToSize; |
---|
141 | const XMLTransService::TransRec* fToTable; |
---|
142 | }; |
---|
143 | |
---|
144 | XERCES_CPP_NAMESPACE_END |
---|
145 | |
---|
146 | #endif |
---|