-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilereader.cpp
More file actions
36 lines (30 loc) · 844 Bytes
/
filereader.cpp
File metadata and controls
36 lines (30 loc) · 844 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
#include <fstream>
#include <string>
#include "reader.h"
void filereader::read_file(std::string& filePath, std::string& text)
{
std::ifstream dataFile;
dataFile.open(filePath);
if (dataFile.is_open())
{
text.assign((std::istreambuf_iterator<char>(dataFile) ), (std::istreambuf_iterator<char>()));
}
dataFile.close();
}
void filereader::read_file_multiline(std::string& filePath, std::vector<std::string>& patterns)
{
std::string line = "";
std::ifstream dataFile;
dataFile.open(filePath);
if (dataFile.is_open())
{
std::getline(dataFile, line);
while (dataFile.good())
{
std::getline(dataFile, line);
if (line.length() == 7)
patterns.push_back(line);
}
}
dataFile.close();
}