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 /LoadFilesCommand.cpp | |
parent | bc02054d56118110a36aea72d21f9d5e73d07d1f (diff) |
refactor parser factory
Diffstat (limited to 'LoadFilesCommand.cpp')
-rw-r--r-- | LoadFilesCommand.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/LoadFilesCommand.cpp b/LoadFilesCommand.cpp index 3fb4978..76cd197 100644 --- a/LoadFilesCommand.cpp +++ b/LoadFilesCommand.cpp @@ -1,3 +1,4 @@ +#include <memory> #include <vector> #include <string> @@ -27,12 +28,15 @@ void LoadFilesCommand::load_files() { ToggleMuseumPauseCommand(this->museum, true).execute(); MuseumDeserializer deserializer { this->museum }; + ParserFactory factory {}; + for (string url : files) { - unique_ptr<FileReader> file = FileReaderFactory().create(url); try { - ParserFactory::parse(*file, deserializer); + unique_ptr<FileReader> file = FileReaderFactory().create(url); + Parser & parser = factory.get_parser(*file); + parser.parse(deserializer); } catch (Exception & e) { - throw Exception("parser error: %s (%s)", e.what(), url.c_str()); + throw Exception("%s (%s)", e.what(), url.c_str()); } } } @@ -41,7 +45,7 @@ void LoadFilesCommand::execute() { try { this->load_files(); } catch (Exception & e) { - throw Exception("LoadFilesCommand error: %s", e.what()); + throw Exception("LoadFilesCommand: %s", e.what()); } } |