-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdef.cpp
75 lines (61 loc) · 1.7 KB
/
def.cpp
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
#include "def.h"
OnePieceOfDef::OnePieceOfDef(const string& pospStr, const string& def) :
posp(word::strToPOSP(pospStr)), def(def) {
}
OnePieceOfDef::OnePieceOfDef(const word::POSP& posp, const string& def) :
posp(posp), def(def) {
}
OnePieceOfDef::OnePieceOfDef(const string& entireDef) {
string _entireDef = entireDef;
str::clearEnds(_entireDef);
int dotPos = _entireDef.find('.');
posp = word::strToPOSP(_entireDef.substr(0, dotPos));
def = _entireDef.substr(dotPos + 1, _entireDef.length() - 1 - dotPos);
str::clearEnds(def);
}
OnePieceOfDef::~OnePieceOfDef() {
}
string OnePieceOfDef::toString() {
return word::POSPToStr(posp) + ". " + def;
}
word::POSP OnePieceOfDef::getPosp() {
return posp;
}
string OnePieceOfDef::getDef() {
return def;
}
Def::Def(FileStrBridge* fsb, const string& itemName) :
ComplexInfo(fsb, itemName) {
construct();
}
Def::~Def() {
destruct();
}
int Def::getSize() {
return defList.size();
}
OnePieceOfDef* Def::getItem(int no) {
return defList[no];
}
void Def::transStrToProp(const string& infoStr) {
//cout << "Def::transStrTopProp called" << endl;
int lastEnd = -1;
for (;;) {
int lp = infoStr.find('#', lastEnd + 1);
if (lp == string::npos) break;
int rp = infoStr.find('#', lp + 1);
string temps = infoStr.substr(lp + 1, rp - 1 - (lp + 1) + 1);
OnePieceOfDef* opod = new OnePieceOfDef(temps);
defList.push_back(opod);
lastEnd = rp;
}
}
string Def::transPropToStr() {
//cout << "Def::transPropToStr called" << endl;
string res = "";
for (vector <OnePieceOfDef*>::iterator it = defList.begin(); it != defList.end(); ++it) {
res += '#' + (*it)->toString() + '#' + '\n';
}
str::clearEnds(res);
return res;
}