forked from ZXCroon/Wordable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef.h
executable file
·66 lines (47 loc) · 1.21 KB
/
def.h
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
#ifndef DEF_H
#define DEF_H
#include <vector>
#include "info.h"
#include "util.h"
class OnePieceOfDef {
public:
OnePieceOfDef(const string& pospStr, const string& def);
OnePieceOfDef(const word::POSP& posp, const string& def);
OnePieceOfDef(const string& entireDef);
~OnePieceOfDef();
string toString();
word::POSP getPosp();
string getDef();
private:
word::POSP posp;
string def;
};
class Def : public ComplexInfo {
public:
Def(FileStrBridge* fsb, const string& itemName);
~Def();
OnePieceOfDef* getItem(int no);
int getSize();
// It's better to let print be virtual.
// However, template cannot be declared as virtual.
template <class T>
void print(T& display) {
vector <OnePieceOfDef*>::iterator it = defList.begin();
sendStr(display, "\n");
for (int no = 1; it != defList.end(); ++it, ++no) {
string s = " ";
s += str::intToStr(no);
s += ". [";
s += word::POSPToStr((*it)->getPosp()) + "] ";
s += (*it)->getDef() + '\n';
sendStr(display, s);
}
sendStr(display, "\n");
}
protected:
void transStrToProp(const string& infoStr);
string transPropToStr();
private:
vector <OnePieceOfDef*> defList;
};
#endif