aboutsummaryrefslogtreecommitdiff
path: root/CSVParser.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-22 14:44:47 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-22 14:44:47 +0200
commit8c0562c8ef37cd5e80c58609f7bc7ae352365f65 (patch)
tree42e9906c5ddf1b0e719ee3eb7b965a444be64c38 /CSVParser.cpp
parentbc02054d56118110a36aea72d21f9d5e73d07d1f (diff)
refactor parser factory
Diffstat (limited to 'CSVParser.cpp')
-rw-r--r--CSVParser.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/CSVParser.cpp b/CSVParser.cpp
index 824d5f4..8afce80 100644
--- a/CSVParser.cpp
+++ b/CSVParser.cpp
@@ -6,17 +6,11 @@
#include "CSVParser.h"
#include "Exception.h"
-#include "ParserFactory.h"
using namespace std;
-CSVParser CSVParser::instance {};
-CSVParser::CSVParser() {
- ParserFactory::register_strategy(this);
-}
-
-unsigned int CSVParser::heuristic(FileReader & f) {
- const string content = f.read();
+unsigned int CSVParser::heuristic() {
+ const string content = this->get_file().read();
int global_columns = 0;
int columns = 1;
int rows = 0;
@@ -41,10 +35,10 @@ static size_t header_idx(vector<string> header, string field) {
return iter - header.begin();
}
-void CSVParser::parse(FileReader & f, MuseumDeserializer & d) {
+void CSVParser::parse(MuseumDeserializer & d) {
vector<vector<string>> table = {};
- istringstream rows(f.read());
+ istringstream rows(this->get_file().read());
string row;
while (getline(rows, row)) {
// ignore windows line endings