#include "FileReader.h" #include "File.h" File & FileReader::open(const std::string url) { File * reader = find_reader(url)->clone(); reader->open(url); return *reader; } void FileReader::assign(const std::string type, const File * node) { static FactoryMap & map = get_map(); map[type] = node; } FactoryMap & FileReader::get_map() { static FactoryMap map; return map; } const File * FileReader::find_reader(const std::string type) { static FactoryMap & map = get_map(); // try to find protocol by prefix for (auto item : map) { if (!type.starts_with(item.first)) continue; return item.second; } // fallback is local file return map.find("file://")->second; }