|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Genx
----- Original Message ----- From: "Toni Uusitalo" <toni.uusitalo@p...> > 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); 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. 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. > 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








