reading and writing objects to file



Hi,

I would like to read and write objects/structures to and from a file,
what is the approraite way to do this ? "fread" and "fwrite" are to be
sued for binary file reading and writing.

For reading:

FILE *fd;
My_Type *ptr;

....

ptr =  My_Type__alloc( );

For reading:

fread( ptr, sizeof(My_Type), 1, fd );

Then copy the data in such a way that they remain valid after transfer
to the client:

myval = ORBit_copy_value( ptr, TC_My_TypeObj );

For writing, the valid pointer can be sued directly ?

fwrite( ptr, sizeof(My_Type), 1, ptr );

I am mainly concerned about reading/writing the data into a valid object
which can be transferred over a CORBA-link.

Best regards,

Peter Van Osta

Union Biometrica N.V./S.A.
European Scientific Operations (ESO)
Cipalstraat 3
B-2440 Geel
Belgium
Tel.: +32 (0)14 570 619
Fax.: +32 (0)14 570 621

http://www.unionbio.com/

http://ourworld.compuserve.com/homepages/pvosta/cvwww.htm



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]