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 namespace latinime { 21 22 class DigraphUtils { 23 public: 24 typedef enum { 25 NOT_A_DIGRAPH_INDEX, 26 FIRST_DIGRAPH_CODEPOINT, 27 SECOND_DIGRAPH_CODEPOINT 28 } DigraphCodePointIndex; 29 30 typedef enum { 31 DIGRAPH_TYPE_NONE, 32 DIGRAPH_TYPE_GERMAN_UMLAUT, 33 DIGRAPH_TYPE_FRENCH_LIGATURES 34 } DigraphType; 35 36 typedef struct { int first; int second; int compositeGlyph; } digraph_t; 37 38 static bool hasDigraphForCodePoint(const int dictFlags, const int compositeGlyphCodePoint); 39 static int getAllDigraphsForDictionaryAndReturnSize( 40 const int dictFlags, const digraph_t **const digraphs); 41 static int getDigraphCodePointForIndex(const int dictFlags, const int compositeGlyphCodePoint, 42 const DigraphCodePointIndex digraphCodePointIndex); 43 static int getDigraphCodePointForIndex(const int compositeGlyphCodePoint, 44 const DigraphCodePointIndex digraphCodePointIndex); 45 46 private: 47 DISALLOW_IMPLICIT_CONSTRUCTORS(DigraphUtils); 48 static DigraphType getDigraphTypeForDictionary(const int dictFlags); 49 static int getAllDigraphsForDigraphTypeAndReturnSize( 50 const DigraphType digraphType, const digraph_t **const digraphs); 51 static const digraph_t *getDigraphForCodePoint(const int compositeGlyphCodePoint); 52 static const digraph_t *getDigraphForDigraphTypeAndCodePoint( 53 const DigraphType digraphType, const int compositeGlyphCodePoint); 54 55 static const digraph_t GERMAN_UMLAUT_DIGRAPHS[]; 56 static const digraph_t FRENCH_LIGATURES_DIGRAPHS[]; 57 static const DigraphType USED_DIGRAPH_TYPES[]; 58 }; 59 } // namespace latinime 60 #endif // DIGRAPH_UTILS_H 61