bintools/rcomp/inc/CTABLE.H
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 1997-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 the License "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 * Definitions supporting character set mapping functionality.
       
    16 * Supported conversion is currently only between one of a set of
       
    17 * supported 8-bit character sets and Unicode.
       
    18 * Author:  Pute, January 1997.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 #ifndef __CTABLE_H__
       
    24 #define __CTABLE_H__
       
    25 #include <stdlib.h>
       
    26 #include "wide.h"
       
    27 
       
    28 #if defined(__VC32__)
       
    29 #pragma warning( disable : 4200 ) // nonstandard extension used : zero-sized array in struct/union
       
    30 #endif
       
    31 
       
    32 //
       
    33 // Structures that can be easily initialised from an initialiser list.
       
    34 // These are then used by the mapping classes defined underneath.
       
    35 // An alternative mode of operation would be to initialise the
       
    36 // classes from filed data, which would remove the need for the
       
    37 // structures.
       
    38 //
       
    39 
       
    40 
       
    41 struct S_mapping_range
       
    42     {
       
    43     int first;
       
    44     int last;
       
    45     UTF16 mappings[32];
       
    46     };
       
    47 
       
    48 // Intended to hold a set of contiguous mappings from characters in
       
    49 // the range defined by first and last.
       
    50 
       
    51 
       
    52 
       
    53 
       
    54 
       
    55 class Range
       
    56     {
       
    57 private:
       
    58     int i_first;
       
    59     int i_last;
       
    60     // these define the range.  Arguably this could be a template class,
       
    61     // but the STL needs to be explored for this stuff.
       
    62 
       
    63 public:
       
    64 
       
    65     Range ();
       
    66     Range ( int afirst, int alast );
       
    67     int count() const;                       // how many entries?
       
    68     int part_of( int avalue ) const;         // is avalue part of the range?
       
    69     int first() const;                       // return the first value
       
    70     void define ( int afirst, int alast );   // define new range.
       
    71 
       
    72     };
       
    73 
       
    74 
       
    75 
       
    76 class Mapping_range
       
    77     {
       
    78 private:
       
    79     Range range;
       
    80     UTF16 *mappings;
       
    81 
       
    82 public:
       
    83     Mapping_range();
       
    84     Mapping_range( S_mapping_range *data );
       
    85 
       
    86     int map( unsigned char an8_bit_character, UTF16 &aUnicode_character ) const;
       
    87     //
       
    88     // If the 8-bit character is within range, the Unicode character is set
       
    89     // to its mapping, otherwise the Unicode character is unmodified.
       
    90     // The return value is true or false to indicate whether or not a
       
    91     // mapping took place.
       
    92 
       
    93     };
       
    94 
       
    95 
       
    96 // Need to supply an escape mechanism for Unicode characters enbedded in CP1252 strings
       
    97 const unsigned char UnicodeEscape = 0x81;	// indicates embedded UTF8 encoding of Unicode character
       
    98 
       
    99 
       
   100 #endif // CTABLE_H not defined
       
   101 // end of CTABLE.H
       
   102