diff options
author | randomdan <randomdan@localhost> | 2012-03-22 01:22:51 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2012-03-22 01:22:51 +0000 |
commit | 0278f4a8efb30d4688ce57101cdcf7db34596e46 (patch) | |
tree | 655ad8951f769ab229e058355011d3bcc4c64469 /project2/compression/decompressStream.cpp | |
parent | Stream bug fix (diff) | |
download | project2-0278f4a8efb30d4688ce57101cdcf7db34596e46.tar.bz2 project2-0278f4a8efb30d4688ce57101cdcf7db34596e46.tar.xz project2-0278f4a8efb30d4688ce57101cdcf7db34596e46.zip |
A generic variadic template loader
A nocomp (pass through) stream decompressor
A tidy up and plugin implementation for stream decompressors
Diffstat (limited to 'project2/compression/decompressStream.cpp')
-rw-r--r-- | project2/compression/decompressStream.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/project2/compression/decompressStream.cpp b/project2/compression/decompressStream.cpp new file mode 100644 index 0000000..eb32833 --- /dev/null +++ b/project2/compression/decompressStream.cpp @@ -0,0 +1,30 @@ +#include "stream.h" +#include "scriptLoader.h" +#include "decompressor.h" +#include "scripts.h" +#include "scopeObject.h" +#include "scriptStorage.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) const + { + DecompressorPtr decomp = DecompressorLoader::getFor(method())->create(); + stream->runStream([&](const char * data, size_t len) -> size_t { + decomp->decompress(data, len, sink); + return len; + }); + } + + StreamPtr stream; + const Variable method; +}; + +DECLARE_LOADER("decompstream", DecompressStream); |