aboutsummaryrefslogtreecommitdiff
path: root/Parser.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 15:48:14 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-18 15:48:14 +0200
commitd8289105193707daede1a5b59137f18e20f20aeb (patch)
tree939908b9c4c6f7aaef8aa61ee2e04be3e85610b6 /Parser.cpp
parent76e61d68bbf568ec0d7fc4632e52d4de5496b003 (diff)
(2/2) rename
Diffstat (limited to 'Parser.cpp')
-rw-r--r--Parser.cpp32
1 files changed, 0 insertions, 32 deletions
diff --git a/Parser.cpp b/Parser.cpp
deleted file mode 100644
index 49c4d00..0000000
--- a/Parser.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <algorithm>
-
-#include "ParserFactory.h"
-#include "Exception.h"
-
-void ParserFactory::parse(FileReader & file, MuseumDeserializer & deserializer) {
- auto & col = ParserFactory::get_collection();
- if (col.size() < 1)
- throw Exception("no parsers registered");
-
- unsigned int best_score = 0;
- Parser * best_strategy = nullptr;
- for (Parser * strategy : col) {
- unsigned int score = strategy->heuristic(file);
- if (score <= best_score) continue;
-
- best_score = score;
- best_strategy = strategy;
- }
-
- if (best_strategy == nullptr)
- throw Exception("unknown file type");
-
- best_strategy->parse(file, deserializer);
-}
-
-void ParserFactory::register_strategy(Parser * ps) {
- auto & col = ParserFactory::get_collection();
- if (std::find(col.begin(), col.end(), ps) != col.end()) return;
- col.push_back(ps);
-}
-