WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
raw_socket_ostream.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include "wpi/util/raw_ostream.hpp"
8
9namespace wpi::net {
10
11class NetworkStream;
12
13class raw_socket_ostream : public wpi::util::raw_ostream {
14 public:
15 raw_socket_ostream(NetworkStream& stream, bool shouldClose)
16 : m_stream(stream), m_shouldClose(shouldClose) {}
18
19 void close();
20
21 bool has_error() const { return m_error; }
22 void clear_error() { m_error = false; }
23
24 protected:
25 void error_detected() { m_error = true; }
26
27 private:
28 void write_impl(const char* data, size_t len) override;
29 uint64_t current_pos() const override;
30
31 NetworkStream& m_stream;
32 bool m_error = false;
33 bool m_shouldClose;
34};
35
36} // namespace wpi::net
Definition NetworkStream.hpp:12
void error_detected()
Definition raw_socket_ostream.hpp:25
bool has_error() const
Definition raw_socket_ostream.hpp:21
void clear_error()
Definition raw_socket_ostream.hpp:22
raw_socket_ostream(NetworkStream &stream, bool shouldClose)
Definition raw_socket_ostream.hpp:15
Definition raw_socket_ostream.hpp:9