3232#include < set>
3333#include < streambuf>
3434
35- using lslboost::asio::basic_socket;
36- using lslboost::asio::io_context;
37- using lslboost::asio::ip::tcp;
35+ namespace asio = lslboost::asio;
36+ using lslboost::system::error_code;
37+ using asio::basic_socket;
38+ using asio::io_context;
39+ using asio::ip::tcp;
3840
3941namespace lsl {
4042typedef tcp Protocol;
@@ -46,7 +48,7 @@ class cancellable_streambuf : public std::streambuf,
4648public:
4749 // / Construct a cancellable_streambuf without establishing a connection.
4850 cancellable_streambuf ()
49- : basic_socket<Protocol>(lslboost::base_from_member<lslboost:: asio::io_context>::member),
51+ : basic_socket<Protocol>(lslboost::base_from_member<asio::io_context>::member),
5052 cancel_issued_ (false ), cancel_started_(false ) {
5153 init_buffers ();
5254 }
@@ -92,10 +94,10 @@ class cancellable_streambuf : public std::streambuf,
9294 this ->basic_socket <Protocol>::async_connect (endpoint, handler);
9395 this ->get_service ().get_io_context ().reset ();
9496 }
95- ec_ = lslboost:: asio::error::would_block;
97+ ec_ = asio::error::would_block;
9698 do
9799 this ->get_service ().get_io_context ().run_one ();
98- while (!cancel_issued_ && ec_ == lslboost:: asio::error::would_block);
100+ while (!cancel_issued_ && ec_ == asio::error::would_block);
99101 return !ec_ ? this : nullptr ;
100102 }
101103
@@ -115,7 +117,7 @@ class cancellable_streambuf : public std::streambuf,
115117 * @return An \c error_code corresponding to the last error from the stream
116118 * buffer.
117119 */
118- const lslboost::system:: error_code &error () const { return ec_; }
120+ const error_code &error () const { return ec_; }
119121
120122protected:
121123 // / Close the socket if it's open.
@@ -142,14 +144,14 @@ class cancellable_streambuf : public std::streambuf,
142144 if (gptr () == egptr ()) {
143145 io_handler handler = {this };
144146 this ->get_service ().async_receive (this ->get_implementation (),
145- lslboost:: asio::buffer (lslboost:: asio::buffer (get_buffer_) + putback_max), 0 ,
147+ asio::buffer (asio::buffer (get_buffer_) + putback_max), 0 ,
146148 handler);
147149
148- ec_ = lslboost:: asio::error::would_block;
150+ ec_ = asio::error::would_block;
149151 protected_reset (); // line changed for lsl
150152 do
151153 this ->get_service ().get_io_context ().run_one ();
152- while (ec_ == lslboost:: asio::error::would_block);
154+ while (ec_ == asio::error::would_block);
153155 if (ec_) return traits_type::eof ();
154156
155157 setg (&get_buffer_[0 ], &get_buffer_[0 ] + putback_max,
@@ -161,16 +163,16 @@ class cancellable_streambuf : public std::streambuf,
161163
162164 int_type overflow (int_type c) override {
163165 // Send all data in the output buffer.
164- lslboost:: asio::const_buffer buffer = lslboost:: asio::buffer (pbase (), pptr () - pbase ());
165- while (lslboost:: asio::buffer_size (buffer) > 0 ) {
166+ asio::const_buffer buffer = asio::buffer (pbase (), pptr () - pbase ());
167+ while (asio::buffer_size (buffer) > 0 ) {
166168 io_handler handler = {this };
167169 this ->get_service ().async_send (
168- this ->get_implementation (), lslboost:: asio::buffer (buffer), 0 , handler);
169- ec_ = lslboost:: asio::error::would_block;
170+ this ->get_implementation (), asio::buffer (buffer), 0 , handler);
171+ ec_ = asio::error::would_block;
170172 protected_reset (); // line changed for lsl
171173 do
172174 this ->get_service ().get_io_context ().run_one ();
173- while (ec_ == lslboost:: asio::error::would_block);
175+ while (ec_ == asio::error::would_block);
174176 if (ec_) return traits_type::eof ();
175177 buffer = buffer + bytes_transferred_;
176178 }
@@ -202,17 +204,17 @@ class cancellable_streambuf : public std::streambuf,
202204 friend struct io_handler ;
203205 struct io_handler {
204206 cancellable_streambuf *this_;
205- void operator ()(const lslboost::system:: error_code &ec, std::size_t bytes_transferred = 0 ) {
207+ void operator ()(const error_code & ec, std::size_t bytes_transferred = 0 ) {
206208 this_->ec_ = ec;
207209 this_->bytes_transferred_ = bytes_transferred;
208210 }
209211 };
210212
211213 enum { putback_max = 8 };
212214 enum { buffer_size = 512 };
213- lslboost:: asio::detail::array<char , buffer_size> get_buffer_;
214- lslboost:: asio::detail::array<char , buffer_size> put_buffer_;
215- lslboost::system:: error_code ec_;
215+ asio::detail::array<char , buffer_size> get_buffer_;
216+ asio::detail::array<char , buffer_size> put_buffer_;
217+ error_code ec_;
216218 std::size_t bytes_transferred_;
217219 std::atomic<bool > cancel_issued_;
218220 bool cancel_started_;
0 commit comments