libzypp 17.37.17
|
#include <zypp-core/zyppng/io/iodevice.h>
Public Types | |
enum | OpenModeFlag { Closed = 0x0 , ReadOnly = 0x1 , WriteOnly = 0x2 , ReadWrite = ReadOnly | WriteOnly } |
using | Ptr = std::shared_ptr<IODevice> |
using | WeakPtr = std::weak_ptr<IODevice> |
Public Types inherited from zyppng::Base | |
using | Ptr = std::shared_ptr<Base> |
using | WeakPtr = std::weak_ptr<Base> |
Public Member Functions | |
ZYPP_DECLARE_FLAGS (OpenMode, OpenModeFlag) | |
IODevice () | |
virtual void | close () |
void | setReadChannel (uint channel) |
uint | currentReadChannel () const |
int | readChannelCount () const |
bool | canRead () const |
bool | canWrite () const |
bool | isOpen () const |
ByteArray | readAll () |
ByteArray | read (int64_t maxSize) |
int64_t | read (char *buf, int64_t maxSize) |
virtual ByteArray | readLine (const int64_t maxSize=0) |
virtual int64_t | bytesAvailable () const |
int64_t | readBufferCount () const |
bool | canReadLine () const |
ByteArray | readAll (uint channel) |
ByteArray | read (uint channel, int64_t maxSize) |
int64_t | read (uint channel, char *buf, int64_t maxSize) |
ByteArray | channelReadUntil (uint channel, const char delim, int64_t maxSize=0) |
ByteArray | channelReadLine (uint channel, int64_t maxSize=0) |
int64_t | channelReadLine (uint channel, char *buf, const int64_t maxSize) |
virtual int64_t | bytesAvailable (uint channel) const |
int64_t | readBufferCount (uint channel) const |
virtual int64_t | channelReadUntil (uint channel, char *buf, const char delimiter, const int64_t maxSize) |
bool | canReadLine (uint channel) const |
bool | canReadUntil (uint channel, const char delim) const |
int64_t | write (const ByteArray &data) |
int64_t | write (const char *data, int64_t len) |
virtual int64_t | bytesPending () const =0 |
bool | waitForReadyRead (int timeout) |
virtual bool | waitForReadyRead (uint channel, int timeout)=0 |
SignalProxy< void()> | sigReadyRead () |
SignalProxy< void(uint)> | sigChannelReadyRead () |
SignalProxy< void(int64_t)> | sigBytesWritten () |
SignalProxy< void()> | sigAllBytesWritten () |
SignalProxy< void(uint) > | sigReadChannelFinished () |
Public Member Functions inherited from zyppng::Base | |
Base () | |
virtual | ~Base () |
WeakPtr | parent () const |
void | addChild (const Base::Ptr &child) |
void | removeChild (const Ptr &child) |
const std::unordered_set< Ptr > & | children () const |
std::thread::id | threadId () const |
template<typename T> | |
std::vector< std::weak_ptr< T > > | findChildren () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () |
template<typename T> | |
std::weak_ptr< T > | weak_this () const |
template<typename T> | |
std::weak_ptr< T > | weak_this () |
template<typename SenderFunc, typename ReceiverFunc> | |
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Protected Member Functions | |
IODevice (IODevicePrivate &d) | |
virtual bool | open (const OpenMode mode) |
virtual int64_t | rawBytesAvailable (uint channel) const =0 |
virtual int64_t | writeData (const char *data, int64_t count)=0 |
virtual int64_t | readData (uint channel, char *buffer, int64_t bufsize)=0 |
virtual void | readChannelChanged (uint channel)=0 |
void | setReadChannelCount (uint channels) |
void | finishReadChannel (uint channel) |
Protected Member Functions inherited from zyppng::Base | |
Base (BasePrivate &dd) |
Additional Inherited Members | |
Static Public Member Functions inherited from zyppng::Base | |
template<typename Obj, typename Functor> | |
static decltype(auto) | make_base_slot (Obj *o, Functor &&f) |
template<typename SenderFunc, typename ReceiverFunc> | |
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Protected Attributes inherited from zyppng::Base | |
std::unique_ptr< BasePrivate > | d_ptr |
The IODevice class represents a async sequential IO device, like a Socket or Pipe, to receive and or send data.
Definition at line 32 of file iodevice.h.
using zyppng::IODevice::Ptr = std::shared_ptr<IODevice> |
Definition at line 45 of file iodevice.h.
using zyppng::IODevice::WeakPtr = std::weak_ptr<IODevice> |
Definition at line 46 of file iodevice.h.
Enumerator | |
---|---|
Closed | |
ReadOnly | |
WriteOnly | |
ReadWrite |
Definition at line 37 of file iodevice.h.
zyppng::IODevice::IODevice | ( | ) |
Definition at line 10 of file iodevice.cc.
|
protected |
Definition at line 13 of file iodevice.cc.
zyppng::IODevice::ZYPP_DECLARE_FLAGS | ( | OpenMode | , |
OpenModeFlag | ) |
|
virtual |
Reimplemented in zyppng::AsyncDataSource, zyppng::Process, and zyppng::Socket.
Definition at line 30 of file iodevice.cc.
void zyppng::IODevice::setReadChannel | ( | uint | channel | ) |
Definition at line 56 of file iodevice.cc.
uint zyppng::IODevice::currentReadChannel | ( | ) | const |
Definition at line 69 of file iodevice.cc.
int zyppng::IODevice::readChannelCount | ( | ) | const |
Definition at line 77 of file iodevice.cc.
bool zyppng::IODevice::canRead | ( | ) | const |
Definition at line 85 of file iodevice.cc.
bool zyppng::IODevice::canWrite | ( | ) | const |
Definition at line 90 of file iodevice.cc.
bool zyppng::IODevice::isOpen | ( | ) | const |
Definition at line 95 of file iodevice.cc.
ByteArray zyppng::IODevice::readAll | ( | ) |
Definition at line 121 of file iodevice.cc.
ByteArray zyppng::IODevice::read | ( | int64_t | maxSize | ) |
Definition at line 127 of file iodevice.cc.
int64_t zyppng::IODevice::read | ( | char * | buf, |
int64_t | maxSize ) |
Definition at line 134 of file iodevice.cc.
|
virtual |
Definition at line 142 of file iodevice.cc.
|
virtual |
Definition at line 109 of file iodevice.cc.
int64_t zyppng::IODevice::readBufferCount | ( | ) | const |
Definition at line 115 of file iodevice.cc.
bool zyppng::IODevice::canReadLine | ( | ) | const |
Definition at line 100 of file iodevice.cc.
ByteArray zyppng::IODevice::readAll | ( | uint | channel | ) |
Definition at line 150 of file iodevice.cc.
ByteArray zyppng::IODevice::read | ( | uint | channel, |
int64_t | maxSize ) |
Definition at line 155 of file iodevice.cc.
int64_t zyppng::IODevice::read | ( | uint | channel, |
char * | buf, | ||
int64_t | maxSize ) |
Definition at line 166 of file iodevice.cc.
ByteArray zyppng::IODevice::channelReadUntil | ( | uint | channel, |
const char | delim, | ||
int64_t | maxSize = 0 ) |
Convenience function that reads a line from the device into a ByteArray. Since this function has no way to signal if a error happened, a empty ByteArray is returned if there was no data or if a error occured.
Definition at line 188 of file iodevice.cc.
ByteArray zyppng::IODevice::channelReadLine | ( | uint | channel, |
int64_t | maxSize = 0 ) |
Convenience function that reads a line from the device into a ByteArray. Since this function has no way to signal if a error happened, a empty ByteArray is returned if there was no data or if a error occured.
Definition at line 250 of file iodevice.cc.
int64_t zyppng::IODevice::channelReadLine | ( | uint | channel, |
char * | buf, | ||
const int64_t | maxSize ) |
Reads data from the device until one of the following conditions are met:
If bytes have been read from the device this always returns the number of bytes that have been read, otherwise if no data was read 0 is returned or if a error occurs -1 is returned.
Definition at line 255 of file iodevice.cc.
|
virtual |
Definition at line 313 of file iodevice.cc.
int64_t zyppng::IODevice::readBufferCount | ( | uint | channel | ) | const |
Returns the number of bytes currently buffered in the read buffer channel
Definition at line 321 of file iodevice.cc.
|
virtual |
Reads data from the device until one of the following conditions are met:
If bytes have been read from the device this always returns the number of bytes that have been read, otherwise if no data was read 0 is returned or if a error occurs -1 is returned.
Definition at line 260 of file iodevice.cc.
bool zyppng::IODevice::canReadLine | ( | uint | channel | ) | const |
Returns true if a line can be read from the currently buffered data in the given channel
Definition at line 337 of file iodevice.cc.
bool zyppng::IODevice::canReadUntil | ( | uint | channel, |
const char | delim ) const |
Returns true if delim can be found in the currently buffered data
Definition at line 329 of file iodevice.cc.
int64_t zyppng::IODevice::write | ( | const ByteArray & | data | ) |
Definition at line 345 of file iodevice.cc.
int64_t zyppng::IODevice::write | ( | const char * | data, |
int64_t | len ) |
Definition at line 352 of file iodevice.cc.
|
pure virtual |
Returns the current number of bytes that are not yet written to the device.
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
bool zyppng::IODevice::waitForReadyRead | ( | int | timeout | ) |
Blocks the current event loop to wait until there are bytes available to read from the device. This always operates on the read channel that is selected as the default when the function is first called, even if the default channel would be changed during the wait.
Definition at line 359 of file iodevice.cc.
|
pure virtual |
Blocks the current event loop to wait until there are bytes available to read from the given read channel.
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
SignalProxy< void()> zyppng::IODevice::sigReadyRead | ( | ) |
Signal is emitted when there is data available to read on the current default read channel
Definition at line 368 of file iodevice.cc.
SignalProxy< void(uint)> zyppng::IODevice::sigChannelReadyRead | ( | ) |
Signal is emitted when there is data available on the given channel
Definition at line 373 of file iodevice.cc.
SignalProxy< void(int64_t)> zyppng::IODevice::sigBytesWritten | ( | ) |
Signal is emitted every time bytes have been written to the underlying device. This can be used to track how much data was actually sent.
Definition at line 378 of file iodevice.cc.
SignalProxy< void()> zyppng::IODevice::sigAllBytesWritten | ( | ) |
Signal is emitted every time all bytes have been written to the underlying device.
Definition at line 383 of file iodevice.cc.
SignalProxy< void(uint)> zyppng::IODevice::sigReadChannelFinished | ( | ) |
Emitted when the backing device of the given read channel is closed, data might be still available in the buffer to read
Definition at line 388 of file iodevice.cc.
|
protectedvirtual |
Reimplemented in zyppng::AsyncDataSource.
Definition at line 16 of file iodevice.cc.
|
protectedpure virtual |
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
|
protectedpure virtual |
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
|
protectedpure virtual |
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
|
protectedpure virtual |
Implemented in zyppng::AsyncDataSource, and zyppng::Socket.
|
protected |
Definition at line 37 of file iodevice.cc.
|
protected |
Definition at line 44 of file iodevice.cc.