PIIODevice::bytesAvailible()

fix pistringlist pibinarystream write
pibinarystream::binaryStreamSize()
PIByteArray pibinarystream read with more size fix
pistring pibinarystream read optimization
fix bug in PIIOBinaryStream read and write if failed
workaround in PIIOString::readDevice
PISPI readDevice bug Fixed
This commit is contained in:
Бычков Андрей
2022-07-27 15:43:04 +03:00
parent d13e68c206
commit 3873f0b03b
50 changed files with 323 additions and 253 deletions

View File

@@ -66,7 +66,7 @@ typedef bool (*ReadRetFunc)(const uchar *, int, void *);
PIOBJECT_SUBCLASS(name, PIIODevice) \
PIIODevice * copy() const override {return new name();} \
public: \
virtual PIConstChars fullPathPrefix() const override {return prefix;} \
PIConstChars fullPathPrefix() const override {return prefix;} \
static PIConstChars fullPathPrefixS() {return prefix;} \
private:
@@ -284,6 +284,17 @@ public:
//! \~russian Читает из устройства не более "max_size" байт и возвращает данные как PIByteArray
PIByteArray read(int max_size);
//! \~english Returns the number of bytes that are available for reading.
//! \~russian Возвращает количество байт
//! \~\details
//! \~english This function is commonly used with sequential devices
//! to determine the number of bytes to allocate in a buffer before reading.
//! If function returns -1 it mean that number of bytes undefined.
//! \~russian Эта функция как правило используется чтобы знать какой
//! размер буфера нужен в памяти для чтения.
//! Если функция возвращает -1 это значит что количество байт для чтения не известно.
virtual ssize_t bytesAvailible() const {return -1;}
//! \~english Write maximum "max_size" bytes of "data" to device
//! \~russian Пишет в устройство не более "max_size" байт из "data"
int write(const void * data, int max_size) {return writeDevice(data, max_size);}
@@ -536,7 +547,7 @@ private:
EVENT_HANDLER2(void, check_start, void * , data, int, delim);
EVENT_HANDLER(void, write_func);
virtual PIIODevice * copy() const {return 0;}
virtual PIIODevice * copy() const {return nullptr;}
PIString fullPathOptions() const;
void _init();
void begin() override;