summaryrefslogtreecommitdiff
path: root/project2/compression/decompressStream.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-03-22 01:22:51 +0000
committerrandomdan <randomdan@localhost>2012-03-22 01:22:51 +0000
commit124e182581cd6bc168e206b20d70a6fabf2e5854 (patch)
tree655ad8951f769ab229e058355011d3bcc4c64469 /project2/compression/decompressStream.cpp
parentStream bug fix (diff)
downloadproject2-124e182581cd6bc168e206b20d70a6fabf2e5854.tar.bz2
project2-124e182581cd6bc168e206b20d70a6fabf2e5854.tar.xz
project2-124e182581cd6bc168e206b20d70a6fabf2e5854.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.cpp30
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);