Allow libpinyin to build in cross compile mode.
[platform/upstream/libpinyin.git] / src / storage / table_info.h
1 /* 
2  *  libpinyin
3  *  Library to deal with pinyin.
4  *  
5  *  Copyright (C) 2013 Peng Wu <alexepico@gmail.com>
6  *  
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  * 
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *  
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20  */
21
22 #ifndef TABLE_INFO_H
23 #define TABLE_INFO_H
24
25 #include "novel_types.h"
26
27
28 namespace pinyin{
29
30 typedef enum {
31     NOT_USED,                /* not used. */
32     SYSTEM_FILE,             /* system phrase file. */
33     DICTIONARY,              /* professional dictionary. */
34     USER_FILE,               /* user only phrase file. */
35 } PHRASE_FILE_TYPE;
36
37 typedef struct {
38     guint8 m_dict_index; /* for assert purpose. */
39     const gchar * m_table_filename;
40     const gchar * m_system_filename;
41     const gchar * m_user_filename;
42     PHRASE_FILE_TYPE m_file_type;
43 } pinyin_table_info_t;
44
45
46 class UserTableInfo;
47
48 class SystemTableInfo{
49     friend class UserTableInfo;
50 private:
51     int m_binary_format_version;
52     int m_model_data_version;
53     gfloat m_lambda;
54
55     pinyin_table_info_t m_table_info[PHRASE_INDEX_LIBRARY_COUNT];
56
57 private:
58     void reset();
59
60     void postfix_tables();
61
62 public:
63     SystemTableInfo();
64
65     ~SystemTableInfo();
66
67     bool load(const char * filename);
68
69     const pinyin_table_info_t * get_table_info();
70
71     gfloat get_lambda();
72 };
73
74 class UserTableInfo{
75 private:
76     int m_binary_format_version;
77     int m_model_data_version;
78
79 private:
80     void reset();
81
82 public:
83     UserTableInfo();
84
85     bool load(const char * filename);
86
87     bool save(const char * filename);
88
89     bool is_conform(const SystemTableInfo * sysinfo);
90
91     bool make_conform(const SystemTableInfo * sysinfo);
92 };
93
94 };
95
96
97 #endif