new PIChunkStream::extract() method

This commit is contained in:
2020-10-08 22:29:47 +03:00
parent 4c0fe72d71
commit 16cfdc709b
2 changed files with 12 additions and 0 deletions

View File

@@ -115,7 +115,16 @@ void PIChunkStream::readAll() {
PIChunkStream::~PIChunkStream() {
}
bool PIChunkStream::extract(PIByteArray & data) {
if (data.size_s() < 4) return false;
data >> tmp_data;
if (tmp_data.size_s() < 4) return false;
data_ = &tmp_data;
_init();
return true;
}

View File

@@ -67,6 +67,9 @@ public:
//! Add data to this chunk strean with ID "id" and value "data"
template <typename T> PIChunkStream & add(int id, const T & data) {*this << ChunkConst<T>(id, data); return *this;}
//! Extract %PIByteArray from "data" and set it current stream. Returns if has data to read.
bool extract(PIByteArray & data);
void setSource(const PIByteArray & data);
void setSource(PIByteArray * data);