Just as a test I've done this:
struct membuf : std::streambuf
{
membuf(char* begin, char* end) {
this->setg(begin, begin, end);
}
};
class FileFactory final : public alure::FileIOFactory {
private:
membuf buf;
public:
FileFactory(membuf &bufin) : buf(bufin)
{
std::cout << "hello" << std::endl;
}
alure::UniquePtr<std::istream> openFile(const alure::String &name) noexcept override
{
auto stream = alure::MakeUnique<std::istream>(&buf);
if (stream->fail()) {
std::cout << "failed" << std::endl;
}
return std::move(stream);
}
};
In my main function I have:
membuf sbuf(existing_buff, existing_buff + sz);
alure::FileIOFactory::set(alure::MakeUnique<FileFactory>(sbuf));
When I run my test I get:
Failed to rewind file for the next decoder factory
This is just a test, I was planning to pass in a map of id,buf in the constructor to the factory if I got this to work.
Just as a test I've done this:
When I run my test I get:
Failed to rewind file for the next decoder factoryThis is just a test, I was planning to pass in a map of id,buf in the constructor to the factory if I got this to work.