source: icXML/icXML-devel/src/icxercesc/util/XML256TableTranscoder.hpp @ 2721

Last change on this file since 2721 was 2721, checked in by cameron, 6 years ago

Fix imports in icXML modified Xerces files

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