From 178bb3a1ceab88f29aa7d0ceb453e76de172fd27 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 6 Aug 2017 22:23:41 +0200 Subject: Add protools, used for getting content out of packages Only HTTP protocol implemented yet, but with gzip, deflate and bzip2 suport --- src/protocols.hh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/protocols.hh (limited to 'src/protocols.hh') 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 +#include +#include + +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&& 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&& 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 -- cgit v1.2.3-70-g09d2