Re: [Libxmlplusplus-general] API questions
- From: murrayc t-online de (Murray Cumming)
- To: libxml++ <libxmlplusplus-general lists sourceforge net>
- Subject: Re: [Libxmlplusplus-general] API questions
- Date: 27 Jan 2003 12:28:37 +0100
On Sun, 2003-01-26 at 22:51, Stefan Seefeld wrote:
> > We use pointers everywhere else at the moment.
>
> hmm, isn't that dangerous ? I don't know libxml2's ownership
> semantics well, so I don't know who is responsible for child
> node cleanup etc.
Nodes are created by their parents - other Nodes, or maybe the Parser,
and are owned by them. You shouldn't need to new a Node yourself. This
seems to work. We might state that more formally later.
> Imagine you have two xmlpp::nodes, with a parent/child relationship.
> Then you delete the parent,
You shouldn't delete nodes. Let libxml++ take care of that.
> calling the underlaying libxml2
> cleanup function (which, let's say, cleans up the subtree recursively).
> Your child xmlpp::Node now points into invalid memory !
In general, if you can provide a test case that reproduces a bug, we
might investigate it.
> I would suggest you fix the semantics and then implement that
> appropriately, either by always using deep copies, or (probably better)
> by means of smart pointers (ref counting).
I feel like smart pointers could be better, but so far there doesn't
seem to be a big need. Maybe after the API freeze.
> actually, I think the libxml2 node types already contain pointers to
> the document. But right now your xmlpp::Node class isn't implemented
> in terms of libxml2 types. Why ? As I understand, libxml++ is a wrapper
> around libxml2. If this is true, you should always delegate down to
> libxml2. Specifically, xmlpp::Node should simply hold a (private)
> xmlNode pointer, from which the document can be fetched.
I'm not sure that libxml allows that, but feel free to patch.
> > UTF8 has variable numbers of bytes per character, so wstring is no good:
> > http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch03s04.html
>
> hmm, ok. What about parametrizing the whole libxml++ for the char type
> to be used ? That would work similarly to std::string and std::iosream,
> i.e. you would write a 'trait' that provides the mapping for application
> specific string classes.
Could you provide some code examples? Maybe in a separate thread.
--
Murray Cumming
murray usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]