Telnet++ 4.0.0.9
A C++ library for interacting with Telnet streams
Loading...
Searching...
No Matches
codec.hpp
1#pragma once
2
3#include "telnetpp/core.hpp"
4
5#include <boost/exception/exception.hpp>
6
7#include <functional>
8#include <stdexcept>
9
11
12//* =========================================================================
16//* =========================================================================
17class TELNETPP_EXPORT codec
18{
19public:
20 using continuation =
21 std::function<void(telnetpp::bytes data, bool continuation_ended)>;
22
23 //* =====================================================================
25 //* =====================================================================
26 virtual ~codec() = default;
27
28 //* =====================================================================
31 //* =====================================================================
32 void start();
33
34 //* =====================================================================
37 //* =====================================================================
38 void finish(continuation const &cont);
39
40 //* =====================================================================
46 //* =====================================================================
47 void operator()(telnetpp::bytes data, continuation const &cont);
48
49private:
50 //* =====================================================================
52 //* =====================================================================
53 virtual void do_start() {};
54
55 //* =====================================================================
57 //* =====================================================================
58 virtual void do_finish(continuation const & /*cont*/) {};
59
60 //* =====================================================================
71 //* =====================================================================
72 virtual telnetpp::bytes transform_chunk(
73 telnetpp::bytes data, continuation const &continuation) = 0;
74
75 bool engaged_{false};
76};
77
78//* =========================================================================
81//* =========================================================================
82class TELNETPP_EXPORT corrupted_stream_error : virtual std::domain_error,
83 virtual boost::exception
84{
85public:
86 //* =====================================================================
88 //* =====================================================================
89 explicit corrupted_stream_error(char const *what_arg);
90};
91
92} // namespace telnetpp::options::mccp
Represents an object that can transform (encode or decode) arbitrary byte sequences....
Definition codec.hpp:18
virtual ~codec()=default
Destructor.
An exception that is thrown in the case that a stream of data cannot be decompressed.
Definition codec.hpp:84
An implementation of the Mud Client Compression Protocol.
Definition client.hpp:5