From: Stefan S. <se...@sy...> - 2003-01-30 03:02:42
|
ok, next try: https://sourceforge.net/tracker/?group_id=12999&atid=312999 contains my patch. I now use _private pointers everywhere, i.e. for all currently supported node types, attributes, and even the dtd. This time it uses libxml2's new callback mechanism for the memory management (note that you need version 2.5.1 for it to compile. I didn't touch the configure yet to test for that version) As you will see, I cut down redundant methods quite radically. No offence intended ;-) I dropped all constructors but the one taking the implementation pointer, as that is the one being called from the callback. For all other constructors we have to rethink the memory ownership. I have a couple of ideas how to get this right, involving factory methods... Also, I dropped all the 'write' related stuff, as that isn't needed any more: as now there is only one xml tree, there is no need to dump the C++ tree into a temporary libxml2 tree in order to let libxml2 externalize it. Also, all the node API is really implemented in the Node base class, just in the protected part, and the individual derived node types drag the respective methods into the public part, or map it to better method names. Finally, there are some methods that I'm not sure whether and how to implement them, as they don't seem to make much sense in this context: I'm talking about 'add_child_content' et al., i.e. where the behavior depends on the (node) types of the parent and the child types. Since we are talking about a statically typed API, shouldn't we always know whom we ask to insert stuff, thus being more explicit like 'add_child' in elements, and 'add_content' in text nodes. Etc. As the last time, this doesn't touch the public API, with one little exception: 'get_content' now returns a string copy, not a reference. That's just the way it has to work when the internal representation is something else. Let me know whether this is accepted, the next patch will be the 'Document' type, and then the xpath lookup I'v been talking about. Then it's time for some more unit tests... Regards, Stefan |