-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseFile.cpp
46 lines (41 loc) · 1009 Bytes
/
parseFile.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
//
// Created by evren on 4.01.2022.
//
#include <fstream>
#include <sstream>
#include "parseFile.h"
parseFile::parseFile(std::string filePath) {
this->filePath = filePath;
this->setCount();
this->setContent();
this->setFieldSize();
}
void parseFile::setCount() {
// gets the number of lines in the file
std::ifstream file(this->filePath);
std::string tempRow;
while (std::getline(file, tempRow)) {
this->rowCount++;
}
file.close();
}
void parseFile::setContent() {
// gets the content of the file
std::ifstream file(this->filePath);
std::string tempRow;
int i = 0;
while (std::getline(file, tempRow)) {
this->content[i] += tempRow + "\n";
i++;
}
file.close();
}
void parseFile::setFieldSize() {
// gets the size of the field in the file's first row
std::stringstream stream(this->content[0]);
int i = 0;
while (stream.good() && i < 2){
stream >> this->fieldSize[i];
i++;
}
}