[
Lists Home |
Date Index |
Thread Index
]
At 21:18 20.1.2004, you wrote:
>----- Original Message -----
>From: "Toni Uusitalo" <toni.uusitalo@pan.nu>
>
> > I vote for abstract "streaming writer" callback, no FILE* streams but
> > something like:
> >
> > typedef int (*PFNOUTPUTCALLBACK)(void *UserData, utf8Byte *buf, int
> cBytes,
> > int *cBytesWritten);
>
>I agree. I have actually implemented an XML writer API in Delphi,
>initially modelled after the one available in .NET, and I also
>decided to use an (abstract) IWriter interface for the target,
>as it allows you to plug in various output targets, like streams
>or encoding transformers.
>
>Btw, instead of void *UserData, maybe one registers an opaque
>WriterTarget pointer, using something like:
>
> void genxSetWriterTarget(genxWriter w, const void * writertarget);
Yes. I actually intended UserData to be called OutputData and it to
be similar to your writertarget, containing FILE* or whatever and
maybe UserData as one of its members. I copied and pasted it
from one header file of mine in a hurry.
>One should have, IMO, additional calls, to enable the target to deal
>with at least the start and end of the document. For instance, some
>encoding transformer need to write a prolog (UTF-16 BOM) or maybe even an
>epilog.
Yes. BOM and xml declaration handling should be modifiable by some settings/
callback. This is essential when user defined or libiconv etc. encoding
transformation
would be used.
>The IWriter interface I used has these methods:
>- Reset
>- Close
>- Write
>- Flush
>- State // returns current state, one of Initialized, Open, Closing, Closed
>
>However, the XML writer needs to deal with Write and Close only,
>since the start of the document can be inferred when Write is called
>on a "Closed" writer target. I believe, the rest is up to the application.
>
>For your call-back above this could be done with adding a boolean
>flag isLast to the parameters (indicating the last buffer).
>One could also add a separate call-back instead.
I don't understand this. Why the application couldn't be responsible for
opening
"stream", then setting genxSetWriterTarget and then closing the "stream" after
all writing's done?
> > You could also wrap for example gnu libiconv calls in this callback to
> > output in different encoding than UTF-8/16
> > (of course you have to work with UTF-8/wchar internally for name char
> > checking etc.). There could
> > be FILE* stream callback and maybe libiconv callback provided "in the box"
> > for genx?
>
>Exactly.
>
>Karl
>
>-----------------------------------------------------------------
>The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
>initiative of OASIS <http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To subscribe or unsubscribe from this list use the subscription
>manager: <http://lists.xml.org/ob/adm.pl>
with respect,
Toni Uusitalo
|