Next: LO_Packer Reference, Previous: LO_Packer, Up: LO_Packer
The following example, taken from profile.cc and profile.h,
shows a packer object being used to write an integer and
an object derived from LObject
to a file.
LO_Packer packer; LO_Stream_File l_stream_file; LO_Stream_Null l_stream_null; l_stream_file.error = _fatal; packer.set_stream(&l_stream_file); l_stream_file.open(profile_file_path,O_WRONLY,00644); int i; // Packer converts the integer to a stream of characters itself. packer << i; PStack mystack; // Note: PStack is derived from LObject. // Since PStack derived from LObject, packer will call mystack.self_pack. packer << mystack;