source: NonGTP/Xerces/xercesc/util/XML256TableTranscoder.hpp @ 188

Revision 188, 8.1 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 1999, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57/*
58 * $Log: XML256TableTranscoder.hpp,v $
59 * Revision 1.4  2003/12/17 00:18:35  cargilld
60 * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
61 *
62 * Revision 1.3  2003/03/07 18:11:55  tng
63 * Return a reference instead of void for operator=
64 *
65 * Revision 1.2  2002/11/04 15:22:05  tng
66 * C++ Namespace Support.
67 *
68 * Revision 1.1.1.1  2002/02/01 22:22:13  peiyongz
69 * sane_include
70 *
71 * Revision 1.1  2000/03/18 00:00:32  roddey
72 * Initial updates for two way transcoding support
73 *
74 */
75
76
77#ifndef XML256TABLETRANSCODER_HPP
78#define XML256TABLETRANSCODER_HPP
79
80#include <xercesc/util/TransService.hpp>
81
82XERCES_CPP_NAMESPACE_BEGIN
83
84//
85//  This class implements the functionality of a common type of transcoder
86//  for an 8 bit, single byte encoding based on a set of 'to' and 'from'
87//  translation tables. Actual derived classes are trivial and just have to
88//  provide us with pointers to their tables and we do all the work.
89//
90class XMLUTIL_EXPORT XML256TableTranscoder : public XMLTranscoder
91{
92public :
93    // -----------------------------------------------------------------------
94    //  Public constructors and destructor
95    // -----------------------------------------------------------------------
96    virtual ~XML256TableTranscoder();
97
98
99    // -----------------------------------------------------------------------
100    //  The virtual transcoding interface
101    // -----------------------------------------------------------------------
102    virtual unsigned int transcodeFrom
103    (
104        const   XMLByte* const          srcData
105        , const unsigned int            srcCount
106        ,       XMLCh* const            toFill
107        , const unsigned int            maxChars
108        ,       unsigned int&           bytesEaten
109        ,       unsigned char* const    charSizes
110    );
111
112    virtual unsigned int transcodeTo
113    (
114        const   XMLCh* const    srcData
115        , const unsigned int    srcCount
116        ,       XMLByte* const  toFill
117        , const unsigned int    maxBytes
118        ,       unsigned int&   charsEaten
119        , const UnRepOpts       options
120    );
121
122    virtual bool canTranscodeTo
123    (
124        const   unsigned int    toCheck
125    )   const;
126
127
128protected :
129    // -----------------------------------------------------------------------
130    //  Hidden constructors
131    // -----------------------------------------------------------------------
132    XML256TableTranscoder
133    (
134        const   XMLCh* const                        encodingName
135        , const unsigned int                        blockSize
136        , const XMLCh* const                        fromTable
137        , const XMLTransService::TransRec* const    toTable
138        , const unsigned int                        toTableSize
139        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
140    );
141
142
143    // -----------------------------------------------------------------------
144    //  Protected helper methods
145    // -----------------------------------------------------------------------
146    XMLByte xlatOneTo
147    (
148        const   XMLCh       toXlat
149    )   const;
150
151
152private :
153    // -----------------------------------------------------------------------
154    //  Unimplemented constructors and operators
155    // -----------------------------------------------------------------------
156    XML256TableTranscoder();
157    XML256TableTranscoder(const XML256TableTranscoder&);
158    XML256TableTranscoder& operator=(const XML256TableTranscoder&);
159
160
161    // -----------------------------------------------------------------------
162    //  Private data members
163    //
164    //  fFromTable
165    //      This is the 'from' table that we were given during construction.
166    //      It is a 256 entry table of XMLCh chars. Each entry is the
167    //      Unicode code point for the external encoding point of that value.
168    //      So fFromTable[N] is the Unicode translation of code point N of
169    //      the source encoding.
170    //
171    //      We don't own this table, we just refer to it. It is assumed that
172    //      the table is static, for performance reasons.
173    //
174    //  fToSize
175    //      The 'to' table is variable sized. This indicates how many records
176    //      are in it.
177    //
178    //  fToTable
179    //      This is a variable sized table of TransRec structures. It must
180    //      be sorted by the intCh field, i.e. the XMLCh field. It is searched
181    //      binarily to find the record for a particular Unicode char. Then
182    //      that record's extch field is the translation record.
183    //
184    //      We don't own this table, we just refer to it. It is assumed that
185    //      the table is static, for performance reasons.
186    //
187    //      NOTE: There may be dups of the extCh field, since there might be
188    //      multiple Unicode code points which map to the same external code
189    //      point. Normally this won't happen, since the parser assumes that
190    //      internalization is normalized, but we have to be prepared to do
191    //      the right thing if some client code gives us non-normalized data
192    //      itself.
193    // -----------------------------------------------------------------------
194    const XMLCh*                        fFromTable;
195    unsigned int                        fToSize;
196    const XMLTransService::TransRec*    fToTable;
197};
198
199XERCES_CPP_NAMESPACE_END
200
201#endif
Note: See TracBrowser for help on using the repository browser.