Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwindowspipereader_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2021 Alex Trotsenko <alex1973tr@gmail.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QWINDOWSPIPEREADER_P_H
6#define QWINDOWSPIPEREADER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qobject.h>
20#include <qmutex.h>
21#include <private/qringbuffer_p.h>
22
23#include <qt_windows.h>
24
26
27class Q_CORE_EXPORT QWindowsPipeReader : public QObject
28{
30public:
31 explicit QWindowsPipeReader(QObject *parent = nullptr);
33
34 void setHandle(HANDLE hPipeReadEnd);
35 void startAsyncRead();
36 void stop();
37 void drainAndStop();
38 void stopAndClear();
39
40 void setMaxReadBufferSize(qint64 size);
41 qint64 maxReadBufferSize() const { return readBufferMaxSize; }
42
43 bool isPipeClosed() const { return pipeBroken; }
44 qint64 bytesAvailable() const;
45 qint64 read(char *data, qint64 maxlen);
46 qint64 readLine(char *data, qint64 maxlen);
47 qint64 skip(qint64 maxlen);
48 bool canReadLine() const;
49 DWORD checkPipeState();
50 bool checkForReadyRead() { return consumePendingAndEmit(false); }
51
52 bool isReadOperationActive() const;
53 HANDLE syncEvent() const { return syncHandle; }
54
56 void winError(ulong, const QString &);
57 void readyRead();
58 void pipeClosed();
59
60protected:
61 bool event(QEvent *e) override;
62
63private:
64 enum State { Stopped, Running, Draining };
65
66 void startAsyncReadHelper(QMutexLocker<QMutex> *locker);
67 void startAsyncReadLocked();
68 void cancelAsyncRead(State newState);
69 static void CALLBACK waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
70 PTP_WAIT wait, TP_WAIT_RESULT waitResult);
71 bool readCompleted(DWORD errorCode, DWORD numberOfBytesRead);
72 bool waitForNotification();
73 bool consumePendingAndEmit(bool allowWinActPosting);
74 bool consumePending();
75
76 HANDLE handle;
77 HANDLE eventHandle;
78 HANDLE syncHandle;
79 PTP_WAIT waitObject;
80 OVERLAPPED overlapped;
81 qint64 readBufferMaxSize;
83 qint64 actualReadBufferSize;
84 qint64 pendingReadBytes;
85 mutable QMutex mutex;
86 DWORD lastError;
87
89 bool readSequenceStarted;
90 bool pipeBroken;
91 bool readyReadPending;
92 bool winEventActPosted;
93};
94
96
97#endif // QWINDOWSPIPEREADER_P_H
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qint64 maxReadBufferSize() const
void winError(ulong, const QString &)
else opt state
[0]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static void * context
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
struct _cl_event * event
GLbitfield GLuint readBuffer
#define Q_OBJECT
#define Q_SIGNALS
unsigned long ulong
Definition qtypes.h:35
long long qint64
Definition qtypes.h:60
ReturnedValue read(const char *data)
QMutex mutex
[2]