-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubFile.cpp
More file actions
41 lines (34 loc) · 908 Bytes
/
SubFile.cpp
File metadata and controls
41 lines (34 loc) · 908 Bytes
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
//
// Created by Max on 2021-05-09.
//
#include "SubFile.h"
SubFile::SubFile(const std::string &fileName) {
file = std::ifstream(fileName);
}
Block SubFile::getNextBlock() {
std::string line;
int pos = 0;
Block block;
while (!(line = getNextLine()).empty()) {
if (pos == 0) {
block.index = std::stoi(line);
} else if (pos == 1) {
TimeStamp from{};
from.init(line.substr(0, line.find('-')));
block.from = from;
TimeStamp to{};
to.init(line.substr(line.find('>')+1, line.length()));
block.to = to;
} else {
block.content.append(line);
block.content.append("\n");
}
pos++;
}
return block;
}
std::string SubFile::getNextLine() {
temp = "";
getline(file, temp);
return temp;
}