source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/util/XML256TableTranscoder.hpp @ 2674

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