WPILibC++ 2024.3.2
raw_socket_ostream.h
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#ifndef WPINET_RAW_SOCKET_OSTREAM_H_
6#define WPINET_RAW_SOCKET_OSTREAM_H_
7
8#include <wpi/raw_ostream.h>
9
10namespace wpi {
11
12class NetworkStream;
13
15 public:
16 raw_socket_ostream(NetworkStream& stream, bool shouldClose)
17 : m_stream(stream), m_shouldClose(shouldClose) {}
19
20 void close();
21
22 bool has_error() const { return m_error; }
23 void clear_error() { m_error = false; }
24
25 protected:
26 void error_detected() { m_error = true; }
27
28 private:
29 void write_impl(const char* data, size_t len) override;
30 uint64_t current_pos() const override;
31
32 NetworkStream& m_stream;
33 bool m_error = false;
34 bool m_shouldClose;
35};
36
37} // namespace wpi
38
39#endif // WPINET_RAW_SOCKET_OSTREAM_H_
Definition: NetworkStream.h:13
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:43
Definition: raw_socket_ostream.h:14
~raw_socket_ostream() override
bool has_error() const
Definition: raw_socket_ostream.h:22
raw_socket_ostream(NetworkStream &stream, bool shouldClose)
Definition: raw_socket_ostream.h:16
void error_detected()
Definition: raw_socket_ostream.h:26
void clear_error()
Definition: raw_socket_ostream.h:23
Definition: ntcore_cpp.h:26