1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX 24 #define INCLUDED_I18NUTIL_TRANSLITERATION_ONETOONEMAPPING_HXX 25 26 #include <utility> 27 #include <rtl/ustring.hxx> 28 #include "i18nutil/i18nutildllapi.h" 29 30 namespace com { namespace sun { namespace star { namespace i18n { 31 32 class widthfolding; 33 34 typedef std::pair< sal_Unicode, sal_Unicode > OneToOneMappingTable_t; 35 36 #define MAKE_PAIR(item1,item2) std::make_pair< sal_Unicode, sal_Unicode >((sal_Unicode)item1,(sal_Unicode)item2) 37 38 typedef sal_Int8 UnicodePairFlag; 39 typedef struct _UnicodePairWithFlag 40 { 41 sal_Unicode first; 42 sal_Unicode second; 43 UnicodePairFlag flag; 44 } UnicodePairWithFlag; 45 46 class I18NUTIL_DLLPUBLIC oneToOneMapping 47 { 48 private: 49 // no copy, no substitution 50 oneToOneMapping( const oneToOneMapping& ); 51 oneToOneMapping& operator=( const oneToOneMapping& ); 52 public: 53 oneToOneMapping( OneToOneMappingTable_t *rpTable, const size_t rnSize, const size_t rnUnitSize = sizeof(OneToOneMappingTable_t) ); 54 virtual ~oneToOneMapping(); 55 56 // make index for fast search 57 // bluedawrf: not used 58 // void makeIndex(); 59 60 // binary search 61 virtual sal_Unicode find( const sal_Unicode nKey ) const; 62 63 // translator operator [](const sal_Unicode nKey) const64 sal_Unicode operator[] ( const sal_Unicode nKey ) const { return find( nKey ); }; 65 66 protected: 67 OneToOneMappingTable_t *mpTable; 68 size_t mnSize; 69 }; 70 71 class I18NUTIL_DLLPUBLIC oneToOneMappingWithFlag : public oneToOneMapping 72 { 73 friend class widthfolding; 74 75 private: 76 // no copy, no substitution 77 oneToOneMappingWithFlag( const oneToOneMappingWithFlag& ); 78 oneToOneMappingWithFlag& operator=( const oneToOneMappingWithFlag& ); 79 public: 80 oneToOneMappingWithFlag( UnicodePairWithFlag *rpTableWF, const size_t rnSize, const UnicodePairFlag rnFlag ); 81 virtual ~oneToOneMappingWithFlag(); 82 83 // make index for fast search 84 void makeIndex(); 85 86 // index search 87 virtual sal_Unicode find( const sal_Unicode nKey ) const; 88 protected: 89 UnicodePairWithFlag *mpTableWF; 90 UnicodePairFlag mnFlag; 91 UnicodePairWithFlag **mpIndex[256]; 92 sal_Bool mbHasIndex; 93 }; 94 95 } } } } 96 97 #endif // _I18N_TRANSLITERATION_ONETOONEMAPPING_HXX_ 98