From: Ariya H. <ari...@gm...> - 2007-05-20 11:54:57
|
Hi folks, After giving some though about input stream handling, here is my proposal to simplify the implementation. The objectives: - make it very easy for developer that just wants to parse from file or memory buffer - make it possible for developer who has its own input stream implementation The first applies to the use case to create WPG to Foo converter, e.g. our very own command-line converter wpg2odg. In this case, wpg2odg does the following: OdgExporter exporter(&tmpHandler); libwpg::WPGraphics::parse(input, &exporter); where input is an instance of FileStream (or MemoryStream, if it would have loaded the content first to memory), which I think could be simplified as: OdgExporter exporter(&tmpHandler); libwpg::WPGraphics::parseFile(filename, &exporter); or OdgExporter exporter(&tmpHandler); libwpg::WPGraphics::parseBuffer(buffer, length, &exporter); where filename specifies the filename and buffer+length specifiy the memory buffer. Of course, the standard WPGraphics::parse can be still useful, especially for the second use case: applications which have its own stream handling. In particular, for example if the next version of libwpd would support embedded picture in WP document, then it needs to depend to libwpg and should allow the listener to "capture" WPG events. However, WP graphics are different than WP documents. It is unlikely that the size of the graphics would reach e.g. 10 MB or larger. Thus, input class which really "streams" the data might not be needed. In short, libwpd can just read and load the whole picture data first, then use the WPGraphics::parseBuffer() above. To clarify, here are the steps that I would like to undertake (if we agree on this): (1) Integrate the stream code completely into the main parsing code. Thus, there is no libwpg-stream module anymore and libwpg won't depend on libwpd anymore. (2) Create parseFile() and parseBuffer() convenient functions, they create the necessary file stream and memory stream and then call the standard parse() function. Thus, for those who just want to parse from file/memory, no need to deal with stream concept. (3) Only make WPGInputStream public, the other stream classes (WPGMemoryStream/FileStream/OLEStream) are internal only because they are unlikely useful for others, e.g. libwpd has its own, as does OO.o. The implications: * there is only libwpg shared library, no more libwpg-stream * libwpd does not depend on any other library, including libwpd * filter code in OO.o/Karbon/Inkscape typically uses either parseFile() or parseBuffer() function * parse() is offered only for those who really really absolutely wants to handle the input stream by itself Comments? Objections? Ideas? Regards, Ariya |