From: Dan D. <da...@de...> - 2003-09-26 15:11:29
|
On Thu, 2003-09-25 at 18:42, Christophe de Vienne wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi all, > > Here are a few features or little technical points I'd like to see in libxml++ > one day. Some could be included in the 1.0 version, while others will > certainly wait for a 1.2. > > I would appreciate you to comment them : do you think it worth it having such > feature, and do you think it is a good technical choice. > > I may have forgot some things important for you, don't hesitate to suggest > them. > > - From you observations I will make a first RoadMap. > > ******************************************************************************* > 1 - postfix private members intead of prefixing them with an underscore > > target version : 1.0 > > The ISO c++ standart reserve names with a leading underscore to the > implemention. One shouldn't use some. > Although there is no risk of real problem with that, I think it would be > cleaner. > > ******************************************************************************* > 2 - wrap xmlIO. > > target version : 1.0 > > xmlIO interface allow the creation of our own Input/Output Buffers. Wrap them > is an elegant and efficient way to reduce some useless potentialy big strings > copy. > > Think about how to send a document to a stream. Currently we have to do : > > std::ostream & output = std::cout; // could be any ostream of course > std::string tmp = document.write_to_string(); > output << tmp; > > In the above code, the entire document is written to a buffer by libxml, then > copied to a std::string by libxml++ which is finally returned by > write_to_string(). Even the a COW implementation of std::string, we'll need > twice more memory than the size of the document. With a non-COW > implementation it is even worse : it may be copied 3 or 4 time. > > I wrote a small wrapper to xmlOutputBuffer and implemented a > Document::write_to_stream() function. The precedent code become : > > std::ostream & output = std::cout; // std::cout is still an example of course > document.write_to_stream(output); > > The advantage is much more than just writing 1 line instead of 2. The entire > document is never in memory. libxml write to buffer by small pieces which are > immediatly sent to the stream by the wrapper. A patch demonstrating this is > on the patch manager if you want to experiment it. The wrapper allow the user > to very easily define it's own OutputBuffer. I modified dom_build example to > test it, and it works pretty well. > > Another possible thing is to wrap xmlInputBuffer. Although we can (and did) > implement parse_stream without it, it would permit to implement > xmlTextReader.getRemainder() in an elegant way (cf. 3). > I think this is good, but I am also very interested in SAX serialization, perhaps based upon one of node iterators below. I think you can count on that conribution coming from me. ----- I am also personally interested in entity-support in the near term. |