-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataReader.cpp
50 lines (45 loc) · 977 Bytes
/
DataReader.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
50
#include "DataReader.h"
#include <string>
#include <fstream>
#include <iostream>
DataReader::DataReader()
{}
DataReader::~DataReader()
{}
void DataReader::loadObj(std::string obj)
{
//fix the path
obj += ".dat";
obj = "data/"+obj;
//open file
ifs.open((obj).c_str(),std::ifstream::in);
if(ifs.good()){
std::cout << "File: " << obj << " Opened Successfully\n";
}
else{
std::cout << "Error Opening file: " << obj << "\n";
}
}
void DataReader::closeObj()
{
if(ifs.is_open()){
ifs.close();
std::cout << "File Closed\n";
}
}
std::string DataReader::getValue(std::string s)
{
//std::cout << "Searching for: " << s << "\n";
ifs.seekg(0);
std::string temp;
while(ifs.good())
{
std::getline(ifs,temp);
if(temp.find(s) != std::string::npos)
{
temp.erase(temp.begin(), temp.begin()+s.length()+1);
break;
}
}
return temp;
}