Doing the Right Thing with IPersistStream
- From: "Jason S" <jmsachs@xxxxxxxxx>
- Date: 3 Nov 2006 08:53:25 -0800
I have a custom data log file format that I want to turn into a COM
object so it is "self-aware" and can provide some extraction facilities
(e.g. if there are 7 unsigned 16-bit ints being logged, I want to
return the Nth thing as a SAFEARRAY of VT_UI2). Goody!
I guess my (general) question is, what are some Right Things to do so
that it works well with the built-in COM features?
Some specific questions:
Suppose I have implemented a COM object CJasonLog with interface
IJasonLog that derives from IPersistStream. (or should it have
IJasonLog and IPersistStream as separate interfaces?)
If I assign a pointer to IJasonLog into a CComVariant, and something
calls CComVariant::ReadFromStream, will that use my IPersistStream
implementation? Or do I need to provide another interface instead?
How do I get an IStream * from a filename, anyway? is there a COM
equivalent to fopen()?
Strategies for handling persistence for vectors of the object's
members:
(a) write the # of members to the stream, then write each member to the
stream
(b) write each member to the stream, then write a "terminator" object
to the stream so that when the stream is re-opened later, the object
can know when it's done.
Is (b) an acceptible practice? The reason I'm asking is that as I
create my datalog object in memory, as I go I will probably be
shadowing it to a disk file for each new section of the datalog, and I
don't know in advance how many datalog sections there will be.
.
- Follow-Ups:
- Re: Doing the Right Thing with IPersistStream
- From: Igor Tandetnik
- Re: Doing the Right Thing with IPersistStream
- Prev by Date: Re: VARIANT numeric conversion
- Next by Date: Re: DCOM
- Previous by thread: How Get Proxy Information
- Next by thread: Re: Doing the Right Thing with IPersistStream
- Index(es):
Relevant Pages
|