source: NonGTP/Xerces/xerces/include/xercesc/util/XML256TableTranscoder.hpp @ 358

Revision 358, 6.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: XML256TableTranscoder.hpp,v $
19 * Revision 1.5  2004/09/08 13:56:23  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.4  2003/12/17 00:18:35  cargilld
23 * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
24 *
25 * Revision 1.3  2003/03/07 18:11:55  tng
26 * Return a reference instead of void for operator=
27 *
28 * Revision 1.2  2002/11/04 15:22:05  tng
29 * C++ Namespace Support.
30 *
31 * Revision 1.1.1.1  2002/02/01 22:22:13  peiyongz
32 * sane_include
33 *
34 * Revision 1.1  2000/03/18 00:00:32  roddey
35 * Initial updates for two way transcoding support
36 *
37 */
38
39
40#ifndef XML256TABLETRANSCODER_HPP
41#define XML256TABLETRANSCODER_HPP
42
43#include <xercesc/util/TransService.hpp>
44
45XERCES_CPP_NAMESPACE_BEGIN
46
47//
48//  This class implements the functionality of a common type of transcoder
49//  for an 8 bit, single byte encoding based on a set of 'to' and 'from'
50//  translation tables. Actual derived classes are trivial and just have to
51//  provide us with pointers to their tables and we do all the work.
52//
53class XMLUTIL_EXPORT XML256TableTranscoder : public XMLTranscoder
54{
55public :
56    // -----------------------------------------------------------------------
57    //  Public constructors and destructor
58    // -----------------------------------------------------------------------
59    virtual ~XML256TableTranscoder();
60
61
62    // -----------------------------------------------------------------------
63    //  The virtual transcoding interface
64    // -----------------------------------------------------------------------
65    virtual unsigned int transcodeFrom
66    (
67        const   XMLByte* const          srcData
68        , const unsigned int            srcCount
69        ,       XMLCh* const            toFill
70        , const unsigned int            maxChars
71        ,       unsigned int&           bytesEaten
72        ,       unsigned char* const    charSizes
73    );
74
75    virtual unsigned int transcodeTo
76    (
77        const   XMLCh* const    srcData
78        , const unsigned int    srcCount
79        ,       XMLByte* const  toFill
80        , const unsigned int    maxBytes
81        ,       unsigned int&   charsEaten
82        , const UnRepOpts       options
83    );
84
85    virtual bool canTranscodeTo
86    (
87        const   unsigned int    toCheck
88    )   const;
89
90
91protected :
92    // -----------------------------------------------------------------------
93    //  Hidden constructors
94    // -----------------------------------------------------------------------
95    XML256TableTranscoder
96    (
97        const   XMLCh* const                        encodingName
98        , const unsigned int                        blockSize
99        , const XMLCh* const                        fromTable
100        , const XMLTransService::TransRec* const    toTable
101        , const unsigned int                        toTableSize
102        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
103    );
104
105
106    // -----------------------------------------------------------------------
107    //  Protected helper methods
108    // -----------------------------------------------------------------------
109    XMLByte xlatOneTo
110    (
111        const   XMLCh       toXlat
112    )   const;
113
114
115private :
116    // -----------------------------------------------------------------------
117    //  Unimplemented constructors and operators
118    // -----------------------------------------------------------------------
119    XML256TableTranscoder();
120    XML256TableTranscoder(const XML256TableTranscoder&);
121    XML256TableTranscoder& operator=(const XML256TableTranscoder&);
122
123
124    // -----------------------------------------------------------------------
125    //  Private data members
126    //
127    //  fFromTable
128    //      This is the 'from' table that we were given during construction.
129    //      It is a 256 entry table of XMLCh chars. Each entry is the
130    //      Unicode code point for the external encoding point of that value.
131    //      So fFromTable[N] is the Unicode translation of code point N of
132    //      the source encoding.
133    //
134    //      We don't own this table, we just refer to it. It is assumed that
135    //      the table is static, for performance reasons.
136    //
137    //  fToSize
138    //      The 'to' table is variable sized. This indicates how many records
139    //      are in it.
140    //
141    //  fToTable
142    //      This is a variable sized table of TransRec structures. It must
143    //      be sorted by the intCh field, i.e. the XMLCh field. It is searched
144    //      binarily to find the record for a particular Unicode char. Then
145    //      that record's extch field is the translation record.
146    //
147    //      We don't own this table, we just refer to it. It is assumed that
148    //      the table is static, for performance reasons.
149    //
150    //      NOTE: There may be dups of the extCh field, since there might be
151    //      multiple Unicode code points which map to the same external code
152    //      point. Normally this won't happen, since the parser assumes that
153    //      internalization is normalized, but we have to be prepared to do
154    //      the right thing if some client code gives us non-normalized data
155    //      itself.
156    // -----------------------------------------------------------------------
157    const XMLCh*                        fFromTable;
158    unsigned int                        fToSize;
159    const XMLTransService::TransRec*    fToTable;
160};
161
162XERCES_CPP_NAMESPACE_END
163
164#endif
Note: See TracBrowser for help on using the repository browser.