ddc
FormInfo.h
Go to the documentation of this file.
1 // DDC originally by Alexey Sokirko
2 // Changes and modifications 2011-2014 by Bryan Jurish
3 //
4 // This file is part of DDC.
5 //
6 // DDC is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // DDC is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with DDC. If not, see <http://www.gnu.org/licenses/>.
18 //
19 #ifndef _FORM_INFO_H
20 #define _FORM_INFO_H
21 
22 #include "string.h"
23 
24 struct CMorphForm
25 {
26  string m_Gramcode;
27  string m_FlexiaStr;
28  string m_PrefixStr;
29 
30  CMorphForm (string Gramcode, string FlexiaStr, string PrefixStr)
31  {
32  m_Gramcode = Gramcode;
33  m_FlexiaStr = FlexiaStr;
34  m_PrefixStr = PrefixStr;
35  assert (!m_Gramcode.empty());
36  };
37  bool operator == (const CMorphForm& X) const
38  {
39  return m_Gramcode == X.m_Gramcode
40  && m_FlexiaStr == X.m_FlexiaStr
41  && m_PrefixStr == X.m_PrefixStr;
42  };
43 
44 };
45 
46 //----------------------------------------------------------------------------
47 //----------------------------------------------------------------------------
49 {
50  string m_Comments;
51  vector<CMorphForm> m_Flexia;
52 
53  bool operator == (const CFlexiaModel& X) const
54  {
55  return m_Flexia == X.m_Flexia;
56  };
57  bool ReadFromString(string& s);
58  string ToString() const;
59 
60  string get_first_flex() const;
61  string get_first_code() const;
62  bool has_ancode(const string& search_ancode) const;
63 
64 };
65 
66 
67 
68 //----------------------------------------------------------------------------
69 struct CAccentModel
70 {
71  vector<BYTE> m_Accents;
72 
73  bool operator == (const CAccentModel& X) const
74  {
75  return m_Accents == X.m_Accents;
76 
77  };
78  bool ReadFromString(const string& s);
79  string ToString() const;
80 };
81 
82 
83 //----------------------------------------------------------------------------
84 
85 const size_t CommonAncodeSize = 2;
86 const WORD UnknownParadigmNo = 0xffff-1;
87 const WORD UnknownAccentModelNo = 0xffff-1;
88 
89 struct CLemmaInfo
90 {
93  char m_CommonAncode[CommonAncodeSize];
94 
96  {
97  m_FlexiaModelNo = UnknownParadigmNo;
98  m_AccentModelNo = UnknownAccentModelNo;
99  m_CommonAncode[0] = 0;
100  };
101 
102  bool operator ==(const CLemmaInfo& obj) const
103  {
104  return ( (m_FlexiaModelNo == obj.m_FlexiaModelNo)
105  && (m_AccentModelNo == obj.m_AccentModelNo)
106  && !strncmp(m_CommonAncode,obj.m_CommonAncode,CommonAncodeSize)
107  );
108  }
109 
110  bool operator <(const CLemmaInfo& obj) const
111  {
112  if (m_FlexiaModelNo != obj.m_FlexiaModelNo)
113  return m_FlexiaModelNo < obj.m_FlexiaModelNo;
114 
115  int res = strncmp(m_CommonAncode,obj.m_CommonAncode,CommonAncodeSize);
116  if (res != 0)
117  return res < 0;
118 
119  return m_AccentModelNo < obj.m_AccentModelNo;
120  }
121 
122  string GetCommonAncodeIfCan() const
123  {
124  if (m_CommonAncode[0] == 0) return "";
125  return string(m_CommonAncode,2);
126  }
127 
128 };
129 
130 
131 extern void ReadFlexiaModels(FILE* fp, vector<CFlexiaModel>& FlexiaModels );
132 extern void WriteFlexiaModels(FILE* out_fp, const vector<CFlexiaModel>& FlexiaModels );
133 extern void ReadAccentModels (FILE* fp, vector<CAccentModel>& AccentModels );
134 extern void WriteAccentModels(FILE* out_fp, const vector<CAccentModel>& AccentModels );
135 
136 #endif
137 
138 /*--- emacs style variables ---
139  * Local Variables:
140  * mode: C++
141  * c-file-style: "ellemtel"
142  * c-basic-offset: 4
143  * tab-width: 8
144  * indent-tabs-mode: nil
145  * End:
146  */
string m_FlexiaStr
Definition: FormInfo.h:27
void WriteAccentModels(FILE *out_fp, const vector< CAccentModel > &AccentModels)
Definition: wizard.cpp:662
vector< CMorphForm > m_Flexia
Definition: FormInfo.h:51
string m_Comments
Definition: FormInfo.h:50
void WriteFlexiaModels(FILE *out_fp, const vector< CFlexiaModel > &FlexiaModels)
Definition: wizard.cpp:629
const size_t CommonAncodeSize
Definition: FormInfo.h:85
Definition: FormInfo.h:24
const WORD UnknownAccentModelNo
Definition: FormInfo.h:87
char m_CommonAncode[CommonAncodeSize]
Definition: FormInfo.h:93
uint16_t WORD
Definition: utilit.h:106
string GetCommonAncodeIfCan() const
Definition: FormInfo.h:122
CMorphForm(string Gramcode, string FlexiaStr, string PrefixStr)
Definition: FormInfo.h:30
WORD m_FlexiaModelNo
Definition: FormInfo.h:91
const WORD UnknownParadigmNo
Definition: FormInfo.h:86
string m_Gramcode
Definition: FormInfo.h:26
bool operator==(const CMorphForm &X) const
Definition: FormInfo.h:37
Definition: FormInfo.h:48
Definition: FormInfo.h:69
void ReadFlexiaModels(FILE *fp, vector< CFlexiaModel > &FlexiaModels)
Definition: wizard.cpp:604
WORD m_AccentModelNo
Definition: FormInfo.h:92
vector< BYTE > m_Accents
Definition: FormInfo.h:71
string m_PrefixStr
Definition: FormInfo.h:28
CLemmaInfo()
Definition: FormInfo.h:95
void ReadAccentModels(FILE *fp, vector< CAccentModel > &AccentModels)
Definition: wizard.cpp:637
Definition: FormInfo.h:89