summaryrefslogtreecommitdiff
path: root/src/protocols.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-08-06 22:23:41 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-08-06 22:25:44 +0200
commit178bb3a1ceab88f29aa7d0ceb453e76de172fd27 (patch)
tree09f830338d5490552ae878152de0f104cb7f6e5b /src/protocols.hh
parent9d586aec3a5615377e389318e97e7d756c970c96 (diff)
Add protools, used for getting content out of packages
Only HTTP protocol implemented yet, but with gzip, deflate and bzip2 suport
Diffstat (limited to 'src/protocols.hh')
-rw-r--r--src/protocols.hh51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/protocols.hh b/src/protocols.hh
new file mode 100644
index 0000000..8f3da0e
--- /dev/null
+++ b/src/protocols.hh
@@ -0,0 +1,51 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#ifndef PROTOCOLS_HH
+#define PROTOCOLS_HH
+
+#include <memory>
+#include <ostream>
+#include <stddef.h>
+
+class AttributedText;
+class Looper;
+
+class Protocols {
+public:
+ class Listener {
+ public:
+ virtual ~Listener() {}
+
+ virtual void text(Protocols* protocols,
+ size_t id, std::string const& protocol,
+ std::unique_ptr<AttributedText>&& text) = 0;
+ virtual void content(Protocols* protocols, size_t id,
+ std::string const& protocol, std::ostream* out) = 0;
+
+ protected:
+ Listener() {}
+ };
+
+ virtual ~Protocols() {}
+
+ static Protocols* create(size_t workers, size_t buffer, size_t cache,
+ Looper* looper, Listener* listener);
+
+ virtual void clear() = 0;
+
+ virtual void add(size_t id, void const* data, size_t size) = 0;
+ virtual void update(size_t id, void const* data, size_t size) = 0;
+ virtual void remove(size_t id) = 0;
+
+ virtual void text(size_t id) = 0;
+ virtual void free(size_t id, std::unique_ptr<AttributedText>&& text) = 0;
+
+ virtual void content(size_t id, std::ostream* out) = 0;
+
+protected:
+ Protocols() {}
+ Protocols(Protocols const&) = delete;
+ Protocols& operator=(Protocols const&) = delete;
+};
+
+#endif // PROTOCOLS_HH