#include #include "FileReaderFactory.h" #include "FileReader.h" #include "LocalFileReader.h" #include "HTTPFileReader.h" using namespace std; unique_ptr FileReaderFactory::create(const string & url) { FileReader * reader = nullptr; // protocol handlers if (url.starts_with("file://")) reader = new LocalFileReader(url); else if (url.starts_with("http://")) reader = new HTTPFileReader(url); else if (url.starts_with("https://")) reader = new HTTPFileReader(url); // no protocol = treat as file:// if (reader == nullptr) reader = new LocalFileReader(url); reader->open(); return unique_ptr(reader); }