Re: reading and writing objects to file
- From: Michael Meeks <michael ximian com>
- To: pvosta unionbio-eu com
- Cc: ORBit list <orbit-list gnome org>
- Subject: Re: reading and writing objects to file
- Date: 28 Jul 2003 18:16:31 +0100
Hi Peter,
On Wed, 2003-07-23 at 09:59, Peter Van Osta wrote:
> 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.
So - clearly you can't 'serialize' an object, at least not from the
client machine. You'd need to implement the PersistStream interface, and
then write the serialization code, and then stream the object across
from the remote handle, and write it to disk yourself [ that's a fairly
scalable way to do things ].
> fread( ptr, sizeof(My_Type), 1, fd );
>
> Then copy the data in such a way that they remain valid after transfer
> to the client:
Ok - so in bonobo 1.0 we had a really nasty way to serialize a
CORBA_any to XML which worked ( using the typecode information ). We
binned that in 2.0 since it wasn't very pretty, used ORBit internals,
and added a libxml dependency to libbonobo.
> I am mainly concerned about reading/writing the data into a valid object
> which can be transferred over a CORBA-link.
Ok - so you can't transfer a CORBA_Object - since in fact that is not
an object, but a pointer to an instance that implements a given
interface - which is rather a different thing; fully opaque, and totally
abstract.
So - you have to write your own serialization stuff; if you use
Bonobo_Stream / PersistStream, you can use: bonobo-stream-client.h's
_printf, read_string, write_string etc. that may be useful.
HTH,
Michael.
--
michael@ximian.com <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]