Open alexey-malov opened 6 years ago
CompressOutputStreamDecorator::~CompressOutputStreamDecorator()
{
Flush();
}
for (uint8_t i = 0; i < chunk->count; ++i)
{
m_decompressedBuffer.push_back(chunk->byte);
++unpacked;
}
using InputStreamDecorator = function<unique_ptr<IInputStream>(unique_ptr<IInputStream>&& s);
using OutputStreamDecorator = function<unique_ptr<IOutputStream>(unique_ptr<IOutputStream>&& s);
vector<InputStreamDecorator> inputDecorators;
vector<OutputStreamDecorator> outputDecorators;
inputDecorators.emplace_back([](auto&& s){
return make_unique<Decompress>(move(s));
});
inputDecorator.emplace_back([key](auto&& s){
return make_unique<Decrypt>(move(s));
});
for (auto&& d : inputDecorators)
{
s = d(move(s));
}
либо
InputStreamDecorator applyDecompressor;
for (auto&& option : options)
{
if (option == "--decompress")
applyDecompressor = [](auto&& s){
return make_unique<Decompress>(move(s));
};
...
}
if (applyDecompressor)
{
s = applyDecompressor(move(s));
}
if (applyDecryptor)
{
s = applyDecryptor(move(s));
}