class MyType {
BINARY_STREAM_FRIEND(MyType);
public:
void setInt(int v) {m_i = v;}
int getInt() const {return m_i;}
PIString getString()
const {
return m_s;}
private:
int m_i = 0;
};
BINARY_STREAM_WRITE(MyType) {s << v.m_i << v.m_s; return s;}
BINARY_STREAM_READ (MyType) {s >> v.m_i >> v.m_s; return s;}
int main(int argc, char * argv[]) {
MyType t_read, t_write;
t_write.setInt(10);
t_write.setString("text");
data << t_write;
data >> t_read;
piCout << t_read.getInt() << t_read.getString();
}
The PIByteArray class provides an array of bytes.
Definition: pibytearray.h:42
String class.
Definition: pistring.h:42
#define piCout
Macro used for conditional (piDebug) output to PICout(StdOut)
Definition: picout.h:35
Result:
0a000000040000007400650078007400
10 text
For store/restore custom data blocks this is PIMemoryBlock class. Stream operators of this class simply store/restore data block to/from stream:
float a_read[10], a_write[10];
for (int i = 0; i < 10; ++i) {
a_read [i] = 0.f;
a_write[i] = i / 10.f;
}
for (int i = 0; i < 10; ++i)
Help struct to store/restore custom blocks of data to/from PIBinaryStream.
Definition: pimemoryblock.h:35
Result:
00000000cdcccc3dcdcc4c3e9a99993ecdcccc3e0000003f9a99193f3333333fcdcc4c3f6666663f
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9