Chi-Tech
chi_logstream.h
Go to the documentation of this file.
1#ifndef CHI_LOGSTREAM_H
2#define CHI_LOGSTREAM_H
3
4#include <iostream>
5#include <sstream>
6
7namespace chi
8{
9//###################################################################
10/** Log stream for adding header information to a string stream.*/
11class LogStream : public std::stringstream
12{
13private:
14 std::ostream* log_stream_;
15 std::string log_header_;
16 const bool dummy_ = false;
17
18public:
19 /** Creates a string stream.*/
20 LogStream(std::ostream* output_stream,
21 std::string header,
22 bool dummy_flag=false) :
23 log_stream_(output_stream),
24 log_header_(std::move(header)),
25 dummy_(dummy_flag)
26 { }
27
28 /** Flushes the broken-up/headered stream to the output.*/
29 virtual ~LogStream();
30
31 LogStream(const LogStream& other)
32 {
35 }
36};
37
38struct DummyStream: public std::ostream
39{
40 struct DummyStreamBuffer : std::streambuf
41 {
42 virtual int overflow(int c) { return c; };
44
45 DummyStream(): std::ostream(&buffer) {}
46
48};
49}//namespace chi_objects
50#endif //CHI_LOGSTREAM_H
std::ostream * log_stream_
Definition: chi_logstream.h:14
LogStream(const LogStream &other)
Definition: chi_logstream.h:31
virtual ~LogStream()
Definition: chi_logstream.cc:5
const bool dummy_
Definition: chi_logstream.h:16
LogStream(std::ostream *output_stream, std::string header, bool dummy_flag=false)
Definition: chi_logstream.h:20
std::string log_header_
Definition: chi_logstream.h:15
chi::DummyStream::DummyStreamBuffer buffer