summaryrefslogtreecommitdiffstats
path: root/src/storage/table_info.h
blob: 8d7fa0506edaa06492436fd20ca23a4226051382 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* 
 *  libpinyin
 *  Library to deal with pinyin.
 *  
 *  Copyright (C) 2013 Peng Wu <alexepico@gmail.com>
 *  
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef TABLE_INFO_H
#define TABLE_INFO_H

#include "novel_types.h"


namespace pinyin{

typedef enum {
    NOT_USED,                /* not used. */
    SYSTEM_FILE,             /* system phrase file. */
    DICTIONARY,              /* professional dictionary. */
    USER_FILE,               /* user only phrase file. */
} PHRASE_FILE_TYPE;

typedef struct {
    guint8 m_dict_index; /* for assert purpose. */
    const gchar * m_table_filename;
    const gchar * m_system_filename;
    const gchar * m_user_filename;
    PHRASE_FILE_TYPE m_file_type;
} pinyin_table_info_t;


class UserTableInfo;

class SystemTableInfo{
    friend class UserTableInfo;
private:
    int m_binary_format_version;
    int m_model_data_version;
    gfloat m_lambda;

    pinyin_table_info_t m_table_info[PHRASE_INDEX_LIBRARY_COUNT];

private:
    void reset();

    void postfix_tables();

public:
    SystemTableInfo();

    ~SystemTableInfo();

    bool load(const char * filename);

    const pinyin_table_info_t * get_table_info();

    gfloat get_lambda();
};

class UserTableInfo{
private:
    int m_binary_format_version;
    int m_model_data_version;

private:
    void reset();

public:
    UserTableInfo();

    bool load(const char * filename);

    bool save(const char * filename);

    bool is_conform(const SystemTableInfo * sysinfo);

    bool make_conform(const SystemTableInfo * sysinfo);
};

};


#endif