-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread.cpp
More file actions
35 lines (33 loc) · 976 Bytes
/
Copy pathread.cpp
File metadata and controls
35 lines (33 loc) · 976 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
#include <fstream>
#include "read.h"
#include <iostream>
#include <sstream>
std::vector<std::vector<std::string>>
reader::readTable(const std::string &filename, char end) {
std::ifstream in(filename);
std::vector<std::vector<std::string>> result;
while (!in.eof()) {
std::vector<std::string> vecStrings;
std::string temp;
std::getline(in, temp, end);
std::stringstream helper;
helper << temp;
while (!helper.eof()) {
std::string nowStr;
helper >> nowStr;
vecStrings.push_back(std::move(nowStr));
}
result.push_back(vecStrings);
}
return result;
}
std::vector<std::string> reader::readLines(const std::string &filename, char end) {
std::ifstream in(filename);
std::vector<std::string> result;
while (!in.eof()) {
std::string now;
std::getline(in, now, end);
result.push_back(std::move(now));
}
return result;
}