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/protocol.hh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/protocol.hh (limited to 'src/protocol.hh') diff --git a/src/protocol.hh b/src/protocol.hh new file mode 100644 index 0000000..e010092 --- /dev/null +++ b/src/protocol.hh @@ -0,0 +1,44 @@ +// -*- mode: c++; c-basic-offset: 2; -*- + +#ifndef PROTOCOL_HH +#define PROTOCOL_HH + +#include +#include + +class AttributedText; + +class Protocol { +public: + class Match { + public: + virtual ~Match() {} + + virtual std::string const& name() const = 0; + virtual void full(void const* data, size_t size, AttributedText* text) = 0; + virtual void append(void const* data, size_t /* offset */, size_t size, + AttributedText* text) { + full(data, size, text); + } + virtual bool content(void const* /* data */, size_t /* size */, + std::ostream* /* out */) { + return false; + } + + protected: + Match() {} + Match(Match const&) = delete; + Match& operator=(Match const&) = delete; + }; + + virtual ~Protocol() {} + + virtual Match* match(void const* data, size_t size) const = 0; + +protected: + Protocol() {} + Protocol(Protocol const&) = delete; + Protocol& operator=(Protocol const&) = delete; +}; + +#endif // PROTOCOL_HH -- cgit v1.2.3-70-g09d2