secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/util/XML256TableTranscoder.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: XML256TableTranscoder.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 
       
    39 #ifndef XML256TABLETRANSCODER_HPP
       
    40 #define XML256TABLETRANSCODER_HPP
       
    41 
       
    42 #include <xercesc/util/TransService.hpp>
       
    43 
       
    44 XERCES_CPP_NAMESPACE_BEGIN
       
    45 
       
    46 //
       
    47 //  This class implements the functionality of a common type of transcoder
       
    48 //  for an 8 bit, single byte encoding based on a set of 'to' and 'from'
       
    49 //  translation tables. Actual derived classes are trivial and just have to
       
    50 //  provide us with pointers to their tables and we do all the work.
       
    51 //
       
    52 class XMLUTIL_EXPORT XML256TableTranscoder : public XMLTranscoder
       
    53 {
       
    54 public :
       
    55     // -----------------------------------------------------------------------
       
    56     //  Public constructors and destructor
       
    57     // -----------------------------------------------------------------------
       
    58     virtual ~XML256TableTranscoder();
       
    59 
       
    60 
       
    61     // -----------------------------------------------------------------------
       
    62     //  The virtual transcoding interface
       
    63     // -----------------------------------------------------------------------
       
    64     virtual unsigned int transcodeFrom
       
    65     (
       
    66         const   XMLByte* const          srcData
       
    67         , const unsigned int            srcCount
       
    68         ,       XMLCh* const            toFill
       
    69         , const unsigned int            maxChars
       
    70         ,       unsigned int&           bytesEaten
       
    71         ,       unsigned char* const    charSizes
       
    72     );
       
    73 
       
    74     virtual unsigned int transcodeTo
       
    75     (
       
    76         const   XMLCh* const    srcData
       
    77         , const unsigned int    srcCount
       
    78         ,       XMLByte* const  toFill
       
    79         , const unsigned int    maxBytes
       
    80         ,       unsigned int&   charsEaten
       
    81         , const UnRepOpts       options
       
    82     );
       
    83 
       
    84     virtual bool canTranscodeTo
       
    85     (
       
    86         const   unsigned int    toCheck
       
    87     )   const;
       
    88 
       
    89 
       
    90 protected :
       
    91     // -----------------------------------------------------------------------
       
    92     //  Hidden constructors
       
    93     // -----------------------------------------------------------------------
       
    94     XML256TableTranscoder
       
    95     (
       
    96         const   XMLCh* const                        encodingName
       
    97         , const unsigned int                        blockSize
       
    98         , const XMLCh* const                        fromTable
       
    99         , const XMLTransService::TransRec* const    toTable
       
   100         , const unsigned int                        toTableSize
       
   101         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
       
   102     );
       
   103 
       
   104 
       
   105     // -----------------------------------------------------------------------
       
   106     //  Protected helper methods
       
   107     // -----------------------------------------------------------------------
       
   108     XMLByte xlatOneTo
       
   109     (
       
   110         const   XMLCh       toXlat
       
   111     )   const;
       
   112 
       
   113 
       
   114 private :
       
   115     // -----------------------------------------------------------------------
       
   116     //  Unimplemented constructors and operators
       
   117     // -----------------------------------------------------------------------
       
   118     XML256TableTranscoder();
       
   119     XML256TableTranscoder(const XML256TableTranscoder&);
       
   120     XML256TableTranscoder& operator=(const XML256TableTranscoder&);
       
   121 
       
   122 
       
   123     // -----------------------------------------------------------------------
       
   124     //  Private data members
       
   125     //
       
   126     //  fFromTable
       
   127     //      This is the 'from' table that we were given during construction.
       
   128     //      It is a 256 entry table of XMLCh chars. Each entry is the
       
   129     //      Unicode code point for the external encoding point of that value.
       
   130     //      So fFromTable[N] is the Unicode translation of code point N of
       
   131     //      the source encoding.
       
   132     //
       
   133     //      We don't own this table, we just refer to it. It is assumed that
       
   134     //      the table is static, for performance reasons.
       
   135     //
       
   136     //  fToSize
       
   137     //      The 'to' table is variable sized. This indicates how many records
       
   138     //      are in it.
       
   139     //
       
   140     //  fToTable
       
   141     //      This is a variable sized table of TransRec structures. It must
       
   142     //      be sorted by the intCh field, i.e. the XMLCh field. It is searched
       
   143     //      binarily to find the record for a particular Unicode char. Then
       
   144     //      that record's extch field is the translation record.
       
   145     //
       
   146     //      We don't own this table, we just refer to it. It is assumed that
       
   147     //      the table is static, for performance reasons.
       
   148     //
       
   149     //      NOTE: There may be dups of the extCh field, since there might be
       
   150     //      multiple Unicode code points which map to the same external code
       
   151     //      point. Normally this won't happen, since the parser assumes that
       
   152     //      internalization is normalized, but we have to be prepared to do
       
   153     //      the right thing if some client code gives us non-normalized data
       
   154     //      itself.
       
   155     // -----------------------------------------------------------------------
       
   156     const XMLCh*                        fFromTable;
       
   157     unsigned int                        fToSize;
       
   158     const XMLTransService::TransRec*    fToTable;
       
   159 };
       
   160 
       
   161 XERCES_CPP_NAMESPACE_END
       
   162 
       
   163 #endif