summaryrefslogtreecommitdiff
path: root/src/packages.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/packages.hh')
-rw-r--r--src/packages.hh49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/packages.hh b/src/packages.hh
new file mode 100644
index 0000000..e646f92
--- /dev/null
+++ b/src/packages.hh
@@ -0,0 +1,49 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#ifndef PACKAGES_HH
+#define PACKAGES_HH
+
+#include "package.hh"
+
+class PackagesWriter {
+public:
+ virtual ~PackagesWriter() {}
+
+ static PackagesWriter* create(size_t count, std::ostream* out);
+
+ virtual void write(Package const& package, std::string const& data) = 0;
+
+protected:
+ PackagesWriter() {}
+ PackagesWriter(PackagesWriter const&) = delete;
+ PackagesWriter& operator=(PackagesWriter const&) = delete;
+};
+
+class PackagesReader {
+public:
+ enum Status {
+ GOOD,
+ INVALID,
+ IO_ERROR,
+ };
+
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ virtual void package(Package const& package) = 0;
+ virtual void data(uint32_t id, char const* data, size_t size,
+ bool last) = 0;
+
+ protected:
+ Delegate() {}
+ };
+
+ static Status read(std::istream& in, Delegate* delegate);
+
+private:
+ ~PackagesReader() {}
+ PackagesReader() {}
+};
+
+#endif // PACKAGES_HH