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 } DigraphType; 38 39 typedef struct { int first; int second; int compositeGlyph; } digraph_t; 40 41 static bool hasDigraphForCodePoint(const DictionaryHeaderStructurePolicy *const headerPolicy, 42 const int compositeGlyphCodePoint); 43 static int getDigraphCodePointForIndex(const int compositeGlyphCodePoint, 44 const DigraphCodePointIndex digraphCodePointIndex); 45 46 private: 47 DISALLOW_IMPLICIT_CONSTRUCTORS(DigraphUtils); 48 static DigraphType getDigraphTypeForDictionary( 49 const DictionaryHeaderStructurePolicy *const headerPolicy); 50 static int getAllDigraphsForDigraphTypeAndReturnSize( 51 const DigraphType digraphType, const digraph_t **const digraphs); 52 static const digraph_t *getDigraphForCodePoint(const int compositeGlyphCodePoint); 53 static const digraph_t *getDigraphForDigraphTypeAndCodePoint( 54 const DigraphType digraphType, const int compositeGlyphCodePoint); 55 56 static const digraph_t GERMAN_UMLAUT_DIGRAPHS[]; 57 static const DigraphType USED_DIGRAPH_TYPES[]; 58 }; 59 } // namespace latinime 60 #endif // DIGRAPH_UTILS_H 61