PrevNextUpHome SophiaFramework UNIVERSE 5.3

17.4. Simple Parser

The binary stream can be used as a simple parser.

For example, in the code below,

// *** in the code below, the error handling is omitted.
SFXAnsiString data1("ansi string1");
SFXAnsiString data2("ansi string2");
SFXWideString data3("wide string");
SInt32 data4 = -10;
UInt16 data5 = 20;
Bool data6 = true;

SFXBuffer buffer;

AChar temp[] = {0x11, 0x22, 0x33, 0x44, 0x55};

buffer.Set(temp, 5);

write data as following

writer << data1 << data2 << data3 << data4 << data5 << data6 << buffer;

the data can be read as following

buffer.SetSize(5);

reader >> data1 >> data2 >> data3 >> data4 >> data5 >> data6 >> buffer;
[Note] Note
It may not work correctly if the type or the reading order is changed.