next easing of PIChunkStream::extract()

This commit is contained in:
2020-10-08 22:47:32 +03:00
parent 2e3204806f
commit 51775a5ee6
3 changed files with 25 additions and 3 deletions

View File

@@ -47,3 +47,21 @@ while (!cs2.atEnd()) {
}
piCout << i << str << f << s.i << s.f << s.s;
//! [read]
//! [write_new]
PIByteArray & operator <<(PIByteArray & s, const S & value) {
PIChunkStream cs;
cs.add(1, value.i).add(2, value.f).add(3, value.s);
s << cs.data();
return s;
}
//! [write_new]
//! [read_new]
PIByteArray & operator >>(PIByteArray & s, S & value) {
PIChunkStream cs;
if (!cs.extract(s)) return s;
cs.readAll();
cs.get(1, value.i).get(2, value.f).get(3, value.s);
return b;
}
//! [read_new]