diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-22 14:44:47 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-22 14:44:47 +0200 |
commit | 8c0562c8ef37cd5e80c58609f7bc7ae352365f65 (patch) | |
tree | 42e9906c5ddf1b0e719ee3eb7b965a444be64c38 /XMLParser.cpp | |
parent | bc02054d56118110a36aea72d21f9d5e73d07d1f (diff) |
refactor parser factory
Diffstat (limited to 'XMLParser.cpp')
-rw-r--r-- | XMLParser.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/XMLParser.cpp b/XMLParser.cpp index 4bfde46..6252be8 100644 --- a/XMLParser.cpp +++ b/XMLParser.cpp @@ -4,18 +4,11 @@ #include "XMLParser.h" #include "Exception.h" -#include "ParserFactory.h" -#include "TileData.h" using namespace std; -XMLParser XMLParser::instance {}; -XMLParser::XMLParser() { - ParserFactory::register_strategy(this); -} - -unsigned int XMLParser::heuristic(FileReader & f) { - const string content = f.read(); +unsigned int XMLParser::heuristic() { + const string content = this->get_file().read(); int open_backets = 0; int close_brackets = 0; for (char c : content) { @@ -27,10 +20,10 @@ unsigned int XMLParser::heuristic(FileReader & f) { return (open_backets + close_brackets) / penalty; } -void XMLParser::parse(FileReader & f, MuseumDeserializer & d) { +void XMLParser::parse(MuseumDeserializer & d) { using namespace pugi; - const string content = f.read(); + const string content = this->get_file().read(); xml_document doc; xml_parse_result result = doc.load_string(content.c_str()); if (!result) |