libzypp 17.32.5
iodevice.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14
15#ifndef ZYPPNG_IO_IODEVICE_DEFINED
16#define ZYPPNG_IO_IODEVICE_DEFINED
17
19#include <zypp-core/zyppng/base/Base>
20#include <zypp-core/zyppng/base/Signals>
21#include <zypp-core/zyppng/core/ByteArray>
22
23namespace zyppng {
24
25 class IODevicePrivate;
26
31 class IODevice : public Base
32 {
34 public:
35
43
44 using Ptr = std::shared_ptr<IODevice>;
45 using WeakPtr = std::weak_ptr<IODevice>;
46
47 IODevice();
48 virtual void close ();
49
50 void setReadChannel ( uint channel );
51 uint currentReadChannel () const;
52 int readChannelCount () const;
53
54 bool canRead () const;
55 bool canWrite () const;
56 bool isOpen () const;
57
59 ByteArray read ( int64_t maxSize );
60 int64_t read ( char *buf, int64_t maxSize );
61 virtual ByteArray readLine (const int64_t maxSize = 0 );
62 virtual int64_t bytesAvailable () const;
63 bool canReadLine () const;
64
65 ByteArray readAll ( uint channel );
66 ByteArray read ( uint channel, int64_t maxSize );
67 int64_t read ( uint channel, char *buf, int64_t maxSize );
68
74 ByteArray channelReadLine ( uint channel, int64_t maxSize = 0 );
75
85 virtual int64_t channelReadLine ( uint channel, char *buf, const int64_t maxSize );
86 virtual int64_t bytesAvailable( uint channel ) const;
87
91 bool canReadLine ( uint channel ) const;
92
93 int64_t write ( const ByteArray &data );
94 int64_t write ( const char *data, int64_t len );
95
104 bool waitForReadyRead(int timeout);
105
111 virtual bool waitForReadyRead(uint channel, int timeout) = 0;
112
113
118
123
128 SignalProxy< void (int64_t)> sigBytesWritten ();
129
134
135 protected:
137 virtual bool open ( const OpenMode mode );
138 virtual int64_t rawBytesAvailable ( uint channel ) const = 0;
139 virtual int64_t writeData ( const char *data, int64_t count ) = 0;
140 virtual int64_t readData ( uint channel, char *buffer, int64_t bufsize ) = 0;
141 virtual void readChannelChanged ( uint channel ) = 0;
142 void setReadChannelCount ( uint channels );
143 };
144 ZYPP_DECLARE_OPERATORS_FOR_FLAGS( IODevice::OpenMode );
145
146}
147
148#endif
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
virtual void readChannelChanged(uint channel)=0
bool canReadLine() const
Definition iodevice.cc:88
virtual int64_t writeData(const char *data, int64_t count)=0
virtual bool waitForReadyRead(uint channel, int timeout)=0
virtual ByteArray readLine(const int64_t maxSize=0)
Definition iodevice.cc:124
SignalProxy< void(uint)> sigChannelReadyRead()
Definition iodevice.cc:329
void setReadChannelCount(uint channels)
Definition iodevice.cc:37
SignalProxy< void()> sigReadyRead()
Definition iodevice.cc:324
virtual int64_t bytesAvailable() const
Definition iodevice.cc:97
virtual int64_t rawBytesAvailable(uint channel) const =0
SignalProxy< void(int64_t)> sigBytesWritten()
Definition iodevice.cc:334
bool canWrite() const
Definition iodevice.cc:78
virtual int64_t readData(uint channel, char *buffer, int64_t bufsize)=0
bool waitForReadyRead(int timeout)
Definition iodevice.cc:315
ByteArray readAll()
Definition iodevice.cc:103
ZYPP_DECLARE_FLAGS(OpenMode, OpenModeFlag)
virtual void close()
Definition iodevice.cc:30
std::weak_ptr< IODevice > WeakPtr
Definition iodevice.h:45
bool canRead() const
Definition iodevice.cc:73
SignalProxy< void()> sigAllBytesWritten()
Definition iodevice.cc:339
void setReadChannel(uint channel)
Definition iodevice.cc:44
uint currentReadChannel() const
Definition iodevice.cc:57
bool isOpen() const
Definition iodevice.cc:83
ByteArray read(int64_t maxSize)
Definition iodevice.cc:109
ByteArray channelReadLine(uint channel, int64_t maxSize=0)
Definition iodevice.cc:170
ZYPP_DECLARE_PRIVATE(IODevice)
int64_t write(const ByteArray &data)
Definition iodevice.cc:301
virtual bool open(const OpenMode mode)
Definition iodevice.cc:16
int readChannelCount() const
Definition iodevice.cc:65
std::shared_ptr< IODevice > Ptr
Definition iodevice.h:44
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177