blob: c1d52ab10c28ab67aec7a904a5a31c54dfab9e99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "stream.h"
#include "componentLoader.h"
#include "decompressor.h"
#include "scripts.h"
#include "variables.h"
#include "scriptStorage.h"
#include "instanceStore.impl.h"
class DecompressStream : public Stream {
public:
DecompressStream(ScriptNodePtr p) :
Stream(p),
method(p, "method")
{
p->script->loader.addLoadTarget(p, Storer::into<ElementLoader>(&stream));
}
void runStream(const Sink & sink, ExecContext * ec) const
{
DecompressorPtr decomp = DecompressorLoader::getFor(method(ec))->create();
stream->runStream([&](const char * data, size_t len) -> size_t {
decomp->decompress(data, len, sink);
return len;
}, ec);
}
StreamPtr stream;
const Variable method;
};
DECLARE_LOADER("decompstream", DecompressStream);
INSTANTIATESTORE(std::string, DecompressorLoader);
|