summaryrefslogtreecommitdiff
path: root/src/protocol.hh
diff options
context:
space:
mode:
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