From 8c0562c8ef37cd5e80c58609f7bc7ae352365f65 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 22 Oct 2024 14:44:47 +0200 Subject: refactor parser factory --- CSVParser.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'CSVParser.cpp') 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 header, string field) { return iter - header.begin(); } -void CSVParser::parse(FileReader & f, MuseumDeserializer & d) { +void CSVParser::parse(MuseumDeserializer & d) { vector> table = {}; - istringstream rows(f.read()); + istringstream rows(this->get_file().read()); string row; while (getline(rows, row)) { // ignore windows line endings -- cgit v1.2.3