forked from ZXCroon/Wordable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentences.cpp
executable file
·41 lines (35 loc) · 962 Bytes
/
sentences.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
#include "sentences.h"
Sentences::Sentences(FileStrBridge* fsb, const string& itemName) :
ComplexInfo(fsb, itemName, true) {
construct();
}
Sentences::~Sentences() {
destruct();
}
void Sentences::transStrToProp(const string& infoStr) {
int lastEnd = -1;
for (;;) {
int lp = infoStr.find('#', lastEnd + 1);
if (lp == string::npos) break;
int rp = infoStr.find('#', lp + 1);
sentList.push_back(infoStr.substr(lp + 1, rp - 1 - (lp + 1) + 1));
lastEnd = rp;
}
}
string Sentences::transPropToStr() {
string res = "";
for (vector <string>::iterator it = sentList.begin(); it != sentList.end(); ++it) {
res += '#' + (*it) + '#' + '\n';
}
str::clearEnds(res);
return res;
}
void Sentences::add(const string& sentence) {
string temps = sentence;
str::clearEnds(temps);
sentList.push_back(temps);
}
void Sentences::del(int no) {
if (no > sentList.size()) return;
sentList.erase(sentList.begin() + no - 1);
}