Allow to lookup Italian verbs and show pronouns.
[mverbiste] / gui / conjugation.h
1 /*  $Id: conjugation.h,v 1.12 2011/01/08 19:07:36 sarrazip Exp $
2     conjugation.h - Generic conjugation interface
3
4     verbiste - French conjugation system
5     Copyright (C) 2003-2006 Pierre Sarrazin <http://sarrazip.com/>
6
7     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (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., 59 Temple Place - Suite 330, Boston, MA
20     02111-1307, USA.
21 */
22
23 #ifndef _H_conjugation
24 #define _H_conjugation
25
26 #include <verbiste/FrenchVerbDictionary.h>
27
28 #include <vector>
29 #include <string>
30 #include <QtCore/QVector>
31 #include <QtCore/QString>
32
33 typedef std::vector<std::string> VS;
34 typedef std::vector<VS> VVS;
35 typedef std::vector<VVS> VVVS;
36
37 #ifndef QT_NO_DEBUG
38 #include <QtCore/QElapsedTimer>
39 #include <QtCore/QDebug>
40 #endif
41
42 /** Obtains the conjugation of the given infinitive.
43     @param  fvd             verb dictionary from which to obtain
44                             the conjugation
45     @param  infinitive      UTF-8 string containing the infinitive form
46                             of the verb to conjugate (e.g., "manger")
47     @param  tname           conjugation template name to use (e.g., "aim:er")
48     @param  dest            structure into which the conjugated is written
49     @param  includePronouns put pronouns before conjugated verbs in the
50                             modes where pronouns are used
51 */
52 void getConjugation(const verbiste::FrenchVerbDictionary &fvd,
53                         const std::string &infinitive,
54                         const std::string &tname,
55                         VVVS &dest,
56                     #ifndef QT_NO_DEBUG
57                         QElapsedTimer &timer,
58                     #endif
59                         bool includePronouns = false);
60
61
62 /** Get the tense name for a certain cell of the conjugation table.
63     The conjugation table is a 4x4 grid and 11 of the 16 cells are
64     used by the tenses to be displayed.
65     @param      row             row number (0..3)
66     @param      col             column number (0..3)
67     @param      isItalian       language used (true for Italian, false for French)
68     @returns            an internationalized (and possibly abbreviated) name
69                         (in UTF-8) for the tense that goes in the cell
70                         designated by row and col;
71                         the returned string is empty if no tense (in the
72                         language used) goes in the designated cell
73 */
74 std::string getTenseNameForTableCell(int row, int col, bool isItalian);
75
76
77 /** Composes the text of the conjugation in a certain tense.
78     The words of this conjugation that match a certain user text
79     are marked specially.
80
81     @param        tense                 structure that represents a certain
82                                         tense of a certain verb
83     @param        lowerCaseUTF8UserText conjugated verb as entered by the
84                                         user, but converted to lower-case,
85                                         and assumed to be in UTF-8
86     @param        openMark              ASCII string to be used before verbs
87                                         that match lowerCaseUTF8UserText
88                                         (e.g., "<b>")
89     @param        closeMark             ASCII string to be used after verbs
90                                         that match lowerCaseUTF8UserText
91                                         (e.g., "</b>")
92     @returns                            a UTF-8 string containing several
93                                         lines of text, each line being
94                                         separated by a newline ('\n')
95                                         character; the string does not end
96                                         the last line with a newline however;
97                                         e.g., "aie\nayons\nayez"
98 */
99 std::string createTableCellText(verbiste::FrenchVerbDictionary &fvd,
100                                 const VVS &tense,
101                                 const std::string &lowerCaseUTF8UserText,
102                                 const std::string &openMark,
103                                 const std::string &closeMark);
104
105 /**
106  * Qt version of createTableCellText() above.
107  * Return a vertor of QStrings, which are conjugations.
108  **/
109 QVector<QString> qgetConjugates(verbiste::FrenchVerbDictionary &fvd,
110                                 const VVS &tense,
111                                 const std::string &lowerCaseUTF8UserText,
112                                 const std::string &openMark,
113                                 const std::string &closeMark);
114 #endif  /* _H_conjugation */