#include #include #include "LoadFilesCommand.h" #include "MuseumDeserializer.h" #include "Exception.h" #include "FileReaderFactory.h" #include "FileReader.h" #include "ToggleMuseumPauseCommand.h" #include "ParserFactory.h" using namespace std; void LoadFilesCommand::execute(int argc, char ** argv) { vector files = {}; for (size_t i = 0; i < argc; i++) { files.push_back(string(argv[i])); } return this->execute(files); } void LoadFilesCommand::execute(vector files) { try { this->load_files(files); } catch (Exception & e) { throw Exception("LoadFilesCommand error: %s", e.what()); } } void LoadFilesCommand::load_files(vector files) { ToggleMuseumPauseCommand(this).set(true); MuseumDeserializer deserializer { this->get_museum() }; for (string url : files) { unique_ptr file = FileReaderFactory::open(url); try { ParserFactory::parse(*file, deserializer); } catch (Exception & e) { throw Exception("parser error: %s (%s)", e.what(), url.c_str()); } } }