Class Example inherits from class ISerializable
Class Example is provided with appropriate implementations of functions read and write.
Operators '>>' and '<<' also apply to file streams, as ifstream (resp. ifstream) derives from istream (resp. ostream).
See class qgar::GenQgarSegment for an example.
A serialized object conforms to the following pattern:
CLASS-NAME(DATA_1) ... (DATA_N)
The source code of functions read and write, to respectively deserialize and serialize an object of class Example, should typically conform to the following patterns. Warning: Values of data members must be read and written in the same order.
// DESERIALIZATION std::istream& Example::read(std::istream& anInStream) { qgReadObjName(anInStream, "Example"); // Get class name qgReadObjData(anInStream, this->_data_1); // Get first data member ... qgReadObjData(anInStream, this->_data_N); // Get last data member return anInStream; } // SERIALIZATION // data_1() is supposed to be the access function // of data member Example::data_1 std::ostream& Example::write(std::ostream& anOutStream) { anOutStream << "Example" << '(' << this->_data_1() << ')' // First data member ... << '(' << this->_data_N() << ')'; // Last data member return anOutStream; }