OpendTect-6_4  6.4
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  RCS: $Id$
10 ________________________________________________________________________
11 
12 */
13 
14 #include "basicmod.h"
15 #include "commondefs.h"
16 #include <streambuf>
17 #include <vector>
18 #include <istream>
19 
20 #include <QSharedPointer>
21 
22 mFDQtclass( QIODevice );
23 mFDQtclass( QProcess );
24 
25 
37 mClass(Basic) qstreambuf : public std::streambuf
38 {
39 public:
40  qstreambuf(QIODevice&,bool isstderr,
41  bool takeoverdevice);
42  ~qstreambuf();
43 
44  void detachDevice(bool readall);
51  virtual std::streambuf::int_type underflow();
52  virtual std::streamsize xsputn(const char_type*,
53  std::streamsize);
54 
55  virtual int sync();
56 
57 private:
58  void readAll();
59 
60  std::vector<char> buffer_;
62 
63  QByteArray readbuffer_;
64  QProcess* process_;
65  QIODevice* iodevice_;
66  bool isstderr_;
67 };
68 
70 mClass(Basic) iqstream : public std::istream
71 {
72 public:
73  iqstream( std::streambuf* buf )
74  : std::istream( buf )
75  {}
77  { delete rdbuf(); }
78 };
79 
80 
82 mClass(Basic) oqstream : public std::ostream
83 {
84 public:
85  oqstream( std::streambuf* buf )
86  : std::ostream( buf )
87  {}
89  { delete rdbuf(); }
90 };
91 
92 #endif
bool isstderr_
Definition: qstreambuf.h:66
Does everything a std::istream does, but also deletes the streambuf.
Definition: qstreambuf.h:70
oqstream(std::streambuf *buf)
Definition: qstreambuf.h:85
Definition: fixedstreambuf.h:17
std::vector< char > buffer_
Definition: qstreambuf.h:60
mFDQtclass(QIODevice)
Adapter to use a qprocess as a stream.
Definition: qstreambuf.h:37
iqstream(std::streambuf *buf)
Definition: qstreambuf.h:73
bool ownsdevice_
Definition: qstreambuf.h:61
~iqstream()
Definition: qstreambuf.h:76
Does everything a std::ostream does, but also deletes the streambuf.
Definition: qstreambuf.h:82
QIODevice * iodevice_
Definition: qstreambuf.h:65
QProcess * process_
Definition: qstreambuf.h:64
#define mClass(module)
Definition: commondefs.h:164
~oqstream()
Definition: qstreambuf.h:88
QByteArray readbuffer_
Definition: qstreambuf.h:63

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