libfilezilla
ascii_layer.hpp
1 #ifndef LIBFILEZILLA_ASCII_LAYER_HEADER
2 #define LIBFILEZILLA_ASCII_LAYER_HEADER
3 
4 #include "buffer.hpp"
5 #include "socket.hpp"
6 
7 #include <optional>
8 
9 namespace fz {
16 class FZ_PUBLIC_SYMBOL ascii_layer final : public socket_layer, protected fz::event_handler
17 {
18 public:
19  ascii_layer(event_loop& loop, event_handler* handler, socket_interface& next_layer);
20  virtual ~ascii_layer();
21 
22  virtual int read(void *buffer, unsigned int size, int& error) override;
23  virtual int write(void const* buffer, unsigned int size, int& error) override;
24 
25  virtual int shutdown() override;
26 
27  virtual void set_event_handler(event_handler* handler, fz::socket_event_flag retrigger_block = fz::socket_event_flag{}) override;
28 
29 private:
30  virtual void operator()(fz::event_base const& ev) override;
31  void on_socket_event(socket_event_source* s, socket_event_flag t, int error);
32 
33  std::optional<uint8_t> tmp_read_;
34  buffer buffer_;
35  bool was_cr_{};
36  bool write_blocked_by_send_buffer_{};
37  bool waiting_read_{};
38 };
39 }
40 
41 #endif
Data has become available.
Interface for sockets.
Definition: socket.hpp:358
Simple handler for asynchronous event processing.
Definition: event_handler.hpp:54
Definition: ascii_layer.hpp:16
Socket classes for networking.
A threaded event loop that supports sending events and timers.
Definition: event_loop.hpp:33
A base class for socket layers.
Definition: socket.hpp:637
The namespace used by libfilezilla.
Definition: apply.hpp:17
Declares fz::buffer.
All classes sending socket events should derive from this.
Definition: socket.hpp:84
data can be written.
The buffer class is a simple buffer where data can be appended at the end and consumed at the front...
Definition: buffer.hpp:26
Common base class for all events.
Definition: event.hpp:22
socket_event_flag
The type of a socket event.
Definition: socket.hpp:34