24 #ifndef GOBY_MIDDLEWARE_IO_LINE_BASED_PTY_H
25 #define GOBY_MIDDLEWARE_IO_LINE_BASED_PTY_H
30 #include <boost/asio/read_until.hpp>
31 #include <boost/asio/streambuf.hpp>
32 #include <boost/system/error_code.hpp>
70 bool use_indexed_groups =
false>
72 subscribe_layer, ThreadType, use_indexed_groups>
75 ThreadType, use_indexed_groups>;
90 void async_read()
override;
94 boost::asio::streambuf buffer_;
104 bool use_indexed_groups>
106 subscribe_layer, ThreadType,
107 use_indexed_groups>::async_read()
109 boost::asio::async_read_until(
110 this->mutable_socket(), buffer_, eol_matcher_,
111 [
this](
const boost::system::error_code& ec, std::size_t bytes_transferred)
113 if (!ec && bytes_transferred > 0)
115 std::string bytes(bytes_transferred, 0);
116 std::istream is(&buffer_);
117 is.read(&bytes[0], bytes_transferred);
118 this->handle_read_success(bytes_transferred, bytes);
123 this->handle_read_error(ec);