summaryrefslogtreecommitdiffstats
path: root/kanagram/src/keduvockvtmlreader.h
blob: acd2978288d34121f723e6037e0b2e17930c0abc (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
                     read a KEduVocDocument from a KVTML file
    -----------------------------------------------------------------------
    copyright            : (C) 1999-2001 Ewald Arnold
                           (C) 2001 The KDE-EDU team
						               (C) 2005 Eric Pignet
    email                : eric at erixpage.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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KEDUVOCKVTMLREADER_H
#define KEDUVOCKVTMLREADER_H

#include <tqfile.h>
#include <tqdom.h>

#include "keduvocdocument.h"
#include "grammarmanager.h"
#include "multiplechoice.h"

class KEduVocDocument;

// internal types, indented are subtypes

#define TQM_VERB           "v"    // go
#define   TQM_VERB_IRR     "ir"
#define   TQM_VERB_REG     "re"
#define TQM_NOUN           "n"    // table, coffee
#define   TQM_NOUN_F       "f"
#define   TQM_NOUN_M       "m"
#define   TQM_NOUN_S       "s"
#define TQM_NAME           "nm"
#define TQM_ART            "ar"   // article
#define   TQM_ART_DEF      "def"  // definite    a/an
#define   TQM_ART_IND      "ind"  // indefinite  the
#define TQM_ADJ            "aj"   // adjective   expensive, good
#define TQM_ADV            "av"   // adverb      today, strongly
#define TQM_PRON           "pr"   // pronoun     you, she
#define   TQM_PRON_POS     "pos"  // possessive  my, your
#define   TQM_PRON_PER     "per"  // personal
#define TQM_PHRASE         "ph"
#define TQM_NUM            "num"  // numeral
#define   TQM_NUM_ORD      "ord"  // ordinal     first, second
#define   TQM_NUM_CARD     "crd"  // cardinal    one, two
#define TQM_INFORMAL       "ifm"
#define TQM_FIG            "fig"
#define TQM_CON            "con"  // conjuncton  and, but
#define TQM_PREP           "pre"  // preposition behind, between
#define TQM_QUEST          "qu"   // question    who, what

// type delimiters

#define TQM_USER_TYPE  "#"   // designates number of user type
#define TQM_TYPE_DIV   ":"   // divide main from subtype

// usage delimiters (also declared in UsageManager.h)

#define UL_USER_USAGE  "#"   // designates number of user type

/**
@author Eric Pignet
*/
class KEduVocKvtmlReader : public TQObject
{
public:
	KEduVocKvtmlReader(TQFile *file);
	~KEduVocKvtmlReader();

	bool readDoc(KEduVocDocument *doc);

	bool readLesson(TQDomElement &domElementParent);
	bool readArticle(TQDomElement &domElementParent);
	bool readConjug(TQDomElement &domElementParent,
									vector<Conjugation> &curr_conjug,
                  const TQString &entry_tag);
	bool readOptions(TQDomElement &domElementParent);
	bool readType(TQDomElement &domElementParent);
	bool readTense(TQDomElement &domElementParent);
	bool readUsage(TQDomElement &domElementParent);
	bool readComparison(TQDomElement &domElementParent,
                      Comparison &comp);
	bool readMultipleChoice(TQDomElement &domElementParent,
                          MultipleChoice &mc);
	bool readExpressionChildAttributes(	TQDomElement &domElementExpressionChild,
														          TQString &lang,
														          grade_t &grade, grade_t &rev_grade,
														          int &count, int &rev_count,
														          time_t &date, time_t &rev_date,
														          TQString &remark,
														          int &bcount, int &rev_bcount,
														          TQString &query_id,
														          TQString &pronunce,
														          int &width,
														          TQString &type,
														          TQString &faux_ami_f,
														          TQString &faux_ami_t,
														          TQString &synonym,
														          TQString &example,
														          TQString &antonym,
														          TQString &usage,
														          TQString &paraphrase);
	bool readExpression(TQDomElement &domElementParent);
	bool readBody(TQDomElement &domElementParent);

	void domErrorUnknownElement(const TQString &elem);
	void domError(const TQString &text );

private:
  TQFile *m_inputFile;
  KEduVocDocument *m_doc;
};

#endif