OpendTect  6.3
qstreambuf.h
Go to the documentation of this file.
1 #ifndef qstreambuf_h
2 #define qstreambuf_h
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Feb 2009
9 ________________________________________________________________________
10 
11 */
12 
13 #include "basicmod.h"
14 #include "commondefs.h"
15 #include <streambuf>
16 #include <vector>
17 #include <istream>
18 
19 #include <QSharedPointer>
20 
21 mFDQtclass( QIODevice );
22 mFDQtclass( QProcess );
23 
24 
36 mClass(Basic) qstreambuf : public std::streambuf
37 {
38 public:
39  qstreambuf(QIODevice&,bool isstderr,
40  bool takeoverdevice);
41  ~qstreambuf();
42 
43  void detachDevice(bool readall);
50  virtual std::streambuf::int_type underflow();
51  virtual std::streamsize xsputn(const char_type*,
52  std::streamsize);
53 
54  virtual int sync();
55 
56 private:
57  void readAll();
58 
59  std::vector<char> buffer_;
61 
62  QByteArray readbuffer_;
63  QProcess* process_;
64  QIODevice* iodevice_;
65  bool isstderr_;
66 };
67 
69 mClass(Basic) iqstream : public std::istream
70 {
71 public:
72  iqstream( std::streambuf* buf )
73  : std::istream( buf )
74  {}
76  { delete rdbuf(); }
77 };
78 
79 
81 mClass(Basic) oqstream : public std::ostream
82 {
83 public:
84  oqstream( std::streambuf* buf )
85  : std::ostream( buf )
86  {}
88  { delete rdbuf(); }
89 };
90 
91 #endif
bool isstderr_
Definition: qstreambuf.h:65
Does everything a std::istream does, but also deletes the streambuf.
Definition: qstreambuf.h:69
oqstream(std::streambuf *buf)
Definition: qstreambuf.h:84
Definition: fixedstreambuf.h:18
std::vector< char > buffer_
Definition: qstreambuf.h:59
mFDQtclass(QIODevice)
Adapter to use a qprocess as a stream.
Definition: qstreambuf.h:36
iqstream(std::streambuf *buf)
Definition: qstreambuf.h:72
bool ownsdevice_
Definition: qstreambuf.h:60
~iqstream()
Definition: qstreambuf.h:75
Does everything a std::ostream does, but also deletes the streambuf.
Definition: qstreambuf.h:81
QIODevice * iodevice_
Definition: qstreambuf.h:64
QProcess * process_
Definition: qstreambuf.h:63
#define mClass(module)
Definition: commondefs.h:161
~oqstream()
Definition: qstreambuf.h:87
QByteArray readbuffer_
Definition: qstreambuf.h:62

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017