summaryrefslogtreecommitdiff
path: root/src/protocol.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/protocol.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/protocol.hh')
-rw-r--r--src/protocol.hh44
1 files changed, 44 insertions, 0 deletions
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 <stddef.h>
+#include <ostream>
+
+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