1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef DIGRAPH_UTILS_H 18 #define DIGRAPH_UTILS_H 19 20 #include "defines.h" 21 22 namespace latinime { 23 24 class DictionaryHeaderStructurePolicy; 25 26 class DigraphUtils { 27 public: 28 typedef enum { 29 NOT_A_DIGRAPH_INDEX, 30 FIRST_DIGRAPH_CODEPOINT, 31 SECOND_DIGRAPH_CODEPOINT 32 } DigraphCodePointIndex; 33 34 typedef enum { 35 DIGRAPH_TYPE_NONE, 36 DIGRAPH_TYPE_GERMAN_UMLAUT, 37 DIGRAPH_TYPE_FRENCH_LIGATURES 38 } DigraphType; 39 40 typedef struct { int first; int second; int compositeGlyph; } digraph_t; 41 42 static bool hasDigraphForCodePoint(const DictionaryHeaderStructurePolicy *const headerPolicy, 43 const int compositeGlyphCodePoint); 44 static int getDigraphCodePointForIndex(const int compositeGlyphCodePoint, 45 const DigraphCodePointIndex digraphCodePointIndex); 46 47 private: 48 DISALLOW_IMPLICIT_CONSTRUCTORS(DigraphUtils); 49 static DigraphType getDigraphTypeForDictionary( 50 const DictionaryHeaderStructurePolicy *const headerPolicy); 51 static int getAllDigraphsForDigraphTypeAndReturnSize( 52 const DigraphType digraphType, const digraph_t **const digraphs); 53 static const digraph_t *getDigraphForCodePoint(const int compositeGlyphCodePoint); 54 static const digraph_t *getDigraphForDigraphTypeAndCodePoint( 55 const DigraphType digraphType, const int compositeGlyphCodePoint); 56 57 static const digraph_t GERMAN_UMLAUT_DIGRAPHS[]; 58 static const digraph_t FRENCH_LIGATURES_DIGRAPHS[]; 59 static const DigraphType USED_DIGRAPH_TYPES[]; 60 }; 61 } // namespace latinime 62 #endif // DIGRAPH_UTILS_H 63