WPILibC++  2019.1.1-beta-4-27-ga2368a6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
raw_socket_ostream.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef WPIUTIL_WPI_RAW_SOCKET_OSTREAM_H_
9 #define WPIUTIL_WPI_RAW_SOCKET_OSTREAM_H_
10 
11 #include "wpi/raw_ostream.h"
12 
13 namespace wpi {
14 
15 class NetworkStream;
16 
18  public:
19  raw_socket_ostream(NetworkStream& stream, bool shouldClose)
20  : m_stream(stream), m_shouldClose(shouldClose) {}
22 
23  void close();
24 
25  bool has_error() const { return m_error; }
26  void clear_error() { m_error = false; }
27 
28  protected:
29  void error_detected() { m_error = true; }
30 
31  private:
32  void write_impl(const char* data, size_t len) override;
33  uint64_t current_pos() const override;
34 
35  NetworkStream& m_stream;
36  bool m_error = false;
37  bool m_shouldClose;
38 };
39 
40 } // namespace wpi
41 
42 #endif // WPIUTIL_WPI_RAW_SOCKET_OSTREAM_H_
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Definition: NetworkStream.h:17
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Definition: raw_socket_ostream.h:17