-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_Input.cpp
More file actions
59 lines (50 loc) · 1.54 KB
/
c_Input.cpp
File metadata and controls
59 lines (50 loc) · 1.54 KB
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
#include "coreVariables.h"
#include "c_Input.h"
// _____ _ _____ _
// | __ \ | | |_ _| | |
// | | | | __ _| |_ __ _ | | _ __ _ __ _ _| |_
// | | | |/ _` | __/ _` | | | | '_ \| '_ \| | | | __|
// | |__| | (_| | || (_| | _| |_| | | | |_) | |_| | |_
// |_____/ \__,_|\__\__,_| |_____|_| |_| .__/ \__,_|\__|
// | |
// |_|
void c_Input::loadFile(std::string inputDirectory, std::string inputFile)
{
// Clear Vector from previous run
edition.clear();
// Load file
std::ifstream input(inputDirectory + inputFile);
while (input)
{
// Separate by line
std::string line;
for (std::string line; std::getline(input, line, '\n');)
{
// Separate by field
std::istringstream iline(line);
while (iline)
{
std::string field;
std::getline(iline, field, '\t');
buffer.push_back(field);
}
edition.push_back(emptyEntry);
size_t current = edition.size() - 1;
edition[current].documentID = buffer[0];
edition[current].page = std::stoi(buffer[1]);
edition[current].column = std::stoi(buffer[2]);
edition[current].snippet = std::stoi(buffer[3]);
edition[current].type = buffer[4];
edition[current].key_value = buffer[5];
if (dataFlag == "T")
{
edition[current].text = buffer[6];
}
else if (dataFlag == "N")
{
edition[current].wordcount = std::stof(buffer[6]);
}
buffer.clear();
}
}
}