-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarcfile.cpp
49 lines (39 loc) · 978 Bytes
/
marcfile.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
#include "marcfile.h"
MarcFile::MarcFile(std::string filePath) {
this->filePath = filePath;
this->content = "";
this->_getContent();
}
void MarcFile::_getContent() {
std::ifstream f(filePath.c_str());
if (!f.is_open()) {
return;
}
std::getline(f, this->content);
f.close();
}
Record MarcFile::next() {
std::string delimiter;
delimiter = (char) 29;
size_t pos;
if ((pos = this->content.find(delimiter)) != std::string::npos) {
std::string raw_record = this->content.substr(0, pos);
Record r;
r.setRawData(raw_record);
this->content.erase(0, pos + delimiter.length());
return r;
}
//size_t pos = 0;
//std::string raw_record;
//while ((pos = content.find(delimiter)) != std::string::npos) {
// raw_record = content.substr(0, pos);
// Record r(raw_record);
// content.erase(0, pos + delimiter.length());
//}
}
bool MarcFile::isValid() {
if (this->content != "") {
return false;
}
return true;
}