]> granicus.if.org Git - icinga2/blob - lib/base/stdiostream.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / base / stdiostream.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef STDIOSTREAM_H
4 #define STDIOSTREAM_H
5
6 #include "base/i2-base.hpp"
7 #include "base/stream.hpp"
8 #include <iosfwd>
9
10 namespace icinga {
11
12 class StdioStream final : public Stream
13 {
14 public:
15         DECLARE_PTR_TYPEDEFS(StdioStream);
16
17         StdioStream(std::iostream *innerStream, bool ownsStream);
18         ~StdioStream() override;
19
20         size_t Read(void *buffer, size_t size, bool allow_partial = false) override;
21         void Write(const void *buffer, size_t size) override;
22
23         void Close() override;
24
25         bool IsDataAvailable() const override;
26         bool IsEof() const override;
27
28 private:
29         std::iostream *m_InnerStream;
30         bool m_OwnsStream;
31 };
32
33 }
34
35 #endif /* STDIOSTREAM_H */