2 Copyright 2013 Karel Matas
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef __DATATYPES_HXX
18 #define __DATATYPES_HXX
31 SKIP ( const vector
<int> &v
, const char *m
)
32 :s1(v
[0]),s2(v
[1]),s3(v
[2]),misclass(m
){};
33 SKIP ( const string
&ss1
, const string
&ss2
, const string
&ss3
, const string
&m
)
34 :s1(std::stoi(ss1
)),s2(std::stoi(ss2
)),s3(std::stoi(ss3
)),misclass(m
){};
45 vector
<string
> onyomi_
;
46 vector
<string
> kunyomi_
;
47 // NOTE: flags: std::vector is needed, no std::set (sorting)
48 vector
<string
> flags_
; // jis
51 vector
<string
> nanori_
;
52 vector
<string
> meaning_
;
60 Kanji (): kanji_("") {};
61 Kanji ( const string
&kanji
) : kanji_(kanji
) {};
64 inline void kanji ( const string
&s
) { kanji_
= s
;}
65 inline void ucs ( const string
&s
) { ucs_
= s
; };
66 inline void onyomi ( const string
&s
) { onyomi_
.push_back(s
); };
67 inline void onyomi ( const vector
<string
> &v
) { onyomi_
=v
; };
68 inline void kunyomi ( const string
&s
) { kunyomi_
.push_back(s
); };
69 inline void kunyomi ( const vector
<string
> &v
) { kunyomi_
=v
; };
70 inline void flags ( const string
&s
) { flags_
.push_back(s
); };
71 inline void flags ( const vector
<string
> &v
) { flags_
=v
; };
72 inline void strokes ( const char *s
) { strokes_
= atoi(s
); };
73 inline void strokes ( int i
) { strokes_
= i
; };
74 inline void freq ( const char *s
) { freq_
= atoi(s
); };
75 inline void freq ( int i
) { freq_
= i
; };
76 inline void meaning ( const string
&s
) { meaning_
.push_back(s
); };
77 inline void meaning ( const vector
<string
> &v
) { meaning_
= v
; };
78 inline void nanori ( const string
&s
) { nanori_
.push_back(s
); };
79 inline void nanori ( const vector
<string
> &v
) { nanori_
= v
; };
80 inline void rad_classic ( const char *s
) { rad_classic_
= atoi(s
); };
81 inline void rad_classic ( int i
) { rad_classic_
= i
; };
82 inline void rad_nelson ( const char *s
) { rad_nelson_
= atoi(s
); };
83 inline void rad_nelson ( int i
) { rad_nelson_
= i
; };
84 inline void skip ( const string
&s1
, const string
&s2
, const string
&s3
,
85 const string
&m
="" ) {
86 skip_
.push_back( SKIP( s1
, s2
, s3
, m
) );
88 inline void skip ( const vector
<int> &v
, const char *misclass
=0 ) {
89 skip_
.push_back( SKIP( v
, misclass
? misclass
:"" ) );
91 inline void components ( const string
&s
) { components_
=s
; };
92 inline void jlpt ( int i
) { jlpt_
=i
; };
93 inline void grade ( int i
) { grade_
=i
; };
96 inline string
kanji () const { return kanji_
; };
97 inline string
ucs () const { return ucs_
; };
98 inline vector
<string
> onyomi () const { return onyomi_
; };
99 inline vector
<string
> kunyomi () const { return kunyomi_
; };
100 inline vector
<string
> flags () const { return flags_
; };
101 inline vector
<string
> meaning () const { return meaning_
; };
102 inline vector
<string
> nanori () const { return nanori_
; };
103 inline int freq () const { return freq_
; };
104 inline int strokes () const { return strokes_
; };
105 inline int rad_classic () const { return rad_classic_
; };
106 inline int rad_nelson () const { return rad_nelson_
; };
107 inline int jlpt () const { return jlpt_
; };
108 inline int grade () const { return grade_
; };
109 inline vector
<SKIP
> skip () const { return skip_
; };
110 inline string
components () const { return components_
;};
112 inline string
str_onyomi () const { return utils::to_string(onyomi_
,", "); };
113 inline string
str_kunyomi () const { return utils::to_string(kunyomi_
,", "); };
114 inline string
str_nanori () const { return utils::to_string(nanori_
,", "); };
115 inline string
str_meaning () const { return utils::to_string(meaning_
,", "); };
116 inline string
str_flags () const { return utils::to_string(flags_
,", "); };
117 inline string
str_radicals () const {
118 if (rad_classic_
&& rad_nelson_
){
119 std::stringstream ss
;
120 ss
<< rad_classic_
<< " (" << rad_nelson_
<< ")";
124 return std::to_string(rad_classic_
);
130 #endif // __DATATYPES_HXX